每个vlan分配一个单独的路由器物理接口,但由于路由器接口有限, 一个物理接口可以配置子接口(逻辑接口)的方式来实现一当多的功能。数据仅通过一条物理链路传输,故为单臂路由。
1、在交换上SW1 SW2 SW3创建access接口和trunk接口
SW2,配置与交换机间接口为trunk,允许所有vlan通过,与PC的接口为access,定义为vlan 10和vlan 20
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type access
[SW2-GigabitEthernet0/0/1]port default vlan 10
[SW2-GigabitEthernet0/0/1]INT G0/0/3
[SW2-GigabitEthernet0/0/3]port link-type access
[SW2-GigabitEthernet0/0/3]port default vlan 20
[SW2]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type trunk
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
SW3,配置与交换机间接口为trunk,允许所有vlan通过,与PC的接口为access,定义为vlan 30
[SW3]int g0/0/1
[SW3-GigabitEthernet0/0/1]port link-type access
[SW3-GigabitEthernet0/0/1]port default vlan 30
[SW3]int g0/0/2
[SW3-GigabitEthernet0/0/2]port link-type trunk
[SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan all
SW1,配置交换机之间,交换机与路由器之间的接口为trunkm,允许所有vlan通过。
[SW1]vlan batch 10 20 30
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2]port link-type trunk
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/2]int g0/0/3
[SW1-GigabitEthernet0/0/3]port link-type trunk
[SW1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
R路由器配置,配置子接口IP
[R-GigabitEthernet0/0/1.1]int g0/0/1.1
[R-GigabitEthernet0/0/1.1]ip address 192.168.1.254 24
[R-GigabitEthernet0/0/1.1]int g0/0/1.2
[R-GigabitEthernet0/0/1.2]ip address 192.168.2.254 24
[R-GigabitEthernet0/0/1.2]int g0/0/1.3
[R-GigabitEthernet0/0/1.3]ip address 192.168.3.254 24
R路由器配置,配置路由器子接口封装VLAN。不同vlan不同网段的pc通信,路由器进行转发,交换机SW1发送到R路由器都加上了VLAN标签,路由器作为三层设备,默认无法处理带了vlan标签的数据包。需要配置对vlan的封装,使路由器能够识别和处理vlan标签,剥离或者封装vlan标签。
[R]int g0/0/1.1
[R-GigabitEthernet0/0/1.1]dot1q termination vid 10 #剥离tag进行三层转发,发送报文时将tag添加到报文中
[R-GigabitEthernet0/0/1.1]arp broadcast enable #开启子接口的arp广播功能
[R-GigabitEthernet0/0/1.1]int g0/0/1.2
[R-GigabitEthernet0/0/1.2]dot1q termination vid 20
[R-GigabitEthernet0/0/1.2]arp broadcast enable
[R-GigabitEthernet0/0/1.2]int g0/0/1.3
[R-GigabitEthernet0/0/1.3]dot1q termination vid 30
[R-GigabitEthernet0/0/1.3]arp broadcast enable
配置完成后,display ip interface brief查看接口状态,物理状态和协议状态都正常。
最后ping测试连通性。
两台oPC处于不同的网络中,这时PC1将数据包发送自己的网关即路由器R子接口G0/0/1.1的地址192.168.1.254/24。路由器接收到数据包时,PC1发送的VLAN 10的数据帧和自身G0/0/1.1接口配置的VLAN ID一样,便会剥离vlan标签后通过三层路由转发。
dis ip routing-table查看路由表,目的地址192.168.2.1所属网段在路由表上出接口为192.168.2.254,将数据帧发送给接口G0/0/1.2,接口G0/0/1.2接收到一个剥离vlan 标签的数据帧时,便会加上自身接口配置的vlan 20后再进行转发。
实验二拓扑图如下:
一、配置PC1、PC2
二、配置LSW和R1
交换机配置
vlan batch 100 200
interface GigabitEthernet0/0/1
port link-type access
port default vlan 200
interface GigabitEthernet0/0/2
port link-type access
port default vlan 100
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 100 200
路由器配置
interface Ethernet0/0/0.100
dot1q termination vid 100
ip address 192.168.10.1 255.255.255.0
arp broadcast enable
interface Ethernet0/0/0.200
dot1q termination vid 200
ip address 192.168.20.1 255.255.255.0
AR1:interface GigabitEthernet0/0/0
ip address 172.16.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1.1
dot1q termination vid 200#200为学号,按自己需求改
ip address 200.1.1.1 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet0/0/1.2
dot1q termination vid 202 #202为学号+2,按自己需求改
ip address 202.1.1.1 255.255.255.0
arp broadcast enable
#
ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/0 172.16.1.2
AR2:
interface GigabitEthernet0/0/0
ip address 172.16.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 100.1.1.1 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/0 172.16.1.1
ip route-static 140.1.1.0 255.255.255.0 GigabitEthernet0/0/1 100.1.1.2
LSW1:
vlan batch 200 202#200为学号,按自己需求改
interface Ethernet0/0/3
port link-type access
port default vlan 200
#
interface Ethernet0/0/4
port link-type access
port default vlan 202
#
interface Ethernet0/0/16
port link-type trunk
port trunk allow-pass vlan 200 202
LSW2:
vlan batch 30 40
interface Vlanif30
ip address 100.1.1.2 255.255.255.0
#
interface Vlanif40
ip address 140.1.1.1 255.255.255.0
#
interface Ethernet0/0/3
port link-type access
port default vlan 30
#
interface Ethernet0/0/4
port link-type access
port default vlan 40
#
ip route-static 0.0.0.0 0.0.0.0 Ethernet0/0/3 100.1.1.1
ip route-static 0.0.0.0 0.0.0.0 100.1.1.1
其它的自己display
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)