交换机上创建中继端口,路由器配置单臂路由以支持不同VLAN间通信
你用的哪个公司的设备,思科,华为?以下是例子
思科:
中继端口
Switch(config)#interface X
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan X
Switch(config)#exit
单臂路由:
Router>enable
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z. .................
Router(config)#interface (X端口
Router(config-if)#no shutdown (激活该端口
Router(config-if)#interface fa0/0.1 (配置 子接口 这个接口是个 逻辑接口,并不是实际存在的物理接口,但是功能却和物理接口是一样的。
Router(config-subif)#ip address X.X.X.X X.X.X.X (为该接口划分ip及子网。
Router(config-subif)#encapsulation dot1q X (用802.1Q协议封装,X是vlan 号
Router(config-subif)#exit
其他机子配置过程与上雷同,X视你具体情况填
完了对两台机子互相ping,能够ping通,说明实验成功。
华为
路由器的配置
[Router]
[Router]inter e0
[Router-Ethernet0]ip add 10.0.0.1 255.255.255.0
[Router-Ethernet0]inter e0.1 (定义子接口E0.1
[Router-Ethernet0.1]ip add 172.16.1.1 255.255.255.0
[Router-Ethernet0.1]vlan-type dot1q vid 1 (指定以太网子接口属于VLAN1
[Router-Ethernet0.1]inter e0.2 (定义子接口E0.2
[Router-Ethernet0.2]ip add 172.16.2.1 255.255.255.0
[Router-Ethernet0.2]vlan-type dot1q vid 2 (指定以太网子接口属于VLAN2
[Router-Ethernet0.2]inter e0.3 (定义子接口E0.3
[Router-Ethernet0.3]ip add 172.16.3.1 255.255.255.0
[Router-Ethernet0.3]vlan-type dot1q vid 3 (指定以太网子接口属于VLAN3
[Router-Ethernet0.3]inter e0
[Router-Ethernet0]undo shut
% Interface Ethernet0 is up
[Router-Ethernet0] (用网线将E0端口连到S3026第24端口
%19:46:32: Interface Ethernet0 changed state to UP
%19:46:32: Line protocol ip on interface Ethernet0, changed state to UP
%19:46:32: Line protocol ip on interface Ethernet0.1, changed state to UP
%19:46:32: Line protocol ip on interface Ethernet0.2, changed state to UP
%19:46:32: Line protocol ip on interface Ethernet0.3, changed state to UP
成功
交换机的配置
<Quidway>
<Quidway>sys
Enter system view , return user view with Ctrl+Z.
[Quidway]vlan 1
[Quidway-vlan1]vlan 2
[Quidway-vlan2]port ethernet 0/17 to eth 0/19 eth 0/22 (将第17至19端口,和第22端口加入VLAN2
[Quidway-vlan2]vlan 3
[Quidway-vlan3]port eth 0/21 (将第21端口加入VLAN3
[Quidway-vlan3]inter e0/24
[Quidway-Ethernet0/24]port link-type trunk (将第24端口设为trunk
[Quidway-Ethernet0/24]port trunk permit vlan all (允许所有VLAN流量通过
Please wait........................................... Done.
温馨提示:内容为网友见解,仅供参考