思科单臂路由配置
 
网络的组建:
路由器F0/0端口与交换机的上联端口F0/5相连,交换机的下联端口F0/11和F0/12分别接PC1和PC2,交换机下联口划分为两个VLAN,分别是
VLAN10和VLAN20,其中PC1属于VLAN10,PC2属于VLAN20;
1、路由器的配置:
R1(config)#int f0/0       //进入f0/0端口;
R1(config-if)#no sh  //打开端口;
R1(config-if)#int f0/0.1  //进入f0/0子端口1;
R1(config-subif)#ip add 192.168.1.1 255.255.255.0 //配置IP地址;
R1(config-subif)#encapsulation dot1q 10   //用IEEE802.Q封装协议封装,指定给VLAN 10
R1(config-subif)#no sh
R1(config-subif)#int f0/0.2  //进入f0/0子端口2;
R1(config-subif)#ip add 192.168.2.1 255.255.255.0 //配置IP地址;
R1(config-subif)#encapsulation dot1q 20   //用IEEE802.Q封装协议封装,指定给VLAN 20
R1(config-subif)#no sh
-----------------------------------------------------------------------------------------------------------------------
2.交换机上的配置:
SW1(config)#int f1/5  //进入f1/5端口;
SW1(config-if)#switchport mode trunk  //设置干道模式;
SW1(config-if)#switchport trunk encapsulation dot1q   //用IEEE802.Q封装协议封装;
SW1(config-if)#no sh
SW1(config-if)#end
SW1#vlan database  //进入vlan配置模式;
SW1(vlan)#vlan 10 name v10 //新建VLAN 10;
SW1(vlan)#vlan 20 name v20 //新建VLAN 20;
SW1#conf t
SW1(config)#int f1/11
SW1(config-if)#switchport access vlan 10  //把f1/11端口划分给VLAN 10;
SW1(config-if)#no sh
SW1(config-if)#int f1/12
SW1(config-if)#switchport access vlan 20 //把f1/11端口划分给VLAN 10;
SW1(config-if)#no sh
-----------------------------------------------------------------------------------------------------------------------
PC1上的配置:
PC1#if eth0 192.168.1.100 netmask 255.255.255.0  //配置IP地址;
PC1# route add default gw 192.168.1.1   //配置网关;
PC2上的配置:
PC2#if eth0 192.168.2.100 netmask 255.255.255.0  //配置IP地址;
PC2# route add default gw 192.168.2.1   //配置网关;
-----------------------------------------------------------------------------------------------------------------------
测试:
在PC1上PING PC2的IP地址,结果如下:
PC1#ping 192.168.2.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/50/56 ms
在PC2上PING PC1的IP地址,结果如下:
PC2#ping 192.168.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/52/72 ms