41

In Windows I can use ipconfig /all to display all the info about my connection: IP address, gateway, subnet mask, DNS ...

In terminal, using ifconfig does not and only supplies limited info. I can use Network Manager, but it would be useful to know the command line alternative.

What is the command line to supply the same info ipconfig /all supplies in Windows?

wjandrea
  • 14,543
pst007x
  • 8,240

5 Answers5

30

The only thing missing from ifconfig are the gateway and DNS servers.

15.04 and newer

First, get the device name you're using. To get a list of devices and their status, type:

nmcli dev status

I got eth0.

To get the DNS and Gateway info, type:

nmcli dev show eth0

The output lists some device parameters including some IP4.DNS[x] entries, which show the DNS servers, and a IP4.ADDRESS[1] line which lists the IP.

On 16.04 and newer versions, there is an IP4.GATEWAY line which is self explanatory. Up to 15.10, the gateway was shown on the address line after gw =.

Up to and including 14.10

You can get these with nm-tool (in Ubuntu versions prior to 15.04) which BTW is the command line version of network manager.

To run it just type in a terminal:

nm-tool

If you're using Ubuntu 15.04 or newer the nm-tool has been replaced by the nmcli command which is different. Check the section called "15.04 and newer" above this one in this case.

wjandrea
  • 14,543
devius
  • 1,249
16

ipconfig shows things like hostname, DNS servers, those are in a different place than just IP addresses in linux, so you will need a couple of commands.

hostname
ifconfig -a
cat /etc/resolv.conf

That shows what I want to see 99% of the time, but ipconfig /all also shows things like DHCP lease times and servers.

cat /var/lib/dhcp/dhclient.leases
4

Was looking at few links and finally found the below working:

nmcli dev list | grep IP4

The output is:

IP4.ADDRESS[1]:                         ip = 195.168.0.107/24, gw = 192.168.0.1
IP4.DNS[1]:                             192.168.0.1
IP4.DOMAIN[1]:                          local

Also all the network related details can be found using putting simply:

nmcli dev list eth0

Danibix
  • 2,195
  • nmcli dev list | grep IP4 means take the output of nmcli dev list and then feed it (using the pipe |) into grep and keep lines that contain regex pattern IP4. – CoderGuy123 Jul 28 '16 at 13:25
  • nmcli dev list | grep IP4 doesn't work on Ubuntu 16.04 – Danibix Jan 18 '18 at 10:48
3

Here's the simplest equivalent i could find for ubuntu 17.04

nmcli device show

Sample output (ip4 stuff only):

nmcli device show | grep IP4
IP4.ADDRESS[1]:                         172.27.35.55/24
IP4.GATEWAY:                            172.27.35.1
IP4.ROUTE[1]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.DNS[1]:                             172.27.35.1
IP4.ADDRESS[1]:                         127.0.0.1/8
IP4.GATEWAY:
2

I needed to work out what DHCP server I was connected to via Ubuntu 14.04 so I used this command:

nmcli dev list|grep DHCP4

as this is what I wanted only from the original command "nmcli dev list"

DHCP4.OPTION[1]: expiry = 1464073312

DHCP4.OPTION[2]:  domain_name = [omitted_proper_details]

DHCP4.OPTION[3]:  broadcast_address = 10.1.45.255

DHCP4.OPTION[4]:  dhcp_message_type = 5

DHCP4.OPTION[5]:  dhcp_lease_time = 432000

DHCP4.OPTION[6]:  ip_address = 10.1.45.132

DHCP4.OPTION[7]:  subnet_mask = 255.255.255.0

DHCP4.OPTION[8]:  dhcp_renewal_time = 216000

DHCP4.OPTION[9]:  routers = 10.1.45.1

DHCP4.OPTION[10]: domain_name_servers = 10.1.26.10 10.1.20.10

DHCP4.OPTION[11]: dhcp_rebinding_time = 378000

DHCP4.OPTION[12]: network_number = 10.1.45.0

DHCP4.OPTION[13]: dhcp_server_identifier = 10.1.20.10

Gives me all the DCHP/DNS details I need, just like ipconfig /all