Finding out Linux Network Configuration Information

Posted on In Linux

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:143.89.135.175  Bcast:143.89.135.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
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)
Interrupt:30

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
UP LOOPBACK RUNNING  MTU:16436  Metric:1
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:

nameserver 8.8.8.8

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

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.1.8   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

Gateway

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 143.89.135.254 dev eth0  proto static

Host name

You can find your own hostname by running:

hostname

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 *