网络服务-

1. 搭建拓扑并连接设备

  • 添加 3 台路由器(例如 Cisco 2911 或 2620)。

  • 按以下方式连接接口(以 FastEthernet 或 GigabitEthernet 为例):

    • R1 的 g0/0 连接 R2 的 g0/0

    • R2 的 g0/1 连接 R3 的 g0/0

也可以使用 Serial 接口,但注意接口名称。本示例使用 Ethernet 接口。


2. 配置各路由器接口 IP 地址及环回口

R1 配置

bash

复制代码
enable
configure terminal
hostname R1

# 环回口 Loopback 0
interface loopback 0
ip address 192.168.10.1 255.255.255.0
no shutdown
exit

# 连接 R2 的接口(假设为 g0/0)
interface g0/0
ip address 192.168.1.1 255.255.255.0
no shutdown
exit

# 查看配置
do show ip interface brief

R2 配置

bash

复制代码
enable
configure terminal
hostname R2

# 环回口
interface loopback 0
ip address 192.168.20.1 255.255.255.0
no shutdown
exit

# 连接 R1 的接口(g0/0)
interface g0/0
ip address 192.168.1.2 255.255.255.0
no shutdown
exit

# 连接 R3 的接口(g0/1)
interface g0/1
ip address 192.168.3.2 255.255.255.0
no shutdown
exit

do show ip interface brief

R3 配置

bash

复制代码
enable
configure terminal
hostname R3

# 环回口
interface loopback 0
ip address 192.168.30.1 255.255.255.0
no shutdown
exit

# 连接 R2 的接口(g0/0)
interface g0/0
ip address 192.168.3.3 255.255.255.0
no shutdown
exit

do show ip interface brief

此时直连链路应该能通(例如从 R1 ping 192.168.1.2 成功),但非直连网段无法访问。


3. 配置静态路由(实现全网互通)

3.1 R1 上的静态路由

R1 需要到达 192.168.20.0/24 和 192.168.30.0/24,下一跳都是 R2(192.168.1.2)。

bash

复制代码
ip route 192.168.20.0 255.255.255.0 192.168.1.2
ip route 192.168.30.0 255.255.255.0 192.168.1.2

3.2 R2 上的静态路由

R2 需要到达 192.168.10.0/24(下一跳 R1)和 192.168.30.0/24(下一跳 R3)。

bash

复制代码
ip route 192.168.10.0 255.255.255.0 192.168.1.1
ip route 192.168.30.0 255.255.255.0 192.168.3.3

3.3 R3 上的静态路由

R3 需要到达 192.168.10.0/24 和 192.168.20.0/24,下一跳都是 R2(192.168.3.2)。

bash

复制代码
ip route 192.168.10.0 255.255.255.0 192.168.3.2
ip route 192.168.20.0 255.255.255.0 192.168.3.2

4. 验证全网互通

在每台路由器上执行 ping 命令,测试到其它环回口的连通性。

  • R1 上测试:

    bash

    复制代码
    ping 192.168.20.1
    ping 192.168.30.1
  • R2 上测试:

    bash

    复制代码
    ping 192.168.10.1
    ping 192.168.30.1
  • R3 上测试:

    bash

    复制代码
    ping 192.168.10.1
    ping 192.168.20.1

如果所有 ping 都成功,说明静态路由配置正确,全网互通。


5. 查看路由表(可选)

bash

复制代码
show ip route static

可以看到添加的静态路由条目。

相关推荐
isyangli_blog2 小时前
openstack 下载打包整套环境
服务器·网络·openstack
treesforest2 小时前
IP 反欺诈查询怎么落地更稳?Ipdatacloud 适用场景与实战决策闭环
网络·数据库·网络协议·tcp/ip·网络安全
不一样的故事1262 小时前
SVN 权限已赋予但客户端看不到服务端文件
大数据·网络·安全
遇印记2 小时前
网络运维DDos攻击
运维·网络·ddos
nuoxin1143 小时前
CH6001FN/BW-富利威
网络·人工智能·嵌入式硬件·fpga开发·dsp开发
lularible3 小时前
PTP协议精讲(2.18):遵循规则的艺术——Profile与一致性要求深度解析
网络·网络协议·开源·嵌入式·ptp
特长腿特长3 小时前
LVS_DR 模式的原理
linux·运维·网络·云原生·centos·lvs
数智工坊3 小时前
R-CNN目标检测算法精读全解
网络·人工智能·深度学习·算法·目标检测·r语言·cnn
AALoveTouch4 小时前
某麦网抢票:基于Wireshark协议分析
网络·测试工具·wireshark