Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the ip command in linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the ip command in linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Install ip

The ip command is included in the iproute2util package, which may already be installed in your Linux distribution. If not, you can install it from the repository of the distribution.

Comparison between ifconfig and ip

Both the ip and ifconfig commands can be used to configure network interfaces, but they do things differently. Next, for comparison, I will use them to perform some common tasks.

Check the network port and IP address

If you want to see the host's IP address or network interface information, the ifconfig (without any parameters) command provides a good summary.

Ifconfig eth0: flags=4099 mtu 1500 ether bc:ee:7b:5e:7d:d8 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6:: 1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 41 bytes 5551 (KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 41 bytes 5551 (5.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlan0: flags=4163 mtu 1500 inet 10.1.1.6 netmask 255.255.255.224 broadcast 10.1.31 inet6 fdb4:f58e:49f:4900:d46d:146b:b16:7212 prefixlen 64 scopeid 0x0 inet6 fe80::8eb3:4bc0:7cbb:59e8 prefixlen 64 Scopeid 0x20 ether 08:71:90:81:1e:b5 txqueuelen 1000 (Ethernet) RX packets 569459 bytes 779147444 (743.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 302882 bytes 38131213 (36.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

The new ip command provides similar results, but the command is ip address show, or abbreviated to ip a:

$ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 65536 scope host valid_lft forever preferred_lft forever2: eth0: mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether bc:ee:7b:5e:7d:d8 Brd ff:ff:ff:ff:ff:ff3: wlan0: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 08:71:90:81:1e:b5 brd ff:ff:ff:ff:ff:ff inet 10.1.1.6/27 brd 10.1.1.31 scope global dynamic wlan0 valid_lft 83490sec preferred_lft 83490sec inet6 fdb4:f58e:49f:4900:d46d:146b:b16:7212/64 scope global noprefixroute dynamic valid_lft 6909sec preferred_lft 3309sec Inet6 fe80::8eb3:4bc0:7cbb:59e8/64 scope link valid_lft forever preferred_lft forever add IP address

Use the ifconfig command to add the IP address command as follows:

$ifconfig eth0 add 192.9.203.21

Ip is similar to:

$ip address add 192.9.203.21 dev eth0

The subcommands in ip can be shortened, so the following command is also valid:

$ip addr add 192.9.203.21 dev eth0

You can be even shorter:

$ip an add 192.9.203.21 dev eth0 removes an IP address

Adding an IP address is the opposite of deleting an IP address.

Using ifconfig, the command is:

$ifconfig eth0 del 192.9.203.21

The syntax of the ip command is:

$ip a del 192.9.203.21 dev eth0 enables or disables multicast

Use the ifconfig interface to enable or disable multicast multicast:

# ifconfig eth0 multicast

For ip, use the set subcommand and device (dev) with a Boolean and multicast option:

# ip link set dev eth0 multicast on enables or disables the network

Every system administrator is familiar with the "close, then open" technique to solve the problem. For network interfaces, the network is turned on or off.

The ifconfig command uses the up or down keyword to implement:

# ifconfig eth0 up

Or you can use a special command:

# ifup eth0

The ip command uses the set subcommand to set the network to the up or down state:

# ip link set eth0 up enables or disables address resolution (ARP)

With ifconfig, you can enable it by declaring it

# ifconfig eth0 arp

Using ip, you can set the arp property to on or off:

# ip link set dev eth0 arp on Thank you for reading this article carefully. I hope the article "how to use ip commands in linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report