tft每日頭條

 > 圖文

 > 路由器與三層交換機端口連接配置

路由器與三層交換機端口連接配置

圖文 更新时间:2024-12-23 00:54:57

本文主要學習路由器和三層交換機對接方法

有一個這樣的公司,客戶要求對行政部,研發部,财務部和市場部劃分四個VLAN分别是VLAN1,VLAN2,VLAN3,VLAN4

拓撲圖如下

路由器與三層交換機端口連接配置(網絡基礎之路由器和三層交換機如何對接)1

由上圖可知,現在交換機上劃分四個VLAN ,每個VLAN的接口地址如上圖所示,現将交換機VLAN1接口與路由LAN口相連,各VLAN通過VLAN1上網。

1. 路由上不劃分VLAN

1.1. 路由器設置

A添加靜态路由

“網絡設置”->“靜态路由”,添加靜态路由如下圖所示:

路由器與三層交換機端口連接配置(網絡基礎之路由器和三層交換機如何對接)2

啟用靜态路由

B為VLAN網絡加入NAT上網支持

默認情況下,隻有和路由局域網IP在同一網段的機器才能上網。進入“網絡設置”->“局域網(LAN)”,在VLAN網絡地址欄裡添加三層交換上所劃分的VLAN網絡,如下:

路由器與三層交換機端口連接配置(網絡基礎之路由器和三層交換機如何對接)3

此時,三層交換下的各VLAN網絡裡的客戶機都可以通過路由聯入互聯網了。

注意

使用這種方法劃分VLAN時,客戶機的網關地址設置三層交換機上的VLAN接口IP地址。

1.2. 三層交換機設置

這裡以華為交換機為例,配置如下:

#

vlan 1

#

vlan 2

#

vlan 3

#

vlan 4

#

interface vlan-interface1

ip address 172.16.1.1255.255.255.0

#

interface Vlan-interface2

ip address 172.16.2.1255.255.255.0

#

interface Vlan-interface3

ip address 172.16.3.1255.255.255.0

#

interface Vlan-interface4

ip address 172.16.4.1255.255.255.0

#

interface Aux0/0

#

interface Ethernet0/1

flow-control

#

interface Ethernet0/2

flow-control

#

interface Ethernet0/3

#

interface Ethernet0/4

#

interface Ethernet0/5

#

interface Ethernet0/6

#

interface Ethernet0/7

port access vlan 2

#

interface Ethernet0/8

port access vlan 2

#

interface Ethernet0/9

port access vlan 2

#

interface Ethernet0/10

port access vlan 2

#

interface Ethernet0/11

port access vlan 2

#

interface Ethernet0/12

port access vlan 2

#

interface Ethernet0/13

port access vlan 3

#

interface Ethernet0/14

port access vlan 3

#

interface Ethernet0/15

port access vlan 3

#

interface Ethernet0/16

port access vlan 3

#

interface Ethernet0/17

port access vlan 3

#

interface Ethernet0/18

port access vlan 3

#

interface Ethernet0/19

port access vlan 4

#

interface Ethernet0/20

port access vlan 4

#

interface Ethernet0/21

port access vlan 4

#

interface Ethernet0/22

port access vlan 4

#

interface Ethernet0/23

port access vlan 4

#

interface Ethernet0/24

port access vlan 4

#

interface GigabitEthernet1/1

#

interface NULL0

#

ip route-static 0.0.0.0 0.0.0.0 172.16.1.2 preference 60

2. 路由上劃分VLAN

有如下網絡拓撲圖:

路由器與三層交換機端口連接配置(網絡基礎之路由器和三層交換機如何對接)4

某公司的網絡拓撲圖

中繼接口使用 802.11q 封裝,允許所有VLAN訪問,在這種情況下,交換機上不需要設置默認路由。

路由的LAN口主IP地址為192.168.0.254,并建立了4個邏輯VLAN,和交換機上的VLAN相對應。

DHCP服務器對VLAN-1/2/3/4提供IP分配,每個VLAN獲取對應網段的地址,即:

  • VLAN-1 下的機器獲得 192.168.1.0/255.255.255.0 段的IP
  • VLAN-2 下的機器獲得 192.168.2.0/255.255.255.0 段的IP
  • VLAN-3 下的機器獲得 192.168.3.0/255.255.255.0 段的IP
  • VLAN-4 下的機器獲得 192.168.4.0/255.255.255.0 段的IP

2.1.路由器設置

2.1.1劃分vlan

“網絡設置”->“VLAN虛拟局域網”,新增VLAN網段,配置如下圖所示:

路由器與三層交換機端口連接配置(網絡基礎之路由器和三層交換機如何對接)5

2.2. 交換機設置

H3C 交換機的設置

DIS current

#

sysname SystemTest

#

local-user admin

password simple admin

service-type telnet

level 3

local-user sxy

password simple sxy

service-type telnet

#

interface Vlan-interface1

ip address 192.168.0.1 255.255.255.0

#

interface Vlan-interface100

ip address 192.168.1.1 255.255.255.0

#

interface Vlan-interface200

ip address 192.168.2.1 255.255.255.0

#

interface Vlan-interface300

ip address 192.168.3.1 255.255.255.0

#

interface Vlan-interface400

ip address 192.168.4.1 255.255.255.0

#

interface Aux1/0/0

#

interface Ethernet1/0/1

port access vlan 100

#

interface Ethernet1/0/2

port access vlan 100

#

interface Ethernet1/0/3

port access vlan 100

#

interface Ethernet1/0/4

port access vlan 100

#

interface Ethernet1/0/5

port access vlan 100

#

interface Ethernet1/0/6

port access vlan 100

#

interface Ethernet1/0/7

port access vlan 200

#

interface Ethernet1/0/8

port access vlan 200

#

interface Ethernet1/0/9

port access vlan 200

#

interface Ethernet1/0/10

port access vlan 200

#

interface Ethernet1/0/11

port access vlan 200

#

interface Ethernet1/0/12

port access vlan 200

#

interface Ethernet1/0/13

port access vlan 300

#

interface Ethernet1/0/14

port access vlan 300

#

interface Ethernet1/0/15

port access vlan 300

#

interface Ethernet1/0/16

port access vlan 300

#

interface Ethernet1/0/17

port access vlan 300

#

interface Ethernet1/0/18

port access vlan 300

#

interface Ethernet1/0/19

port access vlan 400

#

interface Ethernet1/0/20

port access vlan 400

#

interface Ethernet1/0/21

port access vlan 400

#

interface Ethernet1/0/22

port access vlan 400

#

interface Ethernet1/0/23

port access vlan 400

#

interface Ethernet1/0/24

port link-type trunk

port trunk permit vlan 1 100 200 300 400

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关圖文资讯推荐

热门圖文资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved