Show pageOld revisionsBacklinksAdd to bookExport to MarkdownBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Linux IP/Network how-to ====== ===== Setup a secondary IP on the same physical device ===== 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: <code bash> 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 </code> * Add a secondary IP on the physical device: <code bash> ip addr add 172.16.134.5/23 dev ens33 label ens33:1 </code> * Check the configuration previously added: <code bash> 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 </code> <WRAP center round important 60%> The line containing the new alias name (''%%ens33:1%%'') must include ''%%secondary%%''! </WRAP> * Delete alias from physical device: <code bash> ip addr del 172.16.134.5/23 dev ens33 label ens33:1 </code> ==== To make it permanent ==== To make it permanent, you do it using ''nmcli'' or just add the following lines into ''ifcfg-ens33'' file: <code bash> IPADDR1=172.16.134.5 PREFIX1=23 </code> The ''nmcli'' command: <code bash> nmcli con mod ens192 +ipv4.addresses "172.16.134.5/23" </code> When done, just restart network: ''systemctl restart network'' ===== Remove (delete) an IP address ===== <code bash> ip addr del 172.16.134.5/23 dev ens33 </code> ===== Setup with VLAN tag ===== 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 | ==== Add a vlan tag to an interface ==== Here we add the VLAN tag ''90'' to the interface, ''ens2f0.90'': <code bash> ip link add link ens2f0 name ens2f0.90 type vlan id 90 </code> ==== Add the IP to the linked device ==== <code bash> ip addr add 192.168.1.54/24 dev ens2f0.90 </code> ==== Add a default gateway ==== <code bash> ip route add default via 192.168.1.1 dev ens2f0.90 </code> ip.txt Last modified: 2019/10/24 07:12by admin