-1

I'm trying to use two VLANs (VLAN 43 & VLAN 44) in same eth card in linux Centos 7 and Cisco switch trunk for the eth port.

My configuration is:

[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

Cisco configuration:

  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

My network configuration according to ifconfig is:

  [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

I want to know how to add gateway for every VLAN. I tried routing tables and they didn't work for me.

Does anyone know how to do this?

Omar Ali
  • 8,467
  • 4
  • 33
  • 58

1 Answers1

0

You will need to do like this:

cd /etc/sysconfig/network-scripts/

there you will have an ifcfg-vlan43 file having this content:

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

Then you create a file called rule-vlan43 having this content:

from 10.13.43.0/24 table vlan43

Then create a file called route-vlan43 having this content:

default via 10.13.43.1 dev vlan43 table vlan43

Then edit this file /etc/iproute2/rt_tables and at the end of it you have to add something like:

143  vlan43

Afterwards, use these sequence of commands:

ifdown vlan43
ifup vlan43
ip route list

That would be a general basic setup. Repeat the steps for each of your VLAN(s).

Bogdan Stoica
  • 4,349
  • 2
  • 23
  • 38