Linux ip Command: 7 Practical Usage Examples

https://www.profitableratecpm.com/f4ffsdxe?key=39b1ebce72f3758345b2155c98e6709c

Have you ever wondered what Linux IP command could do for you? Maybe you simply enter the Linux terminal work or network management. Let me guide you through a few basic examples of the IP command at work.

IP control is a CLI tool to manage network devices, interfaces, tunnels and routing. You can both display and manipulate these elements of your network with the IP command, by modifying at least the way the device you use sees these elements.

Keep in mind that none of the changes you make with the IP command according to these examples is permanent. This makes the command pleasant in that if you make a mistake and destroy the connection of your device to the network, you can simply straighten up. The other side of this room, however, is that everything persistent The changes you try to make will require other orders.

1

See your network interfaces

A current use for IP control is to check which network devices are connected to your Linux system. You can use this information to connect through the network or to modify it, and even more as we will see later.

For example, type the command IP Show link To list all your network interfaces as well as other information potentially useful about them.

The Linux IP link displays the results of the command with red boxes around each interface name.

In my screenshot, you can see that I have three network interfaces. The first, LO, is an internal curling device, a “virtual” network interface used only by the internal processes of my Linux system. The second, WLO1, is the name of the wireless network card in my laptop. The third is an Ethernet interface connected to my laptop via the USB-C port.

2

Disable and activate network interfaces

Let’s say that you have identified a network interface, and now you want to prevent it from working. For any reason, you don’t want data that crosses them. You can use the IP command to deactivate it so that Linux never uses it.

The way you do this is to use the “set link set” command, telling IP to define the device on “Down”. In this example, I use IP to deactivate my wireless interface called WLO1. Your interface can be named the same or something different, so confirm that you name the right interface before using the command.

sudo ip link set wlo1 down
The Linux IP command Set the command without outing, indicating a successful operation.

From now on, I will not be able to use my WLO1 interface, and if I use the IP Show link Command once again, I will see that its status is “below”.

Let’s say, however, I changed my mind and I want to use WLO1 again. Easy.

ip link set wlo1 up
The IP Linux link configuration command without outing, indicating a successful operation.

As before, there is no confirmation message that something has happened, which indicates that I can consider WLO1 in operation.

3

See your local IP address

If you want to know what your IP address is compared to your local network, IP command is one of the easiest ways to do so. This can be useful to identify the devices mapped on your network, access the servers you are self-heberled, and more.

Type IP address Or IP Addr or simply IP A In your terminal, and you will see all the IP addresses on your device organized by network device. However, you probably don’t care that addresses without a loop. Note that they will be displayed with “/ 24” or something similar to indicate its CIDR class.

The Linux IP command has an order with red boxes around the IP address for wireless and wired interfaces.

If you have several physical network interfaces like me, you will see that you have several local IP addresses. When connecting to my device from another, I can choose the connection method (AKA network interface), I prefer by specifying the correct IP address.

IPV4 only

The IP address order on its own outings of a lot of information, including both your IPV4 and IPv6 address. If you only care about IPV4, you can use the -4 indicator to filter the IPV4 addresses.

ip -4 a
The Linux IP -4 command has visible IPV4 Addresses.

As you can see, the release is much easier to analyze the IP address.

IPv6 only

Likewise, if you are only interested in the IPv6 version of your IP address, you can use the -6 indicator.

ip -6 a

4

Add a local IP address

You may sometimes need to create an IP address for your network interface, for example to correct conflicts with other devices, or to facilitate the search for software of a specific address to find your device. You can do it with the IP command.

In my case, I want to give my Ethernet connection the address 192.168.1.130. I first confirmed, of course, that I had no other devices on my local network with this address; I don’t want to cause IP addresses collisions. Then I am ready to define the new address with this order:

sudo ip addr add 192.168.1.130/24 dev enx00e04c68143d
The Linux IP command is used to define a new IP address for a cable interface.

Now when I check my statistics from the Ethernet device with IP Show linkI can see that there are two different addresses.

The release of the Linux IP command displayed two different IP addresses for the same network interface.

5

Delete an IP address

Let’s say after adding my new IP address, I want to delete the old one. Of course, I must first make sure that nothing on my local network is based on this address for important connections and rather uses my new favorite IP address. Then I just place this order:

sudo ip addr del 192.168.1.129/24 dev enx00e04c68143d
The Linux IP command is used to delete an IP address for a wired interface.

From now on, my device will no longer be accessible by the address 192.168.1.129.

6

See and manipulate the neighbors

Let’s say you want to see which other devices on your local network are present and accessible. The IP command allows you to search for “neighbors” which are local active devices which are visible on the network. This can be useful for solving connection problems.

For example, I have a Raspberry Pi and a few other cable devices on my network right now. If I place the order Neighboring IP Or IP Neight or simply IP N I can see their addresses listed.

The Linux IP command is used to display neighboring devices.

There are Mac addresses indicated for each entry, which can help you determine which device is. You will also see at the end of the entry of each device, there is a description of its current status as “accessible” or “expired” or “delay”. This can help you determine the problems, if necessary, with a device to which you are trying to connect.

The IP command also allows me to manually modify the neighboring table. Let’s say that my Raspberry Pi located in 192.168.1.121 for any reason changed the Mac addresses, and I quickly want to update the list of neighbors of my device to avoid connection problems. After obtaining the new MAC address, 3D: 2F: A2: A7: A0: 74, I would change my entry in this way:

sudo ip n change 192.168.1.121 lladdr 3d:2f:a2:a7:a0:74 dev wlo1

To decompose some elements, “N Change” followed by the IP address determines the device I modify, and “Lladdr 3D: 2F: A2: A7: A0: 74” Specifies the new Mac address, while “Dev WLO1” indicates the network interface I use to apply the update.

If you had to follow my example, you want to replace the IP address, the Mac address and the correct labels for your situation. You can also add or delete neighbors via the IP command, but I will not dive into this article.

7

Check the network roads

You can know how the internet traffic of your device is underway on the local network using the “route” object of the IP command. This can be useful if you try to understand connection problems. Simply place this order:

ip route

Or simply:

ip r
The Linux IP R command is used to display network roads.

You can see four total unique routes: the default route around 192.168.1.1, the address of my router, and the itinerary around 192.168.1.0/24, which defines the range for other devices connected to my local network, each to which I can access via my interface “WL01” Wireless “wired or my interface” ENX00E04C68143D “. Everyone also has a” metric “indicating how preferred the route. The lower the metric, the more the road is a priority.


There is much more in the IP command, such as adding and deleting routes, as well as tunnel management. However, these examples are easy and simple steps in the world of Linux networking. Then, I would recommend consulting examples of the NC command in action or learning to define a static IP address in Ubuntu.

Related Articles

Leave a Reply

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

Back to top button