VLAN实验

VLAN实验

VLAN实验_第1张图片

如图所示:图中共有四个广播域,左边逻辑的分为两个广播域,右边也是逻辑的分为两个广播域,

配置顺序先配置交换机,在配置路由器

SW1 配置:

1、首先创建vlan

[sw1]vlan batch 2 3

2、把对应接口划入VLAN

​ 因为是交换机和电脑连接的口,所以链路类型为access

​ 这个口所属的 VLAN 为 VLAN 2,相当于把0/0/2划入vlan 2

0/0/2接口配置:

[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/2]port default vlan 2

同样0/0/3接口配置:

[sw1-GigabitEthernet0/0/3]port link-type access
[sw1-GigabitEthernet0/0/3]port default vlan 3

3、配置trunk干道

交换机与交换机相连配置链路类型为trunk

[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all

4、配置VLAN间路由:

sw1 无直连路由

SW2 配置:

undo terminal monitor      -------去除配置成功后的日志:
[sw2]vlan batch 2 3
[sw2]int g 0/0/3
[sw2-GigabitEthernet0/0/3]p l a
[sw2-GigabitEthernet0/0/3]p d v 2
[sw2-GigabitEthernet0/0/3]int g 0/0/4
[sw2-GigabitEthernet0/0/4]p l a
[sw2-GigabitEthernet0/0/4]p d v 3
[sw2-GigabitEthernet0/0/4]int g 0/0/2
[sw2-GigabitEthernet0/0/2]p l t
[sw2-GigabitEthernet0/0/2]p t a v a
[sw2-GigabitEthernet0/0/2]int g 0/0/1
[sw2-GigabitEthernet0/0/1]p l t
[sw2-GigabitEthernet0/0/1]p t a v a
[sw2-GigabitEthernet0/0/1]

SW3 配置:

undo terminal monitor
[sw3]vlan batch 2 3
[sw3]int g 0/0/2
[sw3-GigabitEthernet0/0/2]p l a
[sw3-GigabitEthernet0/0/2]p d v 2
[sw3-GigabitEthernet0/0/2]int g 0/0/3
[sw3-GigabitEthernet0/0/3]p l a
[sw3-GigabitEthernet0/0/3]p d v 3
[sw3-GigabitEthernet0/0/3]int g 0/0/1
[sw3-GigabitEthernet0/0/1]p l t
[sw3-GigabitEthernet0/0/1]p t a v a
[sw3-GigabitEthernet0/0/1]

配完以后,我们要想做到一个跨VLAN的通讯的话,我们要配置路由器

首先一共是四个广播域,对应接口分别管对应广播域的VLAN,网段划分如下:

VLAN实验_第2张图片

先0/0/0口,创建VLAN,创建子接口0/0/0.1,子接口对应 vlan 2 网关配置,划分vlan,记得开启arp,

[r1]vlan batch 2 3
[r1]interface GigabitEthernet 0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip address 192.168.1.254 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable 

同理子接口0/0/0.2配置VLAN 3

[r1]interface GigabitEthernet 0/0/0.2
[r1-GigabitEthernet0/0/0.2]ip address 192.168.2.254 24
[r1-GigabitEthernet0/0/0.2]dot1q termination vid 3
[r1-GigabitEthernet0/0/0.2]arp broadcast enable 

然后0/0/1口,同样创建子接口0/0/1.1,子接口对应 vlan 2 网关配置,划分vlan,记得开启arp

[r1]interface GigabitEthernet 0/0/1.1
[r1-GigabitEthernet0/0/1.1]ip address 192.168.3.254 24
[r1-GigabitEthernet0/0/1.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/1.1]arp broadcast enable 

同理子接口0/0/1.2配置VLAN 3

[r1]interface GigabitEthernet 0/0/1.2
[r1-GigabitEthernet0/0/1.2]ip address 192.168.4.254 24
[r1-GigabitEthernet0/0/1.2]dot1q termination vid 3
[r1-GigabitEthernet0/0/1.2]arp broadcast enable 

要去电脑使用DHCP获取,所以路由开启DHCP

1、开启DCHP

[r1]dhcp enable

2、创建IP池,宣告,网关,DNS

四个网段,所以创建四个池

aa

[r1]ip pool aa	
[r1-ip-pool-aa]network 192.168.1.0 mask 24
[r1-ip-pool-aa]gateway-list 192.168.1.254
[r1-ip-pool-aa]dns-list 114.114.114.114

bb

[r1]ip pool bb 
[r1-ip-pool-bb]network 192.168.2.0 mask 24	
[r1-ip-pool-bb]gateway-list 192.168.2.254
[r1-ip-pool-bb]dns-list 114.114.114.114

cc

[r1]ip pool cc
[r1-ip-pool-cc]network 192.168.3.0 mask 24
[r1-ip-pool-cc]gateway-list 192.168.3.254
[r1-ip-pool-cc]dns-list 114.114.114.114

dd

[r1]ip pool dd
[r1-ip-pool-dd]network 192.168.4.0 mask 24	
[r1-ip-pool-dd]gateway-list 192.168.4.254
[r1-ip-pool-dd]dns-list 114.114.114.114

进入对应的接口选取配置

[r1]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global 

[r1]int g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]dhcp select global

[r1]int g 0/0/1.1
[r1-GigabitEthernet0/0/1.1]dhcp select global

[r1]int g 0/0/1.2
[r1-GigabitEthernet0/0/1.2]dhcp select global

VLAN实验_第3张图片

VLAN实验_第4张图片

全网可达完成

你可能感兴趣的:(VLAN实验)