1. 程式人生 > 實用技巧 >單臂路由的配置

單臂路由的配置

實驗拓撲圖:

實驗要求:

Router上配置單臂路由,實現不同vlan之間的通訊。

實驗過程

1.switch上劃分兩個vlan,並把f0/2劃分進vlan10,把f0/3劃分進vlan20

Router>en

Router#config t

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#end

Router#vlan database //建立vlan

Router(vlan)#vlan 10

VLAN 10 added:

Name: VLAN0010

Router(vlan)#vlan 20

VLAN 20 added:

Name: VLAN0020

Router(vlan)#exit

APPLY completed.

Exiting....

Router#config t

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#interface f0/2

Router(config-if)#switchport access vlan 10 //劃分介面進vlan

Router(config-if)#interface f0/3

Router(config-if)#switchport access vlan 20

Router(config-if)#interface f0/1

Router(config-if)#switchport mode trunk //把連線路由器的介面封裝成trunk

Router(config-if)#end

2.分別配置pc1pc2IP地址

pc1(config)#interface f0/0

pc1(config-if)#no shut

pc1(config-if)#ip add 172.16.0.1 255.255.255.0

pc1(config-if)#exit

pc1(config)#ip default-gateway 172.16.0.254 //做單臂路由的實驗,pc需要指定預設閘道器

pc2(config)#interface f0/0

pc2(config-if)#no shut

pc2(config-if)#ip add 192.168.0.1 255.255.255.0

pc2(config-if)#exit

pc2(config)#ip default-gateway 192.168.0.254

3.Router上配置單臂路由

Router>en

Router#config t

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#interface f0/0

Router(config-if)#no shut

Router(config-if)#exit

Router(config)#interface f0/0.1 //進入f0/0的子介面

Router(config-subif)#encapsulation dot1q 10 //封裝dot1q,允許vlan10通過

Router(config-subif)#ip add 172.16.0.254 255.255.255.0 //配置閘道器地址

Router(config-subif)#exit

Router(config)#interface f0/0.2

Router(config-subif)#encapsulation dot1q 20

Router(config-subif)#ip add 192.168.0.254 255.255.255.0

Router(config-subif)#end

4.測試pc1能否pingpc2

pc1#ping 192.168.0.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:

!!!!! //單臂路由可以實現不同vlan之間的通訊

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/36/76 ms

pc2#ping 172.16.0.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.0.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/38/64 ms

轉載於:https://blog.51cto.com/mxn19871215/482802