华为华三思科路由器连接交换机的几种方法

路由器一般连接不同网段,隔离广播域,交换机用来扩展主机,可以隔离冲突域;

路由器和交换机连接有以下几种方法:

路由器和交换机连接方法一般为以下三种:

1.交换机划分VLAN,并通过VLAN虚接口配置地址,将路由器与交换机互联的接口划分到相应的VLAN下,此时链路类型trunk和access都可以,路由器直接在三层接口下配地址;

2.路由器和交换机分别划分VLAN后通过VLAN虚接口配置地址,然后在路由器和交换机上将互联的接口划分到相应的VLAN下;

3.路由器划分子接口,并封装802.1协议,交换机和路由器链路类型为trunk

以下是在华为华三思科模拟器上做实验的结果:

华为设备配置命令:

拓扑图:

 

方法1.路由器:

interface Ethernet0/0/0

   ip address 10.10.23.2 255.255.255.0

交换机:

interface Vlanif10

   ip address 10.10.23.3 255.255.255.0

interface GigabitEthernet0/0/1

   port link-type access

   port default vlan 10

方法2.路由器:

interface Vlanif10

   ip address 10.10.25.2 255.255.255.0

interface Ethernet0/0/1

   portswitch                  (三层接口与二层接口转换)

   port link-type access

   port default vlan 10

交换机:

interface Vlanif20

   ip address 10.10.25.5 255.255.255.0

interface GigabitEthernet0/0/1

   port link-type access

 port default vlan 20

方法3:路由器:

interface GigabitEthernet0/0/0.30

   dot1q termination vid 30

   ip address 10.10.24.2 255.255.255.0

交换机:

interface Vlanif30

   ip address 10.10.24.4 255.255.255.0

interface Ethernet0/0/1

   port link-type trunk              (利用子接口连接,链路类型必须为trunk)

   port trunk allow-pass vlan 30

华三设备配置命令:

拓扑图:

方法1.路由器:

interface GigabitEthernet0/2

   port link-mode route

   ip address 10.10.14.1 255.255.255.0

交换机:

interface GigabitEthernet1/0/1

   port link-mode route                (华三支持直接将二层口转为三层口)

ip address 10.10.14.4 255.255.255.0

方法2.路由器:

interface Vlan-interface10

   ip address 10.10.10.1 255.255.255.0

interface GigabitEthernet0/0

   port link-mode bridge

   port access vlan 10

交换机:interface Vlan-interface10

   ip address 10.10.10.2 255.255.255.0

interface GigabitEthernet1/0/1

   port link-mode bridge

   port access vlan 10

方法3.路由器:

interface GigabitEthernet0/1.20

   ip address 10.10.13.1 255.255.255.0

   vlan-type dot1q vid 20            (华为华三思科三者封装命令有区别)

交换机:

interface Vlan-interface20

   ip address 10.10.13.3 255.255.255.0

interface GigabitEthernet1/0/1

   port link-mode bridge

   port link-type trunk

   port trunk permit vlan 1 20

思科设备配置命令:

拓扑图:

方法1.路由器:

interface FastEthernet0/0

   ip address 10.10.12.1 255.255.255.0

交换机:

interface Vlan10

   ip address 10.10.12.2 255.255.255.0

interface FastEthernet0/1

   switchport access vlan 10

方法2.路由器:

interface FastEthernet0/1.20

   encapsulation dot1Q 20            (先封装后加地址,否则有可能无法添加地址)

   ip address 10.10.13.1 255.255.255.0

交换机:interface Vlan20

   ip address 10.10.13.3 255.255.255.0

interface FastEthernet0/1

   switchport trunk allowed vlan 20

   switchport mode trunk

总结:

路由器与交换机连接一般都可以用这几种办法来配置,比较常用的就是利用802.1q协议来封装,此时需要注意的就是链路类型为trunk模式,当路由器利用VLAN来连接时,需要将端口类型转换为二层接口,但是对于一些路由器型号来说不支持三层与二层互相转换,对于思科设备来说,在接口下加地址时,记得每次都要将端口开启,思科默认为关闭模式。

发布了11 篇原创文章 · 获赞 2 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/w_6858189/article/details/105037573
今日推荐