How to temporarily add or remove an IP address from an interface in Linux

Home > Search > How-to
  by

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

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments