当前位置:网站首页>[to]12 common IP commands in the iproute installation package
[to]12 common IP commands in the iproute installation package
2022-06-13 05:53:00 【morpheusWB】
This tutorial will discuss ip Ordered 12 The most commonly used method in , Let's get started .
Check the network card, such as IP Address , Subnet and other network information , Use ip addr show command :
[[email protected]]$ ip addr show or [[email protected]]$ ip a s
This will display the relevant network information of all available network cards in the system , But if you want to check the information of a network card , The order is :
[[email protected]]$ ip addr show enp0s3
here enp0s3 It's the name of the network card .

IP-addr-show-commant-output
Use ip Command to enable a disabled network card :
[[email protected]]$ sudo ip link set enp0s3 up
To disable the network card, use down trigger :
[[email protected]]$ sudo ip link set enp0s3 down
To assign... To the network card IP Address , We use the following command :
[[email protected]]$ sudo ip addr add 192.168.0.50/255.255.255.0 dev enp0s3
You can also use ip Command to set the broadcast address . The default is that no broadcast address is set , The command to set the broadcast address is :
[[email protected]]$ sudo ip addr add broadcast 192.168.0.255 dev enp0s3
We can also use the following command according to IP Address set the standard broadcast address :
[[email protected]]$ sudo ip addr add 192.168.0.10/24 brd + dev enp0s3
As the example above shows , We can use brd Instead of broadcast To set the broadcast address .
If you want to delete a from your network card IP, Use as follows ip command :
[[email protected]]$ sudo ip addr del 192.168.0.10/24 dev enp0s3
Add alias , That is, add more than one network card IP, Execute the following command :
[[email protected]]$ sudo ip addr add 192.168.0.20/24 dev enp0s3 label enp0s3:1
ip-command-add-alias-linux
Viewing the routing information will show us the routing path of the packet to the destination . To view network routing information , Execute the following command :
[[email protected]]$ ip route show

ip-route-command-output
In the output above , We can see the routing information of packets on all network cards . We can also get specific IP Routing information for , The method is :
[[email protected]]$ sudo ip route get 192.168.0.1
We can also use IP To modify the default routing of packets . The method is to use ip route command :
[[email protected]]$ sudo ip route add default via 192.168.0.150/24
In this way, all network packets pass through 192.168.0.150 To forward , Instead of the previous default route . To modify the default route of a network card , perform :
[[email protected]]$ sudo ip route add 172.16.32.32 via 192.168.0.150/24 dev enp0s3
To delete the previously set default route , Open the terminal and run :
[[email protected]]$ sudo ip route del 192.168.0.150/24
Be careful : The default route modified by the above method is only temporarily valid , All changes will be lost after the system restarts . To permanently modify the route , Need to modify or create route-enp0s3 file . Add the following line :
[[email protected]]$ sudo vi /etc/sysconfig/network-scripts/route-enp0s3172.16.32.32 via 192.168.0.150/24 dev enp0s3
Save and exit the file .
If you are using based on Ubuntu or debian Operating system of , Then the file to be modified is /etc/network/interfaces, Then add ip route add 172.16.32.32 via 192.168.0.150/24 dev enp0s3 This line goes to the end of the file .
ARP, It's address resolution protocol Address Resolution Protocol Abbreviation , Is used to IP Address translation to physical address ( That is to say MAC Address ). be-all IP Corresponding to it MAC Details are stored in one table , This table is called ARP cache .
To see ARP Records in cache , That is, the device connected to the LAN MAC Address , Use the following ip command :
[[email protected]]$ ip neigh

ip-neigh-command-linux
Delete ARP The recorded command is :
[[email protected]]$ sudo ip neigh del 192.168.0.106 dev enp0s3
If you want to go ARP Add a new record to the cache , The order is :
[[email protected]]$ sudo ip neigh add 192.168.0.150 lladdr 33:1g:75:37:r3:84 dev enp0s3 nud perm
here nud It means “neghbour state”( Network neighborhood status ), Its value can be :
- perm - It is permanently valid and can only be deleted by the administrator
- noarp - Record valid , But it is allowed to be deleted after the life cycle expires
- stale - Record valid , But it may have expired
- reachable - Record valid , But it will be invalid after timeout
adopt ip The command can also view network statistics , For example, the number of bytes and messages transmitted on all network cards , Number of erroneous or discarded messages, etc . Use ip -s link Order to see :
[[email protected]]$ ip -s link

ip-s-command-linux
If you want to see an option that is not in the above example , Then you can check the help . In fact, you can ask for help with any order . To list ip All options of the command , perform :
[[email protected]]$ ip help
边栏推荐
- Leetcode Timo attack - simple
- 3. Postman easy to use
- Leetcode- longest palindrome string - simple
- Leetcode guessing numbers game - simple
- Sentinel series integrates Nacos and realizes dynamic flow control
- Leetcode- reverse vowels in string - simple
- Tongweb customs clearance guidelines
- Working principle of sentinel series (concept)
- Calculate the number of days between two times (supports cross month and cross year)
- Quartz database storage
猜你喜欢
随机推荐
2021.9.30学习日志-postman
Power of leetcode-4 - simple
中断处理过程
NVIDIA Jetson Nano/Xavier NX 扩容教程
Leetcode- string addition - simple
Cross compile HelloWorld with cmake
2020 personal annual summary
Django uses redis to store sessions starting from 0
Leetcode- longest palindrome string - simple
How to view tongweb logs correctly?
MySQL fuzzy query and sorting by matching degree
2 first experience of drools
OpenGL馬賽克(八)
Integration of sentinel series Nacos to realize rule synchronization and persistence
OpenGL Mosaic (8)
Tongweb adapts to openrasp
Unity game optimization (version 2) learning record 7
Service architecture diagram of Nacos series
Unity游戏优化(第2版)学习记录7
Unity game optimization [Second Edition] learning record 6










