Finding out Linux Network Configuration Information

There is various network configuration information in Linux and lots tools can be used to find out those configuration information. Finding out these network information in Fedora Linux as the example will be introduced.

IP address, MAC address and netmask

ifconfig will print out all the network interfaces and their information including the IP address and netmask.

$ ifconfig

A typical output is like this:

eth0      Link encap:Ethernet  HWaddr 00:26:22:A1:25:0F
inet addr:  Bcast:  Mask:
RX packets:305973 errors:0 dropped:0 overruns:0 frame:0
TX packets:337971 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:196287324 (187.1 MiB)  TX bytes:134890044 (128.6 MiB)

lo        Link encap:Local Loopback
inet addr:  Mask:
RX packets:274 errors:0 dropped:0 overruns:0 frame:0
TX packets:274 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:37244 (36.3 KiB)  TX bytes:37244 (36.3 KiB)

eth0 is the network interface. lo is the loopback device.

The IP address is shown in inet addr field.

DNS server, hosts file and DNS look up order

The DNS server for Linux to contact is stored in /etc/resolve.conf. The DNS server(s) can be listed by:

$ cat /etc/resolve.conf

A line like this specifies the DNS server:


The hosts file for Linux is stored in /etc/hosts. The first two lines ( and ::1) which map the localhost name shouldn’t be changed since localhost is used for interprocess communication.   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6   mysite.mydomain mysite

The order of DNS look up is defined in /etc/nsswitch.conf. Whether the hosts file should be looked up first can be defined. The line in /etc/nsswitch.conf for DNS look up order is:

hosts:      files mdns4_minimal [NOTFOUND=return] dns


The gateway can be find out by looking at the rules in route table:

$ ip route show

A line like this defines the gateway:

default via dev eth0  proto static

Host name

You can find your own hostname by running:


The long hostname can be found by:

hostname --long

For changing your hostname: Changing Hostname of Fedora Linux.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

One comment:

Leave a Reply

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