锐捷网管交换机通过VLAN实现二层隔离,三层互连配置举例

一、组网需求
某用户内网存在三个部门,相互之间需要二层隔离,三层互联。

因此分别在3台接入设备Device A、Device B和Device C上创建VLAN,用户内网被划分为VLAN 10、VLAN 20和VLAN 30,相互之间二层隔离。把接口定义为一个VLAN的成员,所有连接到此接口的终端都是VLAN网络的一部分。调整用户所在VLAN,只需要调整接口的VLAN配置,而不必调整物理位置。

在核心设备Device D上配置3个VLAN,配置连接Device A、B和C的接口为Trunk口,并指定许可VLAN列表。配置3个SVI,分别作为3个VLAN对应IP子网的网关接口,3个VLAN对应的IP子网分别为192.168.10.0/24、192.168.20.0/24和192.168.30.0/24,3个VLAN通过三层核心设备的IP转发能力实现子网互连。

二、 组网图
图1-16 VLAN典型应用场景配置组网图
VLAN 典型应用场景配置组网图

 

三、配置要点
●在三层核心设备Device D上配置3个VLAN,配置连接Device A、B和C的接口为Trunk口,并配置许可VLAN列表,实现二层隔离。

●在Device D配置3个SVI口,分别作为3个VLAN对应IP子网的网关接口,配置网关IP地址。在终端上根据所在网段,配置默认网关地址。

●分别在3台接入设备Device A、B和C上创建VLAN,为各VLAN分配Access口,配置连接Device D的接口为Trunk口。

四、 配置步骤
(1) 创建和配置VLAN。
# 在核心设备Device D上创建VLAN。修改VLAN 10的名称。

DeviceD> enable

DeviceD# configure terminal

DeviceD(config)# vlan 10

DeviceD(config-vlan)# name office

DeviceD(config-vlan)# vlan range 20,30

DeviceD(config-vlan-range)# exit

# 在接入设备Device A上创建VLAN。

DeviceA> enable

DeviceA# configure terminal

DeviceA(config)# vlan range 10,20

DeviceA(config-vlan-range)# exit

# 在接入设备Device B上创建VLAN。

DeviceB> enable

DeviceB# configure terminal

DeviceB(config)# vlan range 10,20,30

DeviceB(config-vlan-range)# exit

# 在接入设备Device C上创建VLAN。

DeviceC> enable

DeviceC# configure terminal

DeviceC(config)# vlan range 20,30

DeviceC(config-vlan-range)# exit

(2) 在Device D上配置VLAN三层SVI口的IP地址。

DeviceD(config)# interface vlan 10

DeviceD(config-if-VLAN 10)# ip address 192.168.10.1 255.255.255.0

DeviceD(config-if-VLAN 10)# exit

DeviceD(config)# interface vlan 20

DeviceD(config-if-VLAN 20)# ip address 192.168.20.1 255.255.255.0

DeviceD(config-if-VLAN 20)# exit

DeviceD(config)# interface vlan 30

DeviceD(config-if-VLAN 30)# ip address 192.168.30.1 255.255.255.0

DeviceD(config-if-VLAN 30)# exit

(3) 配置Device D的下联口为Trunk口,分别配置其许可VLAN范围。

DeviceD(config)# interface range gigabitethernet 0/2-4

DeviceD(config-if-range)# switchport

DeviceD(config-if-range)# switchport mode trunk

DeviceD(config-if-range)# exit

DeviceD(config)# interface gigabitethernet 0/2

DeviceD(config-if-GigabitEthernet 0/2)# switchport trunk native vlan 1

DeviceD(config-if-GigabitEthernet 0/2)# switchport trunk allowed vlan only 10,20

DeviceD(config-if-GigabitEthernet 0/2)# exit

DeviceD(config)# interface gigabitethernet 0/3

DeviceD(config-if-GigabitEthernet 0/3)# switchport trunk native vlan 1

DeviceD(config-if-GigabitEthernet 0/3)# switchport trunk allowed vlan only 10,20,30

DeviceD(config-if-GigabitEthernet 0/3)# exit

DeviceD(config-if)# interface gigabitethernet 0/4

DeviceD(config-if-GigabitEthernet 0/4)# switchport trunk native vlan 1

DeviceD(config-if-GigabitEthernet 0/4)# switchport trunk allowed vlan only 20,30

DeviceD(config-if-GigabitEthernet 0/4)# end

DeviceD# write

(4) 配置接入设备上联口为Trunk口,配置其许可VLAN范围。如下以Device A配置为例,B和C配置类似。

# 配置Device A的上联口为Trunk模式。许可所有VLAN的数据通过。

DeviceA(config)# interface gigabitethernet 0/1

DeviceA(config-if-GigabitEthernet 0/1)# switchport

