Cisco配置静态路由

实验拓扑

配置R1

sh 复制代码
Router(config)#hostname R1

# 配置e0/0接口地址
R1(config)#interface e0/0
R1(config-if)#ip  address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown

# 配置e0/1 接口地址
R1(config-if)#interface e0/1
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no shutdown 

# 添加其他网段路由
R1(config)#ip route 192.168.23.0 255.255.255.0 192.168.12.2
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.12.2

查看接口ip

sh 复制代码
R1#show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                192.168.12.1    YES manual up                    up      
Ethernet0/1                192.168.1.254   YES manual up                    up      
Ethernet0/2                unassigned      YES unset  administratively down down    
Ethernet0/3                unassigned      YES unset  administratively down down    
Serial1/0                  unassigned      YES unset  administratively down down    
Serial1/1                  unassigned      YES unset  administratively down down    
Serial1/2                  unassigned      YES unset  administratively down down    
Serial1/3                  unassigned      YES unset  administratively down down 

查看R1路由表

sh 复制代码
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.1.0/24 is directly connected, Ethernet0/1
L        192.168.1.254/32 is directly connected, Ethernet0/1
S     192.168.3.0/24 [1/0] via 192.168.12.2
      192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.12.0/24 is directly connected, Ethernet0/0
L        192.168.12.1/32 is directly connected, Ethernet0/0
S     192.168.23.0/24 [1/0] via 192.168.12.2

配置R2

sh 复制代码
# 修改主机名
Router>enable
Router#configure terminal 
Router(config)#hostname R2

# 配置e0/0接口地址
R2(config)#interface e0/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown 

# 配置e0/1接口地址
R2(config-if)#interface e0/1
R2(config-if)#ip address 192.168.23.2 255.255.255.0
R2(config-if)#no shutdown 

# 添加到其他网段路由
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.12.1
R2(config)#ip route 192.168.3.0 255.255.255.0 192.168.23.3

查看接口ip

sh 复制代码
R2#show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                192.168.12.2    YES manual up                    up      
Ethernet0/1                192.168.23.2    YES manual up                    up      
Ethernet0/2                unassigned      YES unset  administratively down down    
Ethernet0/3                unassigned      YES unset  administratively down down    
Serial1/0                  unassigned      YES unset  administratively down down    
Serial1/1                  unassigned      YES unset  administratively down down    
Serial1/2                  unassigned      YES unset  administratively down down    
Serial1/3                  unassigned      YES unset  administratively down down

查看路由

sh 复制代码
R2#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

S     192.168.1.0/24 [1/0] via 192.168.12.1
S     192.168.3.0/24 [1/0] via 192.168.23.3
      192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.12.0/24 is directly connected, Ethernet0/0
L        192.168.12.2/32 is directly connected, Ethernet0/0
      192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.23.0/24 is directly connected, Ethernet0/1
L        192.168.23.2/32 is directly connected, Ethernet0/1

配置R3

sh 复制代码
Router>enable 
Router#configure terminal 
Router(config)#hostname R3
R3(config)#

R3(config)#interface e0/0
R3(config-if)#ip address 192.168.23.3 255.255.255.0
R3(config-if)#no shutdown

R3(config-if)#interface e0/1
R3(config-if)#ip address 192.168.3.254 255.255.255.0
R3(config-if)#no shutdown 

R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.23.2
R3(config)#ip route 192.168.12.0 255.255.255.0 192.168.23.2

查看接口ip

sh 复制代码
R3#show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                192.168.23.3    YES manual up                    up      
Ethernet0/1                192.168.3.254   YES manual up                    up      
Ethernet0/2                unassigned      YES unset  administratively down down    
Ethernet0/3                unassigned      YES unset  administratively down down    
Serial1/0                  unassigned      YES unset  administratively down down    
Serial1/1                  unassigned      YES unset  administratively down down    
Serial1/2                  unassigned      YES unset  administratively down down    
Serial1/3                  unassigned      YES unset  administratively down down   

查看路由

sh 复制代码
R3#show ip route 
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

S     192.168.1.0/24 [1/0] via 192.168.23.2
      192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.3.0/24 is directly connected, Ethernet0/1
L        192.168.3.254/32 is directly connected, Ethernet0/1
S     192.168.12.0/24 [1/0] via 192.168.23.2
      192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.23.0/24 is directly connected, Ethernet0/0
L        192.168.23.3/32 is directly connected, Ethernet0/0

配置vpc4

sh 复制代码
VPCS> ip 192.168.1.2/24 192.168.1.254
Checking for duplicate address...
VPCS : 192.168.1.2 255.255.255.0 gateway 192.168.1.254

配置vpc5

sh 复制代码
VPCS> ip 192.168.3.2/24 192.168.3.254
Checking for duplicate address...
VPCS : 192.168.3.2 255.255.255.0 gateway 192.168.3.254

在vpc4上ping vpc5测试连通性

sh 复制代码
VPCS> ping 192.168.3.2

84 bytes from 192.168.3.2 icmp_seq=1 ttl=61 time=0.958 ms
84 bytes from 192.168.3.2 icmp_seq=2 ttl=61 time=0.785 ms
84 bytes from 192.168.3.2 icmp_seq=3 ttl=61 time=1.050 ms
84 bytes from 192.168.3.2 icmp_seq=4 ttl=61 time=0.823 ms
84 bytes from 192.168.3.2 icmp_seq=5 ttl=61 time=0.827 ms
相关推荐
花果山~~程序猿37 分钟前
高级I/O知识分享【5种IO模型 || select || poll】
运维·服务器·网络
吴半杯1 小时前
Linux-mysql5.7-mysql8.0安装包下载及安装教程,二合一
linux·运维·服务器
默行默致1 小时前
Linux 常用命令
linux·运维
卡戎-caryon2 小时前
【Linux】09.Linux 下的调试器——gdb/cgdb
linux·运维·服务器·开发语言·笔记
小小的木头人4 小时前
Docker vs. containerd 深度剖析容器运行时
运维·docker·容器
Data 3174 小时前
Shell脚本编程基础(二)
大数据·linux·运维·数据仓库·sql·centos·bash
it技术分享just_free5 小时前
基于 K8S kubernetes 的常见日志收集方案
linux·运维·docker·云原生·容器·kubernetes·k8s
aidroid6 小时前
git github仓库管理
linux·运维·docker
学习3人组6 小时前
集群服务器主机实现主机名与IP绑定
运维·服务器·tcp/ip
it技术分享just_free6 小时前
基于 K8S kubernetes 搭建 安装 EFK日志收集平台
运维·docker·云原生·容器·kubernetes·k8s