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
Table of Contents
ifconfig will print out all the network interfaces and their information including the IP address and netmask.
A typical output is like this:
eth0 Link encap:Ethernet HWaddr 00:26:22:A1:25:0F inet addr:18.104.22.168 Bcast:22.214.171.124 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:
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
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 126.96.36.199 dev eth0 proto static
You can find your own hostname by running:
The long hostname can be found by:
For changing your hostname: Changing Hostname of Fedora Linux.