1. 程式人生 > >##實驗 1-4 VLAN 間路由

##實驗 1-4 VLAN 間路由

##實驗 1-4 VLAN 間路由
學習目標
 掌握用於VLAN間路由的Trunk介面的配置方法
 掌握在單個物理介面上配置多個子介面的方法
 掌握在VLAN間實現ARP通訊的配置方法
在這裡插入圖片描述

企業內部網路通常會通過劃分不同的VLAN來隔離不同部門之間的二層通
信,並保證各部門間的資訊保安。但是由於業務需要,部分部門之間需要實現跨VLAN通訊,網路管理員決定藉助路由器,通過配置單臂路由實現R1與R3之間跨VLAN通訊需求。
操作步驟
步驟一. 實驗環境準備
如果本任務中您使用的是空配置裝置,需要從步驟1開始配置,然後跳過步
驟2。如果使用的裝置包含上一個實驗的配置,請直接從步驟2開始配置。
配置R1、R3和S1的裝置名稱,並按照拓撲圖配置R1的G0/0/1介面的IP地
址。
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.0.4.1 24
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
system-view
[Quidway]sysname S1
步驟二. 清除裝置上原有的配置
刪除R3的G0/0/2介面IP地址,清除交換機上GVRP的配置並關閉無關埠。
[R3]interface GigabitEthernet 0/0/2
[R3-GigabitEthernet0/0/2]undo ip address
[S1]undo gvrp
[S1]interface GigabitEthernet 0/0/13
[S1-GigabitEthernet0/0/13]undo port trunk allow-pass vlan 2 to 4094
[S1-GigabitEthernet0/0/13]shutdown
[S1-GigabitEthernet0/0/13]quit
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]undo port hybrid vlan 2 4
[S1-GigabitEthernet0/0/1]quit
[S1]undo vlan batch 2 100 200
[S2]undo gvrp
[S2]interface GigabitEthernet 0/0/6
[S2-GigabitEthernet0/0/6]undo port trunk allow-pass vlan 2 to 4094
[S2-GigabitEthernet0/0/6]shutdown
[S2-GigabitEthernet0/0/6]quit
[S2]interface GigabitEthernet 0/0/3
[S2-GigabitEthernet0/0/3]undo port hybrid vlan 2 4
[S2-GigabitEthernet0/0/3]quit
[S2]undo vlan batch 2 100 200
[S3]undo gvrp
[S3]interface Ethernet 0/0/13
[S3-Ethernet0/0/13]undo port trunk allow-pass vlan 2 to 4094
[S3-Ethernet0/0/13]port link-type hybrid
[S3-Ethernet0/0/13]quit
[S3]interface Ethernet 0/0/1
[S3-Ethernet0/0/1]undo port trunk allow-pass vlan 2 to 4094
[S3-Ethernet0/0/1]quit
[S3]undo vlan 2
[S4]undo gvrp
[S4]interface Ethernet 0/0/6
[S4-Ethernet0/0/6]undo port trunk allow-pass vlan 2 to 4094
[S4-Ethernet0/0/6]port link-type hybrid
[S4-Ethernet0/0/6]quit
[S4]interface Ethernet 0/0/1
[S4-Ethernet0/0/1]undo port trunk allow-pass vlan 2 to 4094
[S4-Ethernet0/0/1]quit
[S4]undo vlan 2
步驟三. 為 R3 配置 IP 地址
按照拓撲圖配置R3上的G0/0/1介面的IP地址。
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 10.0.8.1 24
步驟四. 建立 VLAN
在S1上建立VLAN 4和VLAN 8,將埠G0/0/1加入到VLAN 4中,將埠
G0/0/3加入到VLAN 8中。
[S1]vlan batch 4 8
Info: This operation may take a few seconds. Please wait for a moment…done.
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]port link-type access
[S1-GigabitEthernet0/0/1]port default vlan 4
[S1-GigabitEthernet0/0/1]quit
[S1]interface GigabitEthernet0/0/3
[S1-GigabitEthernet0/0/3]port link-type access
[S1-GigabitEthernet0/0/3]port default vlan 8
[S1-GigabitEthernet0/0/3]quit
將S1連線路由器的G0/0/2埠配置為Trunk介面,並允許VLAN 4和VLAN
8的報文通過。
[S1]interface GigabitEthernet0/0/2
[S1-GigabitEthernet0/0/2]port link-type trunk
[S1-GigabitEthernet0/0/2]port trunk allow-pass vlan 4 8
步驟五. 配置 R2 上的子介面實現 VLAN 間路由
由於路由器只有一個實際的物理介面與交換機S1相連,而實際上不同部門
屬於不同VLAN和不同網段,所以在路由器上配置不同的邏輯子介面來扮演不同的閘道器角色,在R2上配置子介面G0/0/1.1和G0/0/1.3,並作為VLAN 4和VLAN 8的閘道器。
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]interface GigabitEthernet0/0/1.1
[R2-GigabitEthernet0/0/1.1]ip address 10.0.4.254 24
[R2-GigabitEthernet0/0/1.1]dot1q termination vid 4
[R2-GigabitEthernet0/0/1.1]arp broadcast enable
[R2-GigabitEthernet0/0/1.1]quit
[R2]interface GigabitEthernet0/0/1.3
[R2-GigabitEthernet0/0/1.3]ip address 10.0.8.254 24
[R2-GigabitEthernet0/0/1.3]dot1q termination vid 8
[R2-GigabitEthernet0/0/1.3]arp broadcast enable
在R1和R3上各配置一條預設路由指向各自的閘道器。
[R1]ip route-static 0.0.0.0 0.0.0.0 10.0.4.254
[R3]ip route-static 0.0.0.0 0.0.0.0 10.0.8.254
配置完成後,檢測R1與R3間的連通性。
ping 10.0.8.1
配置檔案
[R1]display current-configuration
[V200R007C00SPC600]

