端口连接情况
switch1的f0/1 端口与router1的e0/0端口连接成功!
switch1的f0/2 端口与router2的e0/0端口连接成功!
switch1的f0/12 端口与switch2的f0/12端口连接成功!
switch2的f0/1 端口与router3的e0/0端口连接成功!
switch2的f0/2 端口与router4的e0/0端口连接成功!
switch2的f0/11 端口与router9的e0/0端口连接成功!
router9的e0/1 端口与router10的e0/0端口连接成功!
router10的e0/1 端口与router11的e0/0端口连接成功!
router11的e0/1 端口与switch3的f0/11端口连接成功!
switch3的f0/1 端口与router5的e0/0端口连接成功!
switch3的f0/2 端口与router6的e0/0端口连接成功!
switch3的f0/12 端口与switch4的f0/12端口连接成功!
switch4的f0/1 端口与router7的e0/0端口连接成功!
switch4的f0/2 端口与router8的e0/0端口连接成功
网段规划
sw1 sw2 vlan2 |
10.1.1.0 |
sw1sw2 vlan3 |
10.2.2.0 |
sw1 sw2 vlan2 |
192.168.1.0 |
sw1sw2 vlan3 |
192.168.2.0 |
R1___R2 |
20.0.0.0 |
R2____R3 |
30.0.0.0 |
IP地址规划
Pc1 |
10.1.1.11 |
Sw1 vlan1 |
|
Pc2 |
10.2.2.12 |
Sw2 vlan1 |
|
Pc3 |
10.1.1.13 |
Sw3 vlan1 |
|
Pc4 |
10.2.2.14 |
Sw4 vlan1 |
|
Pc5 |
192.168.1.15 |
R1 |
e0/0.1 |
10.1.1.1 |
e0/0.2 |
10.2.2.1 |
e 0/1 |
20.0.0.1 |
Pc6 |
192.168.2.16 |
R2 |
e0/0 |
20.0.0.2 |
e 0/1 |
30.0.0.1 |
Pc7 |
192.168.1.17 |
R3 |
e0/0 |
30.0.0.2 |
e0/1.1 |
192.168.1.1 |
e0/1.2 |
192.168.2.1 |
Pc8 |
192.168.2.18 |
|
|
端口规划:
Sw1 |
端口1 |
Pc1 |
Vlan2 |
端口2 |
Pc2 |
Vlan3 |
端口12 |
trunk |
|
Sw2 |
端口1 |
Pc3 |
Vlan2 |
端口2 |
Pc4 |
Vlan3 |
端口11 |
trunk |
|
端口12 |
trunk |
|
Sw3 |
端口1 |
Pc5 |
Vlan2 |
端口2 |
Pc6 |
Vlan3 |
端口11 |
trunk |
|
端口12 |
trunk |
|
Sw4 |
端口1 |
Pc7 |
Vlan2 |
端口2 |
Pc8 |
Vlan3 |
端口12 |
trunk |
|
配置过程
Pc 1
Router>en
Router#conf t
Router(config)#hostname pc1
pc1(config)#interface e0/0
pc1(config-if)#ip address 10.1.1.11 255.255.255.0
pc1(config-if)#no shutdown
pc1(config-if)#no ip routing
pc1(config)#ip default-gateway 10.1.1.1
pc1(config)#
Pc2
Router>enable
Router#conf t
Router(config)#hostname pc2
pc2(config)#interface e0/0
pc2(config-if)#ip address 10.2.2.12 255.255.255.0
pc2(config-if)#no shutdown
pc2(config-if)#no ip routing
pc2(config)#ip default-gateway 10.2.2.1
pc2(config)#
Pc3
Router>en
Router#conf t
Router(config)#hostname pc3
pc3(config)#interface e0/0
pc3(config-if)#ip address 10.1.1.13 255.255.255.0
pc3(config-if)#no shutdown
pc3(config-if)#no ip routing
pc3(config)#
pc3(config)#ip default-gateway 10.1.1.1
pc3(config)#exit
Pc4
Router>enable
Router#conf t
Router(config)#hostname pc4
pc4(config)#interface e0/0
pc4(config-if)#ip address 10.2.2.14 255.255.255.0
pc4(config-if)#no shutdown
pc4(config-if)#no ip routing
pc4(config)#ip default-gateway 10.2.2.1
pc4(config)#exit
Pc5
Router>enable
Router#conf t
Router(config)#hostname pc5
pc5(config)#interface e0/0
pc5(config-if)#ip address 192.168.1.15 255.255.255.0
pc5(config-if)#no shutdown
pc5(config-if)#no ip routing
pc5(config)#ip default-gateway 192.168.1.1
pc6
Router>en
Router#conf t
Router(config)#interface e0/0
Router(config-if)#ip address 192.168.2.16 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#no ip routing
Router(config)#ip default-gateway 192.168.2.1
Router(config)#exit
Pc7
Router>en
Router#conf t
Router(config)#hostname pc7
pc7(config)#interface e0/0
pc7(config-if)#ip address 192.168.1.17 255.255.255.0
pc7(config-if)#no shutdown
pc7(config-if)#no ip routing
pc7(config)#ip default-gateway 192.168.1.1
pc7(config)#exit
pc8
Router>en
Router#conf t
Router(config)#hostname pc8
pc8(config)#interface e0/0
pc8(config-if)#ip address 192.168.2.18 255.255.255.0
pc8(config-if)#no shutdown
pc8(config-if)#no ip routing
pc8(config)#ip default-gateway 192.168.2.1
pc8(config)#exit
sw1
Router>en
Router#conf t
Router(config)#hostname sw1
sw1(config-if)#exit
sw1#vlan database
sw1(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
sw1(vlan)#vlan 3
VLAN 3 added:
Name: VLAN0003
sw1(vlan)#exit
APPLY completed.
Exiting....
sw1(config)#interface f0/1
sw1(config-if)#switchport.access vlan 2
%Access VLAN 2 does not exist. Please add it to vlan database
sw1(config-if)#no shutdown
sw1(config-if)#.exit
sw1(config)#interface f0/2
sw1(config-if)#switchport access vlan 3
%Access VLAN 3 does not exist. Please add it to vlan database
sw1(config-if)#no shutdown
sw1(config-if)#exit
sw1(config)#interface f0/12
sw1(config-if)#switchport mode trunk
sw1(config-if)#no shutdown
*Mar 1 00:24:38.595: %DTP-5-TRUNKPORTON: Port Fa0/12 has become dot1q trunk
sw1(config-if)#exit
sw1(config)#^Z
sw1#
sw2
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname sw2
sw2(config-if)#exit
sw2#vlan database
sw2(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
sw2(vlan)#vlan 3
VLAN 3 added:
Name: VLAN0003
sw2(vlan)#exit
APPLY completed.
Exiting....
sw2(config)#interface f0/1
sw2(config-if)#switchport.access vlan 2
%Access VLAN 2 does not exist. Please add it to vlan database
sw2(config-if)#no shutdown
sw2(config-if)#.exit
sw2(config)#interface f0/2
sw2(config-if)#switchport access vlan 3
sw2(config-if)#no shutdown
sw2(config-if)#exit
sw2(config)#interface f0/11
sw2(config-if)#switchport mode trunk
sw2(config-if)#no shutdown
sw2(config-if)#exit
sw2(config)#interface f0/12
sw2(config-if)#switchport mode trunk
sw2(config-if)#no shutdown
*Mar 1 00:24:38.595: %DTP-5-TRUNKPORTON: Port Fa0/12 has become dot1q trunk
sw2(config-if)#exit
sw2(config)#^Z
Sw3
Router>enable
Router#conf t
Router(config)#hostname sw3
sw3(config)#^Z
sw3#vlan database
sw3(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
sw3(vlan)#vlan 3
VLAN 3 added:
Name: VLAN0003
sw3(vlan)#exit
APPLY completed.
Exiting....
sw3#conf t
sw3(config)#interface f0/1
sw3(config-if)#switchport access vlan 2
sw3(config-if)#no shutdown
sw3(config-if)#exit
sw3(config)#interface f0/2
sw3(config-if)#switchport access vlan 3
sw3(config-if)#no shutdown
sw3(config-if)#exit
sw3(config)#interface f0/11
sw3(config-if)#switchport mode trunk
sw3(config-if)#no shutdown
sw3(config-if)#exit
sw3(config)#interface f0/12
sw3(config-if)#switchport mode trunk
sw3(config-if)#no shutdown
*Mar 1 00:56:44.855: %DTP-5-TRUNKPORTON: Port Fa0/12 has become dot1q trunk
sw3(config-if)#exit
sw4
Router>en
Router#conf t
sw4(config)#^Z
sw4#vlan database
sw4(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
sw4(vlan)#vlan 3
VLAN 3 added:
Name: VLAN0003
sw4(vlan)#exit
APPLY completed.
Exiting....
sw4#conf t
sw4(config)#interface f0/1
sw4(config-if)#switchport access vlan 2
sw4(config-if)#no shutdown
sw4(config-if)#exit
* sw4(config)#interface f0/2
sw4(config-if)#switchport access vlan 3
sw4(config-if)#no shutdown
sw4(config-if)#exit
sw4(config)#interface f0/12
sw4(config-if)#switchport mode trunk
sw4(config-if)#no shutdown
sw4(config-if)#exit
sw4(config)#^Z
sw4#
测试
Pc5 ping pc7
pc5#ping 192.168.1.17
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.17, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 28/70/124 ms
Pc6 ping pc8
Router#ping
192.168.2.18
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.18, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 32/74/164 ms
R1
Router>enable
Router#conf t
Router(config)#hostname R1
R1(config)#interface e0/0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface e0/0.1
R1(config-subif)#encapsulation dot
R1(config-subif)#encapsulation dot1Q 2
R1(config-subif)#ip address 10.1.1.1 255.255.255.0
R1(config-subif)#no shutdown
R1(config-subif)#exit
R1(config)#interface e0/0.2
R1(config-subif)#encapsulation dot1Q 3
R1(config-subif)#ip address 10.2.2.1 255.255.255.0
R1(config-subif)#no shutdown
R1(config-subif)#exit
R1(config)#interface e0/1
R1(config-if)#ip address 20.0.0.1 255.0.0.0
R1(config-if)#no shutdown
R1(config-if)#exit
静态路由设置
R1(config)#ip route 192.168.1.0 255.255.255.0 20.0.0.2
R1(config)#ip route 192.168.2.0 255.255.255.0 20.0.0.2
R1(config)#ip route 30.0.0.0 255.0.0.0 20.0.0.2
R1#show ip route
Codes: 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
Gateway of last resort is not set
C 20.0.0.0/8 is directly connected, Ethernet0/1
10.0.0.0/24 is subnetted, 2 subnets
C 10.2.2.0 is directly connected, Ethernet0/0.2
C 10.1.1.0 is directly connected, Ethernet0/0.1
S 192.168.1.0/24 [1/0] via 20.0.0.2
S 192.168.2.0/24 [1/0] via 20.0.0.2
S 30.0.0.0/8 [1/0] via 20.0.0.2
R2
Router>en
Router#conf t
Router(config)#hostname R2
R2(config)#interface e0/0
R2(config-if)#ip address 20.0.0.2 255.0.0.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface e0/1
R2(config-if)#ip address 30.0.0.1 255.0.0.0
R2(config-if)#no shutdown
R2(config-if)#exit
静态路由设置
R2(config)#ip route 10.1.1.0 255.255.255.0 20.0.0.1
R2(config)#ip route 10.1.2.0 255.255.255.0 20.0.0.1
R2(config)#ip route 192.168.1.0 255.255.255.0 30.0.0.2
R2(config)#ip route 192.168.2.0 255.255.255.0 30.0.0.2
R2#show ip route
Codes: 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
Gateway of last resort is not set
C 20.0.0.0/8 is directly connected, Ethernet0/0
10.0.0.0/24 is subnetted, 4 subnets
S 10.2.2.0 [1/0] via 20.0.0.1
S 10.1.1.0 [1/0] via 20.0.0.1
S 192.168.1.0/24 [1/0] via 30.0.0.2
S 192.168.2.0/24 [1/0] via 30.0.0.2
C 30.0.0.0/8 is directly connected, Ethernet0/1
R3
Router>enable
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface e0/0
Router(config-if)#ip address 30.0.0.2 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface e0/1
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface e0/1.1
Router(config-subif)#encapsulation dot1Q 2
Router(config-subif)#ip address 192.168.1.1 255.255.255.0
Router(config-subif)#no shutdown
Router(config-subif)#exit
Router(config)#interface e0/1.2
Router(config-subif)#encapsulation dot1Q 3
Router(config-subif)#ip address 192.168.2.1 255.255.255.0
Router(config-subif)#no shutdown
Router(config-subif)#exit
Router(config)#
静态路由设置
Router(config)#ip route 20.0.0.0 255.0.0.0 30.0.0.1
Router(config)#ip route 10.1.1.0 255.255.255.0 30.0.0.1
Router(config)#ip route 10.2.2.0 255.255.255.0 30.0.0.1
Router(config)#exit
Router#show ip route
Codes: 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
Gateway of last resort is not set
S 20.0.0.0/8 [1/0] via 30.0.0.1
S 10.2.2.0 [1/0] via 30.0.0.1
S 10.1.1.0 [1/0] via 30.0.0.1
C 192.168.1.0/24 is directly connected, Ethernet0/1.1
C 192.168.2.0/24 is directly connected, Ethernet0/1.2
C 30.0.0.0/8 is directly connected, Ethernet0/0
动态路由设置
R1
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#network 10.1.1.0
R1(config-router)#network 10.2.2.0
R1(config-router)#network 20.0.0.0
R1(config-router)#exit
R1(config)#
R2
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#network 20.0.0.0
R2(config-router)#network 30.0.0.0
R2(config-router)#end
R2#
R3
Router(config)#router rip
Router(config-router)#version 2
Router(config-router)#no auto-summary
Router(config-router)#network 30.0.0.0
Router(config-router)#network 192.168.1.0
Router(config-router)#network 192.168.2.0
Router(config-router)#end