Ubuntu – How to find the network IP address, netmask, and gateway info

infonetworking

I'm trying to make my IP address static as I hear it fixes slow browsing issues.

When I click on connection information under the networking menu of the gray taskbar, it tells me about the IP address, subnet mask, and DNS, but nothing about the gateway.

I would like to know if there's a terminal command to find the information.

Best Answer

I have this command as an alias for "ipconfig" (up to 14.04):

nmcli dev list iface eth0 | grep IP4

An example listing is:

IP4-SETTINGS.ADDRESS:                   192.168.1.110
IP4-SETTINGS.PREFIX:                    24 (255.255.255.0)
IP4-SETTINGS.GATEWAY:                   192.168.1.1
IP4-DNS1.DNS:                           208.67.222.222
IP4-DNS2.DNS:                           208.67.220.220

If eth0 doesn't work, you may need to use eth1, eth2, ... depending on your configuration.

EDIT: 2/8/16

Note that this only works in versions before v15.04 (or possibly before v14.10; I have v14.04). For newer versions, you can use this:

 nmcli dev show eth0
Related Question