模板
vlan间通信方式
单臂路由
需要借助路由器和子接口
x
// 配置vlan
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#exit
Switch(config)#int f0/2
Switch(config-if)#swit
Switch(config-if)#switchport acc
Switch(config-if)#switchport access vl
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#int f0/3
Switch(config-if)#switchport access vlan 20
Switch(config-if)#exit
Switch(config)#
xxxxxxxxxx
// 进子接口
Router(config)#int g0/0/0.10
Router(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/0.10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0.10, changed state to up
Router(config-subif)#enca
Router(config-subif)#encapsulation d
Router(config-subif)#encapsulation dot1Q 10 //封装标签
xxxxxxxxxx
Router(config-subif)#ip add
Router(config-subif)#ip address 192.168.1.254 255.255.255.0 //子接口配ip
Router(config-subif)#
xxxxxxxxxx
// 第二个子接口配置
Router(config)#int g0/0/0.20
Router(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/0.20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0.20, changed state to up
Router(config-subif)#en
Router(config-subif)#encapsulation d
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip ad
Router(config-subif)#ip address 192.168.2.254 255.255.255.0
Router(config-subif)#
xxxxxxxxxx
// 交换机创建vlan加入接口改trunk放行
Switch(config)#interface f0/2
Switch(config-if)#sw
Switch(config-if)#switchport ac
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#int f0/3
Switch(config-if)#sw
Switch(config-if)#switchport ac
Switch(config-if)#switchport access vlan 20
Switch(config-if)#exit
Switch(config)#int f0/1
Switch(config-if)#sw
Switch(config-if)#switchport mo
Switch(config-if)#switchport mode t
Switch(config-if)#switchport mode trunk
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
switchport t
Switch(config-if)#switchport trunk all
Switch(config-if)#switchport trunk allowed vl
Switch(config-if)#switchport trunk allowed vlan 10,20
Switch(config-if)#
利用三层交换机和vlan接口
// 与上类似
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#int f0/1
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#int f0/2
Switch(config-if)#sw
Switch(config-if)#switchport ac
Switch(config-if)#switchport access vl
Switch(config-if)#switchport access vlan 20
Switch(config-if)#
// ------------------------------------
Switch(config-if)#exit
Switch(config)#interface vlan 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
Switch(config-if)#ipa
Switch(config-if)#ip a
Switch(config-if)#ip add
Switch(config-if)#ip address 192.168.1.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface vlan 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#ip ad
Switch(config-if)#ip address 192.168.2.254 255.255.255.0
Switch(config-if)#
Switch(config)#ip routing //开启功能