Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Create VLAN Interface In Linux

VLAN (virtual local area network) is very useful concept as you can easily separate device management from users by using appropriate network devices and configuration.

Install user mode programs to enable VLANs on your ethernet devices:
$ sudo apt-get install vlan

Load 8021q module (IEEE 802.1Q):
$ sudo modprobe 8021q

To load 8021q module at the boot time add it to the /etc/modules file:
$ sudo echo 8021q >> /etc/modules
$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.

# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

Solution For Temporary
Create VLAN 700 on the eth0 device:
$ sudo vconfig add eth0 700

Add VLAN with VID == 700 to IF -:eth0:-
Set IP address ( netmask in this example):
$ sudo ifconfig eth0.700

Created interface is named as eth0.700:
$ sudo ifconfig -a
eth0      Link encap:Ethernet  HWaddr 84:8f:69:b0:fa:0a
         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)

eth0.700  Link encap:Ethernet  HWaddr 84:8f:69:b0:fa:0a
         inet addr:  Bcast:  Mask:
         UP BROADCAST MULTICAST  MTU:1500  Metric:1
         RX packets:11 errors:0 dropped:0 overruns:0 frame:0
         TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:884 (884.0 B)  TX bytes:3158 (3.0 KiB)

Now you can access other hosts available in VLAN 700:
$ ping -c 1
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=64 time=1.28 ms

--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.282/1.282/1.282/0.000 ms

To remove VLAN 700 from the eth0 interface execute command:
$ sudo vconfig rem eth0.700

Removed VLAN -:eth0.700:-
Permanent solution
To create VLAN at the boot time you need to get familiar with /etc/network/interfaces configuration file (man interfaces, man vlan-interfaces).

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

To create VLAN 700 on the eth0 interface at the boot time just add similar configuration:
# add vlan 700 on eth0 - static IP address
auto eth0.700
iface eth0.700 inet static


Popular posts from this blog

PostgreSQL pgBadger

PostgreSQL Pgbadger Installation On Linux

How to configure Replication Manager (repmgr) ?

What's is the difference between streaming replication Vs hot standby vs warm standby ?

Script to kill ALL IDLE Connection In postgreSQL