DeviceA(config-if-GigabitEthernet 0/1)# switchport mode trunk

DeviceA(config-if-GigabitEthernet 0/1)# switchport trunk native vlan 1

DeviceA(config-if-GigabitEthernet 0/1)# switchport trunk allowed vlan all

DeviceA(config-if-GigabitEthernet 0/1)# exit

(5) 配置接入设备下联口为Access口,并加入指定VLAN。如下以Device A配置为例,B和C配置类似。

# 配置Device A的下联口为Access模式,分别加入不同的VLAN。

DeviceA(config)# interface range gigabitethernet 0/2-12

DeviceA(config-if-range)# switchport

DeviceA(config-if-range)# switchport mode access

DeviceA(config-if-range)# switchport access vlan 10

DeviceA(config-if-range)# interface range gigabitethernet 0/13-24

DeviceA(config-if-range)# switchport

DeviceA(config-if-range)# switchport mode access

DeviceA(config-if-range)# switchport access vlan 20

DeviceA(config-if-range)# end

DeviceA# write

五、验证配置结果
(1) 在Device D上,使用show vlan [ id vlan-id ]命令查看VLAN信息,包括VLAN ID、名称、状态和加入接口。

DeviceD# show vlan

VLAN Name    Status        Ports

—- ——– ——–  ——————————-

1 VLAN0001  STATIC   Gi0/1, Gi0/5, Gi0/6, Gi0/7

Gi0/8, Gi0/9, Gi0/10, Gi0/11

Gi0/12, Gi0/13, Gi0/14, Gi0/15

Gi0/16, Gi0/17, Gi0/18, Gi0/19

Gi0/20, Gi0/21, Gi0/22, Gi0/23

Gi0/24

10 office  STATIC   Gi0/2, Gi0/3

20 VLAN0020 STATIC   Gi0/2, Gi0/3, Gi0/4

30 VLAN0030 STATIC   Gi0/3, Gi0/4

(2) 查看接口配置和状态是否正确。

# 在Device D上,使用show interface switchport命令查看接口的VLAN状态。

DeviceD# show interface switchport

Interface            Switchport Mode   Access Native Protected VLAN lists

——————————– ———- ——— —— —— ——— —

GigabitEthernet 0/2       enabled  TRUNK      1   Disabled 10,20

GigabitEthernet 0/3       enabled  TRUNK      1   Disabled 10,20,30

GigabitEthernet 0/4       enabled  TRUNK      1   Disabled 20,30

# 在Device D上,使用show interface description命令查看接口状态为up。

DeviceD# show interface description

Interface                Status  Administrative Description

—————————————- ——– ————– ———–

GigabitEthernet 0/2           up    up

GigabitEthernet 0/3           up    up

GigabitEthernet 0/4           up    up

 

VLAN 10                 up    up

VLAN 20                 up    up

VLAN 30                 up    up

(3) 在Device D上,使用show ip route命令查看SVI的直连路由是否正确。

# 目的IP匹配192.168.10.0/24的报文,向VLAN 10转发;目的IP匹配192.168.20.0/24的报文,向VLAN 20转发;目的IP匹配192.168.30.0/24的报文,向VLAN 30转发。

DeviceD# show ip route

Codes: C – Connected, L – Local, S – Static

R – RIP, O – OSPF, B – BGP, I – IS-IS, V – Overflow route

N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2

E1 – OSPF external type 1, E2 – OSPF external type 2

SU – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2

IA – Inter area, EV – BGP EVPN, A – Arp to host

LA – Local aggregate route

* – candidate default

 

Gateway of last resort is no set

C   192.168.10.0/24 is directly connected, VLAN 10

C   192.168.10.1/32 is local host.

C   192.168.20.0/24 is directly connected, VLAN 20

C   192.168.20.1/32 is local host.

C   192.168.30.0/24 is directly connected, VLAN 30

C   192.168.30.1/32 is local host.

# 在Device D上可以Ping通VLAN(例如VLAN 10)的SVI地址。

DeviceD# ping 192.168.10.1

Sending 5, 100-byte ICMP Echoes to 192.168.10.1, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms.

(4) 以终端Host 2、Host 12和Host 13为例,验证连通性。

# 配置VLAN 10内Host 2的缺省网关为192.168.10.1,接口IP地址为192.168.10.2,掩码255.255.255.0。

Host2> enable

Host2# configure terminal

Host2(config)# ip route 0.0.0.0 0.0.0.0 192.168.10.1

Host2(config)# interface gigabitethernet 0/1

Host2(config-if-GigabitEthernet 0/1)# no switchport

Host2(config-if-GigabitEthernet 0/1)# ip address 192.168.10.2 255.255.255.0

# 配置VLAN 10内Host 12的缺省网关为192.168.10.1,接口IP地址为192.168.10.12,掩码255.255.255.0。

