network

Linux – Removing all IP information from an interface

If an interface has already had IP addresses assigned to it, and all of the addresses need to be removed (along with their routes), there is one handy command to accomplish all of these tasks. ip address flush takes an interface name as an argument. Let’s look at the output of ip address show just before and just after removing all IPs.

[root@logistic]# ip address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:80:c8:f8:4a:51 brd ff:ff:ff:ff:ff:ff
inet 192.168.99.35/24 brd 192.168.99.255 scope global eth0
inet 192.168.99.37/24 brd 192.168.99.255 scope global secondary eth0:0
[root@logistic]# ip address flush
Flush requires arguments.
[root@logistic]# ip address flush dev eth0
[root@logistic]# ip address show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:80:c8:f8:4a:51 brd ff:ff:ff:ff:ff:ff

Windows – Change IP from command line

Yes, is possibile don’t make lot of click to reconfigure network interfaces under Windows, using “netsh” command like this:

For set up static address and metric 1 gateway:

netsh interface ip set address name=”Local Area Connection” static ip.ip.ip.ip 255.255.255.0 gw.gw.gw.gw 1

For set up static dns:

netsh interface ip set dns “Local Area Connection” static xx.xx.xx.xx
netsh add dns “Local Area Connection” addr=xx.xx.xx.xx index=2

For setup ip by dhcp:

netsh interface ip set address name=”Local Area Connection” source=dhcp
netsh interface ip set dns name=”Local Area Connection” source=dhcp