【问题标题】:linux Centos multi VLAN tagging,same eth card with cisco switch trunk portlinux Centos 多 VLAN 标记,与 cisco 交换机中继端口相同的 eth 卡
【发布时间】:2017-06-08 23:29:19
【问题描述】:

我正在尝试在 linux Centos 7 中的同一个 eth 卡中使用两个 VLAN(VLAN 43 和 VLAN 44),并为 eth 端口使用 Cisco 交换机中继。

我的配置是:

[root@rdo1 network-scripts]# cat ifcfg-eth2
  TYPE=Ethernet
  DEFROUTE=no
  NAME=eth2
  DEVICE=eth2
  ONBOOT=yes
  IPV6INIT=no
  NM_CONTROLLED=no

[root@rdo1 network-scripts]# cat ifcfg-eth2.43
  VLAN=yes
  VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
  PHYSDEV=eth2
  DEVICE=eth2.43
  BOOTPROTO=static
  ONBOOT=yes
  IPADDR=10.13.43.24
  NETMASK=255.255.255.0

[root@rdo1 network-scripts]# cat ifcfg-eth2.44
  VLAN=yes
  VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
  PHYSDEV=eth2
  DEVICE=eth2.44
  BOOTPROTO=static
  ONBOOT=yes
  IPADDR=10.13.44.24
  NETMASK=255.255.255.0

思科配置:

  vlan 43-44

  !
  int gi3/1
  no ip address
  switchport
  switchport trunk encapsulation dot1q
  switchport trunk allowed vlan 43,44
  switchport mode trunk
  no mdix auto
  storm-control broadcast level 10.00
  spanning-tree bpdufilter enable
  no cdp enable
  !
  end

我根据ifconfig的网络配置是:

  [root@rdo1 network-scripts]# ifconfig
  eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  inet6 fe80::29c:2ff:fea1:35a4 prefixlen 64 scopeid 0x20<link>
  ether 00:9c:02:a1:35:a4 txqueuelen 1000 (Ethernet)
  RX packets 164 bytes 17921 (17.5 KiB)
  RX errors 0 dropped 0 overruns 0 frame 0
  TX packets 29 bytes 2424 (2.3 KiB)
  TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

  eth2.43: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  inet 10.13.43.24 netmask 255.255.255.0 broadcast 10.13.43.255
  inet6 fe80::29c:2ff:fea1:35a4 prefixlen 64 scopeid 0x20<link>
  ether 00:9c:02:a1:35:a4 txqueuelen 0 (Ethernet)
  RX packets 0 bytes 0 (0.0 B)
  RX errors 0 dropped 0 overruns 0 frame 0
  TX packets 9 bytes 690 (690.0 B)
  TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

  eth2.44: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  inet 10.13.44.24 netmask 255.255.255.0 broadcast 10.13.44.255
  inet6 fe80::29c:2ff:fea1:35a4 prefixlen 64 scopeid 0x20<link>
  ether 00:9c:02:a1:35:a4 txqueuelen 0 (Ethernet)
  RX packets 0 bytes 0 (0.0 B)
  RX errors 0 dropped 0 overruns 0 frame 0
  TX packets 12 bytes 816 (816.0 B)
  TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

我想知道如何为每个 VLAN 添加网关。 我尝试了路由表,但它们对我不起作用。

有人知道怎么做吗?

【问题讨论】:

    标签: linux centos switch-statement trunk vlan


    【解决方案1】:

    你需要这样做:

    cd /etc/sysconfig/network-scripts/

    您将有一个包含以下内容的 ifcfg-vlan43 文件:

    VLAN=yes
    TYPE=Vlan
    NAME=vlan43
    DEVICE=vlan43
    PHYSDEV=eth2
    VLAN_ID=43
    BOOTPROTO=static
    TYPE=Ethernet
    NM_CONTROLLED=no
    ONBOOT=yes
    IPADDR=10.13.43.24
    NETMASK=255.255.255.0
    

    然后您创建一个名为 rule-vlan43 的文件,其中包含以下内容:

    from 10.13.43.0/24 table vlan43
    

    然后创建一个名为 route-vlan43 的文件,其中包含以下内容:

    default via 10.13.43.1 dev vlan43 table vlan43
    

    然后编辑这个文件/etc/iproute2/rt_tables,在它的最后你必须添加类似的东西:

    143  vlan43
    

    然后,使用这些命令序列:

    ifdown vlan43
    ifup vlan43
    ip route list
    

    这将是一般的基本设置。对每个 VLAN 重复这些步骤。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      相关资源
      最近更新 更多