sysname R1

interface GigabitEthernet0/0/1
ip address 10.0.4.1 255.255.255.0

ip route-static 0.0.0.0 0.0.0.0 10.0.4.254

user-interface con 0
authentication-mode password
set authentication password cipher % % dD#}P<HzJ;Xs%X>hOkm!,.+Iq61QKK6tI}cc -;k_o

C.+L,% %
user-interface vty 0 4

return
[R2]display current-configuration
[V200R007C00SPC600]

sysname R2

interface GigabitEthernet0/0/1

interface GigabitEthernet0/0/1.1
dot1q termination vid 4
ip address 10.0.4.254 255.255.255.0
arp broadcast enable

interface GigabitEthernet0/0/1.3
dot1q termination vid 8
ip address 10.0.8.254 255.255.255.0
arp broadcast enable

user-interface con 0
authentication-mode password
set authentication password cipher % % |nRPL^hr2IXi7LHDID!/,.%.8%h;3:,hXO2d
k#ikaWI.
(,% %
user-interface vty 0 4

return
[R3]display current-configuration
[V200R007C00SPC600]

sysname R3

interface GigabitEthernet0/0/1
ip address 10.0.8.1 255.255.255.0

ip route-static 0.0.0.0 0.0.0.0 10.0.8.254

user-interface con 0
authentication-mode password
set authentication password cipher % % W|KaTeX parse error: Expected 'EOF', got '}' at position 5: )M5D}̲[email protected]^gK\;>QR,.*…%$
user-interface vty 0 4

Return
[S1]display current-configuration

!Software Version V200R008C00SPC500
sysname S1

vlan batch 4 8

interface GigabitEthernet0/0/1
port link-type access
port default vlan 4

interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 4 8

interface GigabitEthernet0/0/3
port link-type access
port default vlan 8

user-interface con 0
user-interface vty 0 4

return