How to use the ip command instead of ifconfig

Did you know that in 2009 it was announced that the ifconfig Linux command would be deprecated?

On mostly Linux distribution the ifconfig command has been deprecated and will be definitely replaced by ip command.
What are de differences between ifconfig and ip?

Let’s try to summarize them:

Show network devices

ip addr show
ip link show

Enable a network interface

ifconfig eth0 up
ip link set eth0 up

A network interface can be disabled with:

ifconfig eth0 down
ip link set eth0 down

Setting IP address

The simple version:

ifconfig eth0
ip address add dev eth0

The complete version with network mask or the broadcast address:

ifconfig eth0 netmask broadcast
ip addr add broadcast dev eth0

Delete an IP address

This feature is available only with ip:

ip addr del dev eth0

Add alias interface

ifconfig eth0:1
ip addr add dev eth0 label eth0:1

Add an entry in the ARP table.

arp -i eth0 -s 00:11:22:33:44:55
ip neigh add lladdr 00:11:22:33:44:55 nud permanent dev eth0

Set ARP resolution off on one device

ifconfig -arp eth0
ip link set dev eth0 arp off

Show the routing table

ip route show

With ip you can query on which interface a packet to a given IP address would be routed to:

ip route get

Changing the routing table

Add a route:

route add -net dev eth3
ip route add dev eth3

Removing entries from a routing table:

route del -net dev eth3
ip route del dev eth3

Add a gateway:

route add -net gw
ip route add via

A most complete list of deprecated commands and them replacement is available on this post of Doug Vitale:

Deprecated Linux networking commands and their replacements


Deprecated Linux networking commands and their replacements
Deprecated Linux networking commands and their replacements
Deprecated Linux networking commands and their replacements

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.