A-A+

单臂路由实现vlan之间的PC客户端的通信的配置方法

2015年11月20日 站长资讯 暂无评论

这个实验的拓扑图如下,一台路由器(router)连接一台交换机(switch),再联接两台PC客户端组成一个VLAN(虚拟局域网)。重点介绍实现VLAN间的通信的方法,ip地址的设置如图所示。

实验准备:配置好两台PC的IP地址:

switch1的配置如下:

  1. switch1#vlan database     进入vlan数据库模式  
  2.   
  3. switch1(vlan)#vlan 2      创建一个vlan 2  
  4.   
  5. VLAN 2 added:  
  6.   
  7.     Name: VLAN0002  
  8.   
  9. switch1(vlan)#vlan 3     创建一个vlan 3  
  10.   
  11. VLAN 3 added:  
  12.   
  13.     Name: VLAN0003  
  14.   
  15. switch1(vlan)#exit  
  16.   
  17. switch1(config)#int f0/1  
  18.   
  19. switch1(config-if)#switchport mode ac  将端口变为 access模式  
  20.   
  21. switch1(config-if)#switchport access vlan 2 将端口放入vlan2  
  22.   
  23. switch1(config-if)#exit  
  24.   
  25. switch1(config)#int f0/2  
  26.   
  27. switch1(config-if)#switchport mode ac  将端口变为 access 模式  
  28.   
  29. switch1(config-if)#switchport access vlan 3 将端口划入 vlan3  
  30.   
  31. switch1(config-if)#end  
  32.   
  33. switch1(config)#int f0/3  
  34.   
  35. switch1(config-if)#switchport mode trunk   将接口封装成为 trunk  
  36.   
  37. switch1(config-if)#exit  

路由器配置如下:

  1. Router(config)#hostname router1   更改路由器名字  
  2.   
  3. router1(config)#int lo 0  
  4.   
  5. router1(config-if)#ip add 1.1.1.1 255.255.255.255   为环回接口配置IP地址  
  6.   
  7. router1(config-if)#int f0/0         
  8.   
  9. router1(config-if)#no shut     将接口 f0/0开启  
  10.   
  11. router1(config-if)#exit  
  12.   
  13. http://www.xiaoxiongboke.com   
  14.   
  15. router1(config)#int f0/0.1     进入子接口配置模式  
  16.   
  17. router1(config-subif)#encapsulation dot1Q 2    将子接口封装为802.1q   
  18.   
  19. router1(config-subif)#ip add 192.168.100.1 255.255.255.0   配置IP地址  
  20.   
  21. router1(config-subif)#no shut    开启端口  
  22.   
  23. router1(config-subif)#exit  
  24.   
  25. router1(config)#int f0/0.2                      进入子接口配置模式  
  26.   
  27. router1(config-subif)#encapsulation dot1Q 3     将接口封装为 802.1q  
  28.   
  29. router1(config-subif)#ip add 192.168.200.1 255.255.255.0   配置IP地址  
  30.   
  31. router1(config-subif)#no shut    开启端口  

设备配置完成

pc1 和网关通信成功

PC2和网关通信成功

标签:

给我留言