smalllinux

The Linux ‘ip’ Command in Networking

One way to examine your network configuration in Linux is to use the “ip” command.  I have attached a cheat sheet from Red Hat.

By itself, it will show its options:

Screenshot from 2018 10 26 07 35 26 

So much going on here, and I find the help and man pages to be light on clarity and examples.

So let’s explore.

Let’s do the ‘ip addr’ command to display the addresses currently set on the machine (you could also have just typed ‘ip a’):

Screenshot from 2018 10 26 07 41 06 

Because I have IPv6 running in my network, I have a lot more information than if I did not.  Nonetheless, we still see IPv4 information as well.  

You can see that I am connected wia my Wireless adapter, and the my wored Ethernet is not connected.  You can also see I must be running VirtualBox on this computer.

Before we dig any deeper, the new naming scheme is shown – look at my #2 interface: ‘enp3s0’. 

Here is how it works:  It is referred to as the “Predictable Network Interface” naming.  It has been used on systemd-based Linux systems for some time now.  The interface name depends on the physical location of the hardware.  The “en” simply means “Ethernet”, just like “eth” did in the prior naming schema “eth0”.  The “p” is the bus or port number of the Ethernet NIC, and the “s” is the slot number (being that a card may have multiple slots).  So “enp3s0” means Ethernet, Port/Bus 3, Slot 0.

I am going to plug my wired Ethernet in to see the difference:

Screenshot from 2018 10 26 07 50 02

Now we see the ‘enp3s0’ interface has come up and has addresses as well.

What if you just wanted to view the IPv4 addresses?  Use the ‘ip -4 addr’ command:

Screenshot from 2018 10 26 10 28 47

For just IPv6, replace the ‘-4’ with ‘-6’.

A couple of other definitions:

  • BROADCAST the interface supports broadcasting
  • MULTICAST the interface supports multicasting
  • UP the network interface is enabled
  • LOWER_UP is a physical layer link flag (the layer below the network layer, where IP is generally located). LOWER_UP indicates that an Ethernet cable was plugged in and that the device is connected to the network.  LOWER_UP differs from UP, which additionally requires the network interface to be enabled.

To just show a particular interface information, use the command ‘ip addr show enp3s0’:

Screenshot from 2018 10 26 11 27 04

Let’s say you wanted to troubleshoot at Layer 2. 

You can view L2 information as follows with the ‘ip link’ command:

Screenshot from 2018 10 26 12 06 46

You can display the L2 statistics with the ‘ip -s link show enp3s0’ command to look at the Ethernet interface:

Screenshot from 2018 10 26 10 32 17

There are a number of other things you can do with the ‘ip’ command.  Let’s look at some.

You can view the IP neighbors (think Neighbor Discovery in IPv6 and ARP in IPv4) with the ‘ip neigh’ command: 

Screenshot from 2018 10 26 10 24 56

You may want to see what Multicast Group addresses your interface belongs to.  Do this with the ‘ip maddress show enp3s0’ (this is particularly important for IPv6 networking):

Screenshot from 2018 10 26 11 29 29

You can view the current routing – what network is on which interface – with the ‘ip route’ command:

;Screenshot from 2018 10 26 10 26 44

What else have you found helpfull with this command?

I hope you find this article and its content helpful.  Comments are welcomed below.  If you would like to see more articles like this, please support us by clicking the patron link where you will receive free bonus access to courses and more, or simply buying us a cup of coffee!, and all comments are welcome!

 

 

 

Leave a Comment

Contact Us Here


Please verify.
Validation complete :)
Validation failed :(
 
Your contact request has been received. We usually respond within an hour, but please be patient. We will get back to you very soon.
Scroll to Top