Host2> enable

Host2# configure terminal

Host2(config)# ip route 0.0.0.0 0.0.0.0 192.168.10.1

Host2(config)# interface gigabitethernet 0/1

Host2(config-if-GigabitEthernet 0/1)# no switchport

Host2(config-if-GigabitEthernet 0/1)# ip address 192.168.10.12 255.255.255.0

# 配置VLAN 20内Host 13的缺省网关为192.168.20.1,接口IP地址为192.168.20.13,掩码255.255.255.0。

Host13> enable

Host13# configure terminal

Host13(config)# ip route 0.0.0.0 0.0.0.0 192.168.20.1

Host13(config)# interface gigabitethernet 0/1

Host13(config-if-GigabitEthernet 0/1)# no switchport

Host13(config-if-GigabitEthernet 0/1)# ip address 192.168.20.13 255.255.255.0

# 在终端上使用show ip route命令查看缺省网关。发送端和接收端都需要配置缺省网关,任何一方未配置都无法实现跨网段通信。以Host 2为例,因存在缺省路由S*0.0.0.0/0 [1/0] via 192.168.10.1,当终端需要跨网段通信时,将报文交由网关192.168.10.1转发。

Host2# show ip route

Codes: C – Connected, L – Local, S – Static

R – RIP, O – OSPF, B – BGP, I – IS-IS, V – Overflow route

N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2

E1 – OSPF external type 1, E2 – OSPF external type 2

SU – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2

IA – Inter area, EV – BGP EVPN, A – Arp to host

LA – Local aggregate route

* – candidate default

 

Gateway of last resort is 192.168.10.1 to network 0.0.0.0

S*  0.0.0.0/0 [1/0] via 192.168.10.1

C   192.168.10.0/24 is directly connected, GigabitEthernet 0/1

C   192.168.10.2/32 is local host.

# 在DeviceD上可以Ping通终端(例如Host 2)的IP地址。

DeviceD# ping 192.168.10.2

Sending 5, 100-byte ICMP Echoes to 192.168.10.2, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/4 ms.

# 同VLAN(例如VLAN 10)内的终端能够互相Ping通。

Host2# ping 192.168.10.12

Sending 5, 100-byte ICMP Echoes to 192.168.10.12, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms.

# 不同VLAN内的终端也可以互相Ping通。但若在Device D上删除SVI的IP地址配置,或在终端上删除缺省网关,不同VLAN内的终端则无法Ping通。

Host2# ping 192.168.20.13

Sending 5, 100-byte ICMP Echoes to 192.168.10.3, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms.

六、 配置文件
●Device D的配置文件

vlan 10

name office

vlan range 1,20,30

!

interface GigabitEthernet 0/2

switchport

switchport mode trunk

switchport trunk native vlan 1

switchport trunk allowed vlan only 10,20

!

interface GigabitEthernet 0/3

switchport

switchport mode trunk

switchport trunk native vlan 1

switchport trunk allowed vlan only 10,20,30

!

interface GigabitEthernet 0/4

switchport

switchport mode trunk

switchport trunk native vlan 1

switchport trunk allowed vlan only 20,30

!

interface VLAN 10

ip address 192.168.10.1 255.255.255.0

interface VLAN 20

ip address 192.168.20.1 255.255.255.0

interface VLAN 30

ip address 192.168.30.1 255.255.255.0

l Device A的配置文件。接口的相似配置用省略号表示。Device B和C的配置类似。

interface GigabitEthernet 0/1

switchport mode trunk

!

interface GigabitEthernet 0/2

switchport

switchport mode access

switchport access vlan 10

interface GigabitEthernet 0/12

switchport

switchport mode access

switchport access vlan 10

!

interface GigabitEthernet 0/13

switchport

switchport mode access

switchport access vlan 20

interface GigabitEthernet 0/24

switchport

switchport mode access

switchport access vlan 20

七、常见错误
● 未配置网关(SVI)的IP地址,或未配置终端的缺省网关,或者终端的发送端或接收端其中一个未配置缺省网关,都将导致不同VLAN内的终端无法Ping通。

●相互连接的Trunk口Native VLAN配置不同,可能导致数据不通。

● 未将连接终端的接口配置为Access口,可能导致数据不通。

● 若需要Trunk口只通过一个VLAN的报文,但只使用了添加命令却未移除Trunk口的缺省许可VLAN,导致配置结果和规划不符合。

●本设备的Trunk口发送Native VLAN的帧不携带Tag,若第三方厂商设备要求Trunk口接收的帧必须携带Tag,则可能导致本设备发送数据在接收端被丢弃。此情况下,需要配置本设备连接友商设备的接口为Uplink口,使接口发送的报文均携带Tag。

ICP备案号:晋ICP备18007549号-1
站长微信:13613567205