Linux Ubuntu command to show all nic card info

Running Linux Ubuntu

I am looking for the linux command to show all current nic information, including the DNS servers it is using, and the gateway.  

I am trying ifconfig with switches -a , -v, and -s, but I am not getting the DNS or gateway info.

- I am also having an issue where I am able to set the auto eth0 manually in the Ubuntu "network connections" and it holds the settings for awhile, but then I will check on it in a few days and it goes back to automatic settings.... Why is it setting back to automatic?  It could be happening after reboots but it should hold either way, right?
Who is Participating?
0renConnect With a Mentor Commented:
ipconfig /all
is like

ifconfig -a
route -n
cat /etc/resolv.conf
techniousConnect With a Mentor Commented:
It is quite simple. Open a terminal and then:

To display the current configuration simply do the following:
sudo cat /etc/network/interface
To display the current DNS servers:
sudo cat /etc/resolv.conf

Open in new window

As far as the problem with your IP settings changing get WICD.

Install in by opening a terminal and typing:
sudo apt-get install wicd

WICD allows you to have more than one IP profile for a wired NIC and you can set one to be your default, all with the GUI.
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

jkocklerAuthor Commented:
Thanks technious.

Will WICD allow me to have 2 active IP addresses on 1 nic?  I want the nic card to be bound to 2 different ip addresses, using 2 different gateways.  Is this possible?
to see all your nics
ip a l
ifconfig -a

to see ethernet information
ethtool eth0

to view the hardware itself

to see gateway
netstat -r

you can add another ip addreess using ifconfig eth0 add 192.1687.0.1
to route both of them involve configuring the switch.
jkocklerAuthor Commented:
None of those commands are showing me the DNS informatin.  Technious, all of your commands failed completely.
jkocklerAuthor Commented:
Essentially, I am looking for the Linux equivalent to the Windows command:    ipconfig /all
Hope this helps someone out there.

Just open your choice of text editor, copy/paste the text below and don't forget to give it an ".sh" extension when naming the file. For example, just for kicks and giggles I named mine "".


#! /bin/bash
echo Gateway"               "Interface
route -n | awk '/UG/ {printf "%-21s %s\n",$2,$8}'
echo DNS Servers
awk '/nameserver/ {print $2}' /etc/resolv.conf

After you've created the script, navigate to the folder the script is located in and run:


sudo chmod +x

That makes the script executable from the CLI. After that I copied the script into the /usr/local/bin folder. That way you're able to simply run the script from the CLI without having to reference the folder the script was originally located in.

What's really neat is that when I connect to work via an IPSEC VPN, the script catches all of the new settings and gives both gateways in use. Wasn't expecting that without some extra work, but what do I know?
As far as I am aware, WICD only allows a single IP per interface. Just out of curiosity why in the world would you want two IP addresses on one NIC? Isnt that what VLANS are for?
jkocklerAuthor Commented:
Maybe a VLAN would work better in this situation, I do not know.

The reason is, I have 1 asterisk server that is going to be using 2 different internet connections, which are coming in on 2 different gateways, to 2 different firewalls.  The firewalls will then be connected to 1 switch, which asterisk is also connected to.  Since this will all be on the same subnet, I need 2 different private IP addresses on the asterisk nic, because there will be 2 different gateway addresses to send data back to the WAN through.

So and example of the set up is:

IP phone 1 >>>>>ISP Gateway 1 - WAN IP address 75.xx.xx.101>>>Firewall 1 - LAN Address >>>> forward sip packets through port 5060 >> Switch >> to Asterisk server NIC IP >>>>>>> Asterisk NIC sends data to gateway Firewall 1 (LAN Address

IP Phone 2 >>>>>ISP Gateway 2 - WAN IP address 75.xx.xx.111 >>>>> Firewall 2 - LAN Address>>>>>>forward sip packets through port 5060 >> Switch >> to asterisk server NIC IP >>> Asterisk NIC sends data to gateway Firewall 2 (LAN address

So the real reason is because of 2 different LAN gateway addresses.

You may ask, why not just use a dual WAN firewall?.  The reason is, for the price range I am in for firewalls, 2 separate firewalls with a throughput of 90 MBPS, is going to be more cost effective than a Dual WAN firewall, that is able to supply 90 MBPS throughput for each port.

And of course, I have also considered just putting a second NIC card in the asterisk server, but I figured I would see how this would work first.

Could you see a VLAN solution that would work better here?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.