Scenario
Recently while doing the configuration for AWS Direct Connect, I wanted to configure onPrem Ubuntu physical host as a router. Having vlan is one of the pre-requisite and vlan onPrem switch/router should be same as created for virtual interface on AWS console. In this post, I'll explain how I configured vlan on Ubuntu. and I could configure a Ubuntu as a router for AWS Direct Connect.
Installation
Keep in mind, you can create a vlan on physical interface. There should not be any IP address assigned to the physical interface.
ifconfig outout before vlan configuration:
root@ubuntu:/home/ubuntu# ifconfig
eno1 Link encap:Ethernet HWaddr 78:2b:cb:20:60:71
inet addr:10.10.91.219 Bcast:10.10.255.255 Mask:255.255.0.0
inet6 addr: fe80::7a2b:cbff:fe20:6071/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5018984 errors:0 dropped:3117 overruns:0 frame:0
TX packets:108811 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:404946421 (404.9 MB) TX bytes:25990616 (25.9 MB)
enp5s0f0 Link encap:Ethernet HWaddr a0:36:9f:20:7d:48
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp7s0f0 Link encap:Ethernet HWaddr 00:1b:21:bf:10:e8
inet6 addr: fe80::21b:21ff:febf:10e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:419179528 errors:0 dropped:0 overruns:0 frame:0
TX packets:5283119829 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16904 errors:0 dropped:0 overruns:0 frame:0
TX packets:16904 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1324287 (1.3 MB) TX bytes:1324287 (1.3 MB)
root@ubuntu:/home/ubuntu#
eno1 was used as management interface, and enp7s0f0 is the interface where I wanted to configure vlan 112.
To create vlan run:
# vconfig add enp7s0f0 112 -v
Added VLAN with VID == 112 to IF -:enp7s0f0:-
Now, ifconfig -a should list the new vlan with same HWaddr or you cat vlan config file.
root@ubuntu:/home/ubuntu# cat /proc/net/vlan/config
VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_PLUS_VID_NO_PAD
vlan112 | 112 | enp7s0f0
root@ubuntu:/home/ubuntu#
Now, you should assign IP to the new interface. You can IP/subnet add in /etc/network/interfaces as follow
root@ubuntu:/home/ubuntu# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
iface vlan112 inet static
vlan-raw-device enp7s0f0
address x.x.x.x
netmask 255.255.255.254
root@ubuntu:/home/ubuntu#
and run
#ifup vlan112
To make interface up or assign IP from command line.
or
#sudo ip addr add x.x.x.x/31 dev vlan112
To make this setup permanent, the following lines have to be added.
Add the module to the kernel on boot:
#sudo su -c 'echo "8021q" >> /etc/modules'
After vlan is up, you should see similar output in ifconfig command.
root@ubuntu:/home/ubuntu# ifconfig
eno1 Link encap:Ethernet HWaddr 78:2b:cb:20:60:71
inet addr:10.10.91.219 Bcast:10.10.255.255 Mask:255.255.0.0
inet6 addr: fe80::7a2b:cbff:fe20:6071/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5018984 errors:0 dropped:3117 overruns:0 frame:0
TX packets:108811 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:404946421 (404.9 MB) TX bytes:25990616 (25.9 MB)
enp5s0f0 Link encap:Ethernet HWaddr a0:36:9f:20:7d:48
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp7s0f0 Link encap:Ethernet HWaddr 00:1b:21:bf:10:e8
inet6 addr: fe80::21b:21ff:febf:10e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:419179528 errors:0 dropped:0 overruns:0 frame:0
TX packets:5283119829 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:36109877661 (36.1 GB) TX bytes:7772287763609 (7.7 TB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16904 errors:0 dropped:0 overruns:0 frame:0
TX packets:16904 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1324287 (1.3 MB) TX bytes:1324287 (1.3 MB)
vlan112 Link encap:Ethernet HWaddr 00:1b:21:bf:10:e8
inet addr:x.x.x.x Bcast:255.255.255.255 Mask:255.255.255.254
inet6 addr: fe80::21b:21ff:febf:10e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:414301718 errors:0 dropped:0 overruns:0 frame:0
TX packets:471054486 errors:0 dropped:1925565 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:29987695023 (29.9 GB) TX bytes:7504521160847 (7.5 TB)
root@ubuntu:/home/ubuntu#
Recently while doing the configuration for AWS Direct Connect, I wanted to configure onPrem Ubuntu physical host as a router. Having vlan is one of the pre-requisite and vlan onPrem switch/router should be same as created for virtual interface on AWS console. In this post, I'll explain how I configured vlan on Ubuntu. and I could configure a Ubuntu as a router for AWS Direct Connect.
Installation
#sudo apt-get install vlan then Load the 8021q module into the kernel. #sudo modprobe 8021q
Configuration
Keep in mind, you can create a vlan on physical interface. There should not be any IP address assigned to the physical interface.
ifconfig outout before vlan configuration:
root@ubuntu:/home/ubuntu# ifconfig
eno1 Link encap:Ethernet HWaddr 78:2b:cb:20:60:71
inet addr:10.10.91.219 Bcast:10.10.255.255 Mask:255.255.0.0
inet6 addr: fe80::7a2b:cbff:fe20:6071/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5018984 errors:0 dropped:3117 overruns:0 frame:0
TX packets:108811 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:404946421 (404.9 MB) TX bytes:25990616 (25.9 MB)
enp5s0f0 Link encap:Ethernet HWaddr a0:36:9f:20:7d:48
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp7s0f0 Link encap:Ethernet HWaddr 00:1b:21:bf:10:e8
inet6 addr: fe80::21b:21ff:febf:10e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:419179528 errors:0 dropped:0 overruns:0 frame:0
TX packets:5283119829 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16904 errors:0 dropped:0 overruns:0 frame:0
TX packets:16904 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1324287 (1.3 MB) TX bytes:1324287 (1.3 MB)
root@ubuntu:/home/ubuntu#
eno1 was used as management interface, and enp7s0f0 is the interface where I wanted to configure vlan 112.
To create vlan run:
# vconfig add enp7s0f0 112 -v
Added VLAN with VID == 112 to IF -:enp7s0f0:-
Now, ifconfig -a should list the new vlan with same HWaddr or you cat vlan config file.
root@ubuntu:/home/ubuntu# cat /proc/net/vlan/config
VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_PLUS_VID_NO_PAD
vlan112 | 112 | enp7s0f0
root@ubuntu:/home/ubuntu#
Now, you should assign IP to the new interface. You can IP/subnet add in /etc/network/interfaces as follow
root@ubuntu:/home/ubuntu# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
iface vlan112 inet static
vlan-raw-device enp7s0f0
address x.x.x.x
netmask 255.255.255.254
root@ubuntu:/home/ubuntu#
and run
#ifup vlan112
To make interface up or assign IP from command line.
or
#sudo ip addr add x.x.x.x/31 dev vlan112
To make this setup permanent, the following lines have to be added.
Add the module to the kernel on boot:
#sudo su -c 'echo "8021q" >> /etc/modules'
After vlan is up, you should see similar output in ifconfig command.
root@ubuntu:/home/ubuntu# ifconfig
eno1 Link encap:Ethernet HWaddr 78:2b:cb:20:60:71
inet addr:10.10.91.219 Bcast:10.10.255.255 Mask:255.255.0.0
inet6 addr: fe80::7a2b:cbff:fe20:6071/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5018984 errors:0 dropped:3117 overruns:0 frame:0
TX packets:108811 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:404946421 (404.9 MB) TX bytes:25990616 (25.9 MB)
enp5s0f0 Link encap:Ethernet HWaddr a0:36:9f:20:7d:48
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
enp7s0f0 Link encap:Ethernet HWaddr 00:1b:21:bf:10:e8
inet6 addr: fe80::21b:21ff:febf:10e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:419179528 errors:0 dropped:0 overruns:0 frame:0
TX packets:5283119829 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:36109877661 (36.1 GB) TX bytes:7772287763609 (7.7 TB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16904 errors:0 dropped:0 overruns:0 frame:0
TX packets:16904 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1324287 (1.3 MB) TX bytes:1324287 (1.3 MB)
vlan112 Link encap:Ethernet HWaddr 00:1b:21:bf:10:e8
inet addr:x.x.x.x Bcast:255.255.255.255 Mask:255.255.255.254
inet6 addr: fe80::21b:21ff:febf:10e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:414301718 errors:0 dropped:0 overruns:0 frame:0
TX packets:471054486 errors:0 dropped:1925565 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:29987695023 (29.9 GB) TX bytes:7504521160847 (7.5 TB)
root@ubuntu:/home/ubuntu#
No comments:
Post a Comment