How to use Linux ip addr command

Configurare noua (How To)

Situatie

Add an IP address to an Interface

For example:  add the IP address “192.168. 7.22” to the ‘wlp6s0’ interface. To add this Ip address, execute the command as follows: sudo ip addr add 192.168.

As a Linux user, you may have used the ip addr command at some point. But do you know what this command does and how it can be useful?

ip addr command is used to check the IP address of a network interface

The ip addr command is a basic networking utility used to view, add, and delete IP addresses on network interfaces. By default, the ip addr command displays information about all network interfaces on a Linux system. This includes information such as the name of each interface, its IP addresses, the netmask, broadcast address, and the status of the interface (up or down).

With this command, I can easily view information about my system’s current networking configuration and make adjustments as needed. This makes ip addr an invaluable tool for efficiently resolving any network-related issues.

Here’s an example of the ip addr command and its output:

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:16:3e:18:3a:76 brd ff:ff:ff:ff:ff:ff
inet 10.254.222.37/23 brd 10.254.223.255 scope global dynamic eth0
valid_lft 74268sec preferred_lft 74268sec

This output shows information about two network interfaces on the system: lo (the loopback interface) and eth0 (a network interface card).

For each interface, the output shows:

  • The name of the interface (e.g. lo, eth0)
  • The status of the interface (e.g. UP)
  • The MAC address (e.g. 00:11:22:33:44:55)
  • The IP addresses assigned to the interface (e.g. 127.0.0.1, 192.168.0.100)
  • The netmask (e.g. /8, /24)
  • The broadcast address (e.g. brd 192.168.0.255)

This information can be useful when troubleshooting network connectivity issues, or when configuring network interfaces on a Linux system.

If you want to view information about a specific interface, you can specify the interface name as an argument to the ip addr command. For example, to view information about the eth0 interface, you can use the following command:

ip addr show eth0

This will display information about the eth0 interface, including its IP addresses, netmask, broadcast address, and status. The ip addr add command is used to assign an IP address to a network interface and make it available on the network.

To use this command, you must first specify the IP address that you want to assign, followed by the name of the interface you are working with. For example, to assign the IP address 192.168.1.20, you would type: ip addr add 192.168.1.20/32 dev eth0.

If you need to delete an IP address from a network interface, you can use ip addr del command. This command can be useful for removing old or unused IP addresses and for reorganizing your network configuration.

To use this command, you must first specify the IP address that you want to delete, followed by the name of the interface you are working with. For example, to delete the IP address 192.168.1.20, you would type: ip addr del 192.168.1.20 dev eth0.

ip addr command displays information about all the network interfaces on a Linux system. This includes the IP address, netmask, broadcast address, and more. The ip addr command is useful for troubleshooting networking issues.

Solutie

Tip solutie

Permanent
Etichetare:

Voteaza

(11 din 25 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?