
0、接口ip地址及PC配置
PC-IP地址配置如圖所示,R1、R2、R3、MSW1接口ip配置如下:
Router>ena
Router#conf t
Router(config-if)#hostname R1
R1(config)#int lo0
R1 (config-if)#ip add 10.0.1.1255.255.255.255
R1 (config-if)#int f0/0
R1 (config-if)#ip add 10.0.12.1 255.255.255.0
R1(config-if)#no shutdown
Router>ena
Router#conf t
Router(config)#hostname R2
R2(config)#int lo0
R2(config-if)#ip add 10.0.2.2255.255.255.255
R2(config-if)#int f0/1
R2(config-if)#ip add 10.0.12.2255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#int f0/0
R2(config-if)#ip add 10.0.23.2255.255.255.0
R2(config-if)#no shutdown
Router>ena
Router#conf t
Router(config)#hostname R3
R3(config)#int lo0
R3(config-if)#ip add 10.0.3.3255.255.255.255
R3(config-if)#int f0/1
R3(config-if)#ip add 10.0.23.3255.255.255.0
R3(config-if)#no shut
R3(config-if)#int f0/0
R3(config-if)#ip add 10.0.34.3255.255.255.0
R3(config-if)#no shut
Switch>ena
Switch#conf t
Switch(config)#hostname MSW1
MSW1(config)#int f0/5
MSW1(config-if)#no switchport
MSW1(config-if)#ip add 10.0.34.4255.255.255.0
MSW1(config-if)#int lo0
MSW1(config-if)#ip add 10.0.4.4255.255.255.255
1、路由器R1,R2,R3,三層交換機(jī)MSW1之間使用動(dòng)態(tài)路由,實(shí)現(xiàn)互通。
配置ospf協(xié)議
R1(config)#router ospf 1
R1(config-router)#router-id 10.0.1.1
R1(config-router)#network 10.0.1.1 0.0.0.0area 0
R1(config-router)#network 10.0.12.00.0.0.255 area 0
R2(config)#router ospf 1
R2(config-router)#router-id 10.0.2.2
R2(config-router)#network 10.0.2.2 0.0.0.0area 0
R2(config-router)#network 10.0.12.00.0.0.255 area 0
R2(config-router)#network 10.0.23.00.0.0.255 area 0
R3(config)#router ospf 1
R3(config-router)#router-id 10.0.3.3
R3(config-router)#network 10.0.3.3 0.0.0.0area 0
R3(config-router)#network 10.0.23.00.0.0.255 area 0
R3(config-router)#network 10.0.34.00.0.0.255 area 0
MSW1(config)#ip routing
MSW1(config)#router ospf 1
MSW1(config-router)#router-id 10.0.4.4
MSW1(config-router)#network 10.0.4.40.0.0.0 area 0
MSW1(config-router)#network 10.0.34.00.0.0.255 area 0
驗(yàn)證:
從R1上ping MSW1交換機(jī)的環(huán)回地址,實(shí)現(xiàn)互通。
R1#ping 10.0.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.4.4,timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5),round-trip min/avg/max = 0/0/1 ms
2、為R3設(shè)置網(wǎng)絡(luò)訪問(wèn)密碼,密碼為123456
R3(config)#line vty 0
R3(config-line)#password 123456
R3(config-line)#login
驗(yàn)證:使用R1 telnet R3。
R1#telnet 10.0.3.3
Trying 10.0.3.3 ...Open
User Access Verification
Password: 123456
R3>
3、MSW1和MSW2之間做鏈路聚合
MSW1(config)#interface port-channel 1
MSW1(config-if)#exit
MSW1(config)#interface range f0/6-7
MSW1(config-if-range)#channel-group 1 modedesirable
Switch(config)#hostname MSW2
MSW2 (config)#interface port-channel 1
MSW2 (config-if)#exit
MSW2 (config)#interface range f0/1-2
MSW2 (config-if-range)#channel-group 1 modedesirable
驗(yàn)證:
MSW2#show etherchannel summary
1Po1(SU)PAgPFa0/1(P) Fa0/2(P)
MSW1#show etherchannel summary
1Po1(SU)PAgPFa0/6(P) Fa0/7(P)
配置完成
4、在MSW1上設(shè)VLAN10和VLAN20,PC0 PC1屬于VLAN10,PC2 PC3屬于VLAN20,實(shí)現(xiàn)不同VLAN間互通。
MSW1#conf t
MSW1(config)#vlan 10
MSW1(config-vlan)#vlan 20
MSW1(config-vlan)#int f0/1
MSW1(config-if)#switchport access vlan 10
MSW1(config-if)#int f0/2
MSW1(config-if)#switchport access vlan 10
MSW1(config-if)#int f0/3
MSW1(config-if)#switchport access vlan 20
MSW1(config-if)#int f0/4
MSW1(config-if)#switchport access vlan 20
MSW1(config-if)#int vlan 10
MSW1(config-if)#ip add 192.168.1.254255.255.255.0
MSW1(config-if)#int vlan 20
MSW1(config-if)#ip add 192.168.2.254255.255.255.0
驗(yàn)證:使用PC1 ping PC3:
PC1>ping 192.168.2.1
Reply from 192.168.2.1: bytes=32 time=0msTTL=127
5、在二層交換機(jī)上設(shè)置VLAN30和vlan40,PC4 PC5屬于VLAN30,PC6 PC7屬于VLAN40,實(shí)現(xiàn)網(wǎng)絡(luò)隔離。
Switch>ena
Switch#conf t
Switch(config)#vlan 30
Switch(config-vlan)#vlan 40
Switch(config-vlan)#int f0/2
Switch(config-if)#switchport access vlan 30
Switch(config-if)#int f0/3
Switch(config-if)#switchport access vlan 30
Switch(config-if)#int f0/4
Switch(config-if)#switchport access vlan 40
Switch(config-if)#int f0/5
Switch(config-if)#switchport access vlan 40
驗(yàn)證:
使用PC4 ping PC6:
PC4>ping192.168.3.3
Pinging 192.168.3.3 with 32 bytes of data:
Request timed out.
Request timed out.
實(shí)現(xiàn)了網(wǎng)絡(luò)隔離
6、在二層交換機(jī)上配置默認(rèn)路由,下一跳為MSW1 VLAN20 VLAN接口地址
Switch(config)#ip default-gateway192.168.2.254