Linux OSBN/Ubuntuusers Planet UNIX XING / LinkedIn / Amazon

Obsolete tools: nslookup & ifconfig

nslookup and ifconfig are two well-known tools for configuration the network of Unix/Linux hosts and checking whether DNS is working properly.

ifconfig was part of the 4.2BSD distribution in 1983 for the first time and quickly became the standard tool for network configuration – even commerical Unices like Solaris or HP-UX integrated the utility.

Some Linux distributions don’t use ifconfig anymore (e.g. ArchLinux) – other distributions (e.g. SuSE/SLES and Fedora) are advising that this tool will be missing someday:

# man ifconfig
       WARNING: Ifconfig is obsolete on system with Linux  kernel  newer  than
       2.0.  On  this  system  you  should  use ip. See the ip manual page for
       This program is obsolete! For replacement check ip addr and ip link.
       For statistics use ip -s link.

Solaris 11 introduced a new command for network configuration: ipadm (thanks for the hint, Prometheus!).

ip works beginning with Linux 2.2. It is more modern and also includes amongst others the functionality of the route and arp utilities.

Here are some of the most used ifconfig/route commands and their ip pendants:

Task ifconfig/route ip
Show all NICs
ip addr show
Show specific NIC
ifconfig eth0
ip addr show eth0
Disable NIC
ifconfig eth0 down
ip link set eth0 down
Enable NIC
ifconfig eth0 up
ip link set eth0 up
Assign IP
ifconfig eth0 [IP] netmask [NM]
ip addr [IP]/[CIDR] dev eth0
Show routing table
netstat -r
ip route
Set standard route
route add default gw [IP] eth0
ip route add default via [IP]

Of course ip has a lot of more features – just a few of them:

  • Enable/disable MTU and Promiscuous Mode
  • Configure Multicasting and VLANs
  • ARP table maintenance

Similar to ifconfig – nslookup is also obsolete for a long time. There are two replacement tools that are able to do more: host and dig. The open DNS server bind advises not to use nslookup (source):

Due to its arcane user interface and frequently inconsistent
behavior, we do not recommend the use of nslookup.
Use dig instead.

Here are some commonly used nslookup commands and their dig pendants.

Task nslookup dig
Forward lookup
dig +short
Reverse lookup
nslookup [IP]
dig -x [IP]
dig +short -x [IP]
Use specific DNS server
nslookup [DNS]
dig @[DNS]
dig @[DNS] +short
Ask for MX records
nslookup -query=mx
dig MX
dig +short MX
Specific timeout
nslookup -timeout=42
dig +time=42
dig +short +time=42

The option +short ist really useful if you just want to get a IP or a hostname. By default, dig also prints some additional information like the IP and response time of the used DNS sever:

; <<>> DiG 9.9.2-P2 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33883
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 16384
;                     IN      A

;; ANSWER SECTION:              300     IN      A              300     IN      A              300     IN      A

;; Query time: 66 msec
;; WHEN: Sun Apr  7 17:18:22 2013
;; MSG SIZE  rcvd: 86

# dig +short

It’s also a good idea to have a look at the manpage of dig because it offers a lot of additional features in addition to the mentioned functions. 🙂

Sharing is caring

Leave a Reply

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