您的位置:首页 > 其它

实验八:VLAN的配置和单臂路由

2016-08-02 16:03 211 查看
看下列拓扑图:



需求如图,要求同一个VLANping通即可。

以R3模拟PC1,命令如下:

conf t

hostname PC1

no ip routing                       //关闭路由功能

int f0/0

ip add 192.168.10.1 255.255.255.0

no shut

exit

ip default-gateway 192.168.10.254                //配置默认的网关

end


其余R4、R5、R6命令类似。

再看路由器模拟交换机:

//由于是模拟,因此添加VLAN的方式与交换机有些不同

vlan database

vlan 10

end

conf t

hostname SW1

int f0/0

switchport mode access                           //将该接口模式设定为access

switchport access vlan 10                        //将该接口划进vlan 10

exit

int f0/1

switchport mode access

switchport access vlan 20

exit

int f0/15

switchport mode trunk encapsulation dot1q         //设置trunk使用的协议是dot1q

swithcport mode trunk                             //设置该端口的模式为trunk

//我们可以用下面这个命令来查看trunk端口

show interface trunk

//使用下面这个命令来查看端口的vlan划分

show vlan-switchport


R2的配置与上面类似

下面再说一下单臂路由

单臂路由:因为不同vlan之间不能通过交换机直接通信,必须要走路由器,而路由器的接口是很宝贵的,因此可以在路由器的一个端口上设定子端口,如此可以实现一个接口的路由活动。

拓扑图如下:



首先我们修改R2的f0/1端口的配置,将其配置成为trunk模式,命令如下:

conf t

int f0/1

no switchport acess vlan 20                    //这里删除原来的设置

switchport mode trunk en dot1q                 //协议使用dot1q

switchport mode trunk                          //模式为trunk


现在我们在R6上做单臂路由:

命令如下:

//因为是从PC改过来的,因此恢复默认设置

conf t

ip routing

host GW

default interface f0/0                 //将f0/0的设置恢复成默认的

int f0/0

no shut                                 //将f0/0打开

int f0/0.10

en dot1q 10                            //配置子接口用的trunk标准

ip add 192.168.10.254 255.255.255.0

no shut

exit

int f0/0.20

en dot1q 20                             //道理同上

ip add 192.168.20.254 255.255.255.0

no shut

exit


总结:

端口的模式有access、trunk等,设置为trunk模式时,需要先指定trunk使用的协议,trunk可能使用的协议有ISL(Cisco私有)、dot1q(802系列的协议)、negotiate(端口协商)等。

在交换机上面对端口划分VLAN的时候,是在端口模式下划分,switchport mode access ,switch access vlan 10

做单臂路由的时候,在子接口模式下,指定trunk模式使用的协议时,同时指定所属vlan,命令:en dot1q 10。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: