Skip to content

Commands to deal with ethernet and VLAN interfaces in Linux

Command to admin up an ethernet interface

sudo ifconfig eth1 up

Command to admin down an ethernet interface

sudo ifconfig eth1 down

Command to set an interface for DHCP (for example eth1 interface)

sudo ifconfig eth1 0.0.0.0 0.0.0.0

Command to set an interface for static IP (for example 10.1.1.1)

sudo ifconfig eth1 10.1.1.1/24

Command to restart the network service

sudo service network restart

Command to create VLAN interface (for example VLAN 101 on eth1)

sudo vconfig add eth1 101

Command to admin up a VLAN interface

sudo ifconfig eth1.101 up

Command to admin down a VLAN interface

sudo ifconfig eth1.101 down

Command to set static IP for a VLAN interface (for example 10.10.10.2)

sudo ifconfig eth1.101 10.10.10.2/24

Command to set route to a VLAN interface

sudo route add -net 172.0.0.0.0 netmask 240.0.0.0 gw 10.10.10.1 eth1.101

Command to map different COS values (0-7) from a VLAN interface to a single COS value (5)

sudo vconfig set_egress_map eth1.101 0 5
sudo vconfig set_egress_map eth1.101 1 5
sudo vconfig set_egress_map eth1.101 2 5
sudo vconfig set_egress_map eth1.101 3 5
sudo vconfig set_egress_map eth1.101 4 5
sudo vconfig set_egress_map eth1.101 5 5
sudo vconfig set_egress_map eth1.101 6 5
sudo vconfig set_egress_map eth1.101 7 5

Location of the file that contains network interface details

/etc/network/interfaces

Location of the config file for DHCP deamon

/etc/dhcp/dhcpd.conf

Location of the config file for DHCP server

/etc/default/isc-dhcp-server

Location of the file that contains VLAN details

/proc/net/vlan/eth1.101