ip

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ip [2019/02/07 16:34] – created adminip [2019/10/24 07:12] (current) – [Setup a secondary IP on the same physical device] admin
Line 42: Line 42:
        valid_lft forever preferred_lft forever        valid_lft forever preferred_lft forever
 </code> </code>
-**Attention:** The line containing the new alias name (''%%ens33:1%%'') must include ''%%secondary%%''!+ 
 +<WRAP center round important 60%> 
 +The line containing the new alias name (''%%ens33:1%%'') must include ''%%secondary%%''! 
 +</WRAP>
  
   * Delete alias from physical device:   * Delete alias from physical device:
Line 49: Line 52:
 ip addr del 172.16.134.5/23 dev ens33 label ens33:1 ip addr del 172.16.134.5/23 dev ens33 label ens33:1
 </code> </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.1549553664.txt.gz
  • Last modified: 2019/02/07 16:34
  • by admin