In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use ip instead of ifconfig under Linux, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.
If you use Linux long enough, then you naturally know how some tools come and go. The 2009 mailing list of Debian developers announced the abandonment of the lack of maintenance of the net-tools toolkit. Net-tools is still used by some people today. In fact, you can still use the ifconfig command to manage your network configuration in Ubuntu 14.10.
However, in some cases (for example, Ubuntu Docker containers), the net-tools toolkit will not be installed by default, which means that ifconfig cannot be used. Nonetheless, net-tools can be installed using a software repository.
Sudo apt-get install net-tools
Since net-tools is no longer maintained, we strongly recommend that you replace ifconfig with the ip command. More importantly, ip performs better than ifconfig.
What's interesting is that ip is not just a substitute for ifconfig. There are many structural differences between the two commands. Even so, they are all used for the same purpose. The ip command actually completes all of the following transactions.
List which network interfaces are configured on the system
View the status of the network interface
Configure network interfaces (including local loops and Ethernet)
Enable or disable network interfaces
Manage default static rout
IP tunnel configuration
Configure ARP or NDISC cache entries
Next, let's try using ip instead of ifconfig as mentioned above. I'll give some simple examples of how to use the ip command. To correctly use and understand that these commands require root permissions, you can use su to switch to the root user or use sudo. Because these commands will change the network information of your machine. Use it carefully.
Note: the address used in the demonstration is for demonstration only, and when it comes to your computer, it will vary depending on your network and hardware.
Next, let's go!
Collect information
One of the things most people learn to do with ifconfig is to look at the IP address assigned on the network interface. Enter ifconfig directly without any parameters and enter to see it. So that's all we need to do with ip.
Ip a
This command will list information about all network interfaces.
You say you only want to see IPv4-related information, so you can do this.
Ip-4a
You also say that you want to see information about a specific network interface, then use the following command to view the wireless card connection information.
Ip a show wlan0
You can even locate more specific information, and if you want to see IPv4 information on wlan0, you can do this.
Ip-4 a show wlan0
You can also list the running network interfaces in this way.
Ip link ls up modifies and configures network interfaces
Next, let's learn about the core function of the ip command-modifying the configuration network interface. Suppose you want to assign a specific address to * Ethernet network cards (eth0). In ifconfig, it looks like this.
Ifconfig eth0 192.168.1.101
So this is what happens with the ip command.
Ip an add 192.168.1.101/255.255.255.0 dev eth0
Keep it short. You can do that.
Ip an add 192.168.1.101/24 dev eth0
Obviously, in that case, you need to know the subnet mask of the address you want to arrange.
In the same way, you can delete the address of a network card in this way.
Ip a del 192.168.1.101/24 dev eth0
If you want to simply clear all addresses on all interfaces, that's all you need.
Ip-s-s a f to 192.168.1.0 take 24
The ip command, on the other hand, activates / disables network interfaces.
Disable eth0
Ip link set dev eth0 down
Activate eth0
Ip link set dev eth0 up
Using the ip command, we can also add / remove default gateways, like this.
Ip route add default via 192.168.1.254
If you want more details about the network interface, you can edit the transmission queue, set a low value for the slow interface and a higher value for the fast one. Then you need to do it like this.
Ip link set txqueuelen 10000 dev eth0
This command sets up a long transmission queue. You should set a value that best suits your hardware.
You can also use the ip command to set * transmission units for the network interface.
Ip link set mtu 9000 dev eth0
Once you have made the change, you can use ip a list eth0 to check if it works.
Manage routing tabl
In fact, you can also use the ip command to manage the system routing table. This is a very useful feature of the ip command. And you should use it carefully.
View all routing tables.
Ip r
The output will look like the following figure.
Now all the traffic you want to route passes through the 192.168.1.254 gateway of the eth0 network card, so do this.
Ip route add 192.168.1.0/24 dev eth0
Delete this route.
Ip route del 192.168.1.0 dev eth0 above is all the contents of this article entitled "how to use ip instead of ifconfig under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.