CISCO基本路由配置
拓扑图
接口配置
R1 Router>enable Router#configure terminal Router(config)#interface ethernet 0/0 Router(config-if)#ip address 1.1.1.1 255.255.255.0 Router(config-if)#no shutdown R2 Router>enable Router#configure terminal Router(config)#interface ethernet 0/0 Router(config-if)#ip address 1.1.1.2 255.255.255.0 Router(config-if)#no shutdown Router(config-if)#exit Router(config)#int e0/1 Router(config-if)#ip address 2.2.2.1 255.255.255.0 Router(config-if)#no shutdown R3 Router>enable Router#configure Router(config)#interface e0/0 Router(config-if)#ip address 2.2.2.2 255.255.255.0 Router(config-if)#no shutdown Router(config-if)#exit Router(config)#int e0/1 Router(config-if)#ip address 3.3.3.1 255.255.255.0 Router(config-if)#no shutdown R4 Router>enable Router#configure terminal Router(config)#interface ethernet 0/0 Router(config-if)#ip address 3.3.3.1 255.255.255.0 Router(config-if)#no shutdown
查看接口配置
Router(config-if)#do show ip int bri Interface IP-Address OK? Method Status Protocol Ethernet0/0 1.1.1.1 YES manual up up Ethernet0/1 unassigned YES unset administratively down down Ethernet0/2 unassigned YES unset administratively down down Ethernet0/3 unassigned YES unset administratively down down
静态路由配置
R1(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 R2(config)#ip route 0.0.0.0 0.0.0.0 2.2.2.2 R3(config)#ip route 0.0.0.0 0.0.0.0 2.2.2.1 R4(config)#ip route 0.0.0.0 0.0.0.0 3.3.3.1 Router(config)#do ping 3.3.3.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/4/12 ms
取消配置
R1(config)#no ip route 0.0.0.0 0.0.0.0 1.1.1.2 R2(config)#no ip route 0.0.0.0 0.0.0.0 2.2.2.2 R3(config)#no ip route 0.0.0.0 0.0.0.0 2.2.2.1 R4(config)#no ip route 0.0.0.0 0.0.0.0 3.3.3.1
动态路由rip
R1 Router(config)#router rip Router(config-router)#version 2 Router(config-router)#network 1.1.1.0 (宣告附近网段) Router(config-router)#no auto-summary R2 Router(config)#router rip Router(config-router)#version 2 Router(config-router)#network 1.1.1.0 Router(config-router)#network 2.2.2.0 Router(config-router)#no auto-summary R3 Router(config)#router rip Router(config-router)#version 2 Router(config-router)#network 3.3.3.0 Router(config-router)#network 2.2.2.0 Router(config-router)#no auto-summary R4 Router(config)#router rip Router(config-router)#version 2 Router(config-router)#network 3.3.3.0 Router(config-router)#no auto-summary
动态路由协议ospf
R1 Router(config)#router ospf 1 Router(config-router)#router-id 1.1.1.1 Router(config-router)#network 1.1.1.0 0.0.0.255 area 0 (宣告附近网段) R2 Router(config)#router ospf 1 Router(config-router)#router-id 2.2.2.2 Router(config-router)#network 1.1.1.0 0.0.0.255 area 0 Router(config-router)#network 2.2.2.0 0.0.0.255 area 0 R3 Router(config)#router ospf 1 Router(config-router)#router-id 3.3.3.3 Router(config-router)#network 3.3.3.0 0.0.0.255 area 0 Router(config-router)#network 2.2.2.0 0.0.0.255 area 0 R4 Router(config)#router ospf 1 Router(config-router)#router-id 4.4.4.4 Router(config-router)#network 3.3.3.0 0.0.0.255 area 0