ip

This is an old revision of the document!


Linux IP/Network how-to

This how-to shows the procedure to setup an alias on a physical ethernet device. We are going to use 'ip' command line tool. We are going to setup following parameters:

What Value
Physical device:ens33
Default gateway:172.16.135.254
Netmask/Prefix :255.255.254.0
Alias interface:ens33:1

Attention: The alias network IP only is routed, if you use the same Netmask/Prefix!

  • Get current IP configuration:
ip a list dev ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:02:13:85 brd ff:ff:ff:ff:ff:ff
    inet 172.16.134.3/23 brd 172.16.135.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe02:1385/64 scope link
       valid_lft forever preferred_lft forever
  • Add a secondary IP on the physical device:
ip addr add 172.16.134.5/23 dev ens33 label ens33:1
  • Check the configuration previously added:
ip a list dev ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:02:13:85 brd ff:ff:ff:ff:ff:ff
    inet 172.16.134.3/23 brd 172.16.135.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet 172.16.134.5/23 scope global secondary ens33:1
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe02:1385/64 scope link
       valid_lft forever preferred_lft forever

The line containing the new alias name (ens33:1) must include secondary!

  • Delete alias from physical device:
ip addr del 172.16.134.5/23 dev ens33 label ens33:1
ip addr del 172.16.134.5/23 dev ens33

In some circumstances, a VLAN tagging is necessary. In this chapter, I show how-to setup such an interface.

What Value
Physical device : ens2f0
IP address : 192.168.1.54
Netmask/Prefix : 255.255.255.0 / 24
VLAN interface : ens2f0.90

Here we add the VLAN tag 90 to the interface, ens2f0.90:

ip link add link ens2f0 name ens2f0.90 type vlan id 90
ip addr add 192.168.1.54/24 dev ens2f0.90
ip route add default via 192.168.1.1 dev ens2f0.90
  • ip.1554828131.txt.gz
  • Last modified: 2019/04/09 18:42
  • by admin