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: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.

Similar Posts

  • | |

    How to Query Transaction By ID in Hyperledger Fabric 2.0

    Querying transaction content out from a blockchain network is a common practice used by common scenarios like exploring the blockchain history or verifying the blockchain transaction content from a known ID. In Hyperledger Fabric, the transaction can be queried using a special system chaincode QSCC (Query System Chaincode) which is for ledger and other Fabric-related…

  • Several Vim Tips (in Chinese)

    窗口模式操作 CTRL-W CTRL-S 将当前窗口分割为两窗口 CTRL-W CTRL-W 切换窗口 CTRL-W j 切换到下一窗口 CTRL-W k 切换到上一窗口 CTRL-W CTRL-R 将窗口的位置轮换 CTRL-W CTRL-_ 将当前窗口最小化 CTRL-W CTRL-= 将所有窗口变为等大 搜索和替换 /word 搜索word 搜索之后按回车高亮显示,n 下一个 p 上一个 :%s/模式/替换成的内容/gc % 全局选项,如果没有开启则只在当前行进行替换 g 表示 全局替换,如果没有g选项则只替换每行出现的第一个单词 c 表示需要确认 Esc替换按键 ESC键在键盘的左上角,按起来很不方便,而在VIM中ESC经常用到,其实有一个同样作用的组合按键:CTRL-[,这两个按起来手基本不用做大的动作,方便多了。 块操作 使用visual可视模式 v 进入可视模式,移动光标可进行选择 CTRL-Q 或 CTRL-V 进入列式模式,可进行块操作,选定的是一个矩形块。如果使用behave mswin CTRL-V可能映射成为past Read more: How to convert between…

  • Finding Which Package Provides a File in Ubuntu Linux and Linux Mint

    How to find which package provides a file in Debian based releases, such as Linux Mint, Ubuntu? You can use `dpkg`: $ dpkg -S /path/to/the/file -S or –search is the option to make dpkg do a “search”: -S, –search filename-search-pattern… Search for a filename from installed packages. To search which package provides a command file…

  • |

    Synchronizing home directories

    Any good tools to synchronize home directories on Linux boxes? Many have several PC/laptops and consequently many home directories. There is home directory synchronizing problem. unison is a good tool to do this: http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#rshmeth http://www.watzmann.net/blog/2009/02/my-homedirs-in-unison.html http://www.cis.upenn.edu/~bcpierce/papers/index.shtml#File%20Synchronization Useful script: $ unison -batch -ui text ./ /mnt/homebak/zma/ In text user interface, synchronizing two directories in batch mode…

One Comment

Leave a Reply

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