3 commands you need to know about Linux networking
Tags: linux, beginners, tutorial, cloud
Published: 2022-11-18 13:51:36

> check the article here [3 commands you need to know about Linux networking](https://www.howtouselinux.com/post/understanding-ip-command-in-linux)

IP command is one of the most important and frequently used commands in Linux. In this blog post, we will discuss what IP command is, and how to use it effectively. IP command is used to display or manipulate the network interface parameters. It can be used to view network information about your network interfaces, configure them, and more.

### Useful IP Commands in Linux

Here are some useful IP commands:

-   ip addr: This command will display/add/delete IP addresses in Linux
-   ip link: This command will display/add/delete network interfaces in Linux.
-   ip route: This command will display/add/delete routes in Linux.

Let’s take a look at these IP commands.

### Check network interface info with ip link show command in Linux

The IP link show command can be used to display information about your network interfaces. This command will display all of the network interfaces on your systems. The command output will include the  [MAC address](https://www.howtouselinux.com/post/linux-command-get-mac-address-in-linux), [MTU size](https://www.howtouselinux.com/post/check-mtu-size-in-linux), status, etc. Here is an example of the output of this command:

For example:



```
root@localhost:~# ip link show  
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT  
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000  
link/ether 08:00:27:a4:4c:fc brd ff:ff:ff:ff:ff:ff  
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000  
link/ether 44:94:fc:82:ec:6e brd ff:ff:ff:ff:ff:ff
```

As you can see from the output above, there are three interfaces on this system: lo, eth0, and wlan0.

-   The lo interface is the loopback interface, which is used for local communication on the system.
-   The eth0 interface is the Ethernet interface, which is used to connect to a network.
-   The wlan0 interface is the wireless interface, which is used to connect to a wireless network.

You can use the ip link show command to view information about any of these interfaces.

To view information about a specific interface, you can use the following syntax:

ip link show dev <interface name>

For example, to view information about the eth0 interface, you would use the following command:
```
root@localhost:~# ip link show dev eth0

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000  
link/ether 08:00:27:a4:4c:fc br
```
### Configure network interface with ip link set command in Linux

To configure your network interfaces in Linux, you can use the ip link set command. This command is used to set various parameters of a network interface. For example, you can use this command to enable or disable a network interface.

The main reason to disable a network interface is to prevent it from being used. This can be useful in a number of situations. For example, if you are troubleshooting your network, you may want to disable an interface to see if that fixes the problem.

Or, if you are connected to a network that you don’t want to use, you may want to disable the interface to prevent your computer from using it.

To disable a network interface, you can use the following command:

**ip link set eth0 down**

This command will disable the eth0 interface. If you want to enable the interface, you can use the following command:

**ip link set eth0 up**

You can also use the ip link set command to change the MAC address of a network interface. To do this, you can use the following command:

ip link set eth0 address 00:11:22:33:44:55

This command will change the MAC address of the eth0 interface to 00:11:22:33:44:55.

### Check IP address with ip addr show command in Linux

The ip addr show command can be used to  [display IP information](https://www.howtouselinux.com/post/check-ip-address-in-linux)  about your network addresses. This command will display all of the IP addresses on your system. Here is an example of the output of this command:

For example:

```
root@localhost:~# ip addr show  
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN  
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
inet 127.0.0.1/8 scope host lo  
valid_lft forever preferred_lft forever  
inet6 ::1/128 scope host  
valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000  
link/ether 08:00:27:a4:4c:fc brd ff:ff:ff:ff:ff:ff  
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0  
valid_lft forever preferred_lft forever  
inet6 fe80::a00:27ff:fea4:4cfc/64 scope link  
valid_lft forever preferred_lft forever

3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000  
link/ether 44:94:fc:82:ec:6e brd ff:ff:ff:ff:ff:ff
```


As you can see from the output above, there are three interfaces on this system: lo, eth0, and wlan0.

### Change IP Address with IP addr add/del Command in Linux

The ip addr add command is used to  [add an IP address](https://www.howtouselinux.com/post/linux-command-change-ip-address-in-linux)  to a network interface. For example, if you want to add the IP address 10.0.0.1/24 to the eth0 interface, you can use the following command:

ip addr add 10.0.0.1/24 dev eth0

The ip addr del command is used to delete an IP address from a network interface. For example, if you want to delete the IP address 10.0.0.1/24 from the eth0 interface, you can use the following command:

ip addr del 10.0.0.1/24 dev eth0

The ip addr flush command is used to flush the IP addresses from a network interface. This command will delete all of the IP addresses from a network interface. For example, if you want to flush the IP addresses from the eth0 interface, you can use the following command:

ip addr flush dev eth0


### Conclusion

In this article, we have covered the IP command in Linux. We have explained what the IP command is and how it can be used to configure network interfaces and routes. We have also provided a list of some useful IP commands.

From  [understanding ip command in Linux](https://www.howtouselinux.com/post/understanding-ip-command-in-linux)