Bootstrap FreeKB - Linux Fundamentals - Temporarily add or remove an IP address from an interface
Linux Fundamentals - Temporarily add or remove an IP address from an interface

Updated:   |  Linux Fundamentals articles

The ip address add option can be used to manually assign an IP address and subnet mask or prefix to an interface. 

[root@server1 ~]# ip address add 192.168.1.102/24 dev eth0
[root@server1 ~]# ip address add 192.168.1.102/255.255.255.0 dev eth0

 

You would also want to add the broadcast address to the interface. This would only temporarily assign an IP address, subnet mask or prefix, and broadcast address to an interface. Once the network service is restarted, or the interface is brought down and then brought up, or if the operating system is reboot, the interface would use the settings in /etc/sysconfig/network-scripts/ifcfg-xxxxxxxxxx or /etc/network/interfaces.

[root@server1 ~]# ip address add broadcast 192.168.1.255 dev eth0

 

The ip address del option can be used to manually remove an IP address and subnet mask or prefix address to an interface.

[root@server1 ~]# ip address del 192.168.1.102/24 dev eth0
[root@server1 ~]# ip address del 192.168.1.102/255.255.255.0 dev eth0

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 014b59 in the box below so that we can be sure you are a human.