Recently at work, I needed to quickly configure IP addresses and VLANs. This is a quick page as a cheat-sheet on how you can apply the configuration on debian-based (perhaps more as well with the tools) systems using the terminal. This guide has both ad-hoc configurations, and configurations which are persistent. This guide will not use
vconfig which is commonly used, however going to be depricated.
Note that for this configuration you will need root access or at least permission to change interface configuration on the system.
Generally there are very little commands required but lets go through it:
# Create the virtual interface for eth0 with VLAN 1288
ip link add link eth0 name eth0.1288 type vlan id 1288
# Set the IP address for the virtual eth0.1288 interface
ip addr add 172.16.10.5/26 dev eth0.1288
# Bring the virtual eth0.1288 interface up
ip linkset dev eth0.1288 up
# Delete interface after use
# Will also be cleaned after a reboot
ip link delete eth0.1288
For this you need to edit the
/etc/network/interfaces file. Add this VLAN block to the end of the file.
$ vi /etc/network/interfaces
# auto eth0.1288
iface eth0.1288 inet static
dns-nameservers 172.16.10.2 220.127.116.11 18.104.22.168
You should restart the network interface or reboot the system:
Create a script to configure the VLAN interface and addresses using a bash script with commandline options.