Blog:http://www.simlinux.com
Many system administrators still use Ifconfig, route, ARP, netstat command combinations to manage and debug network configurations, which are provided by the Net-tools package, but in the arch Linux, centos7/ RHEL7 and other distributions have been replaced with Iproute2 Net-toolsiproute2 is another network configuration tool to replace the function of net-tools;
Net-tools Access and modification of the network configuration is done through PROCFS (/PROC) and IOCTL system calls, while Iproute2 communicates with the kernel via a netlink socket; Importantly, IPROUTE2 development has been very good:
https://www.kernel.org/pub/linux/utils/net/iproute2/
Here is the comparison of the use of Net-tools and Iproute2:
List all network interfaces (including network cards that are not activated)
Use net-tools:$ ifconfig-a using iproute2:$ IP link Show
650) this.width=650; "class=" Alignnone size-full wp-image-356 "src=" http://www.simlinux.com/wp-content/uploads/2014 /09/iplink.jpg "alt=" Iplink "width=" 640 "height=" 183 "style=" Border:0px;height:auto; "/> Activate and deactivate network cards
Use net-tools:$ sudo ifconfig eth1 up$ sudo ifconfig eth1 down using iproute2:$ sudo IP link set down eth1$ sudo IP link set up E Th1
Configuring IPV4 Addresses
Use net-tools:$ sudo ifconfig eth1 10.0.0.1/24 using iproute2:$ sudo ip addr add 10.0.0.1/24 dev eth1 using Net-tools configuration multi ip:$ sudo ifco Nfig eth0:1 192.168.10.10 netmask 255.255.255.0 up$ sudo ifconfig eth0:2 192.168.10.15 netmask 255.255.255.0 up use Iproute2 with Place multi ip:$ sudo IP addr add 10.0.0.1/24 broadcast 10.0.0.255 dev eth1$ sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 Dev E th1$ sudo ip addr add 10.0.0.3/24 broadcast 10.0.0.255 dev eth1 view eth0 IP address $sudo ip Addr List dev eth0
Remove the IPV4 address from the NIC
Use net-tools:$ sudo ifconfig eth1 0 using iproute2:$ sudo ip addr del 10.0.0.1/24 dev eth1
View the IPV4 address configured on the NIC
Use the net-tools:$ ifconfig eth1 to use iproute2:$ IP addr Show Dev eth1 if the NIC is bound to multiple IPs, IPROUTE2 can display all the addresses, and Net-tools can only display a
650) this.width=650; "class=" Alignnone size-full wp-image-357 "src=" http://www.simlinux.com/wp-content/uploads/2014 /09/ipaddr.jpg "alt=" ipaddr "width=" 640 "height=" 154 "style=" border:0px;height:auto; "/> Config IPv6 address
Using net-tools:$ sudo ifconfig eth1 inet6 add 2002:0db5:0:f102::1/64$ sudo ifconfig eth1 inet6 add 2003:0db5:0:f102::1/64 use IP route2:$ sudo ip-6 addr add 2002:0db5:0:f102::1/64 dev eth1$ sudo ip-6 addr add 2003:0db5:0:f102::1/64 dev eth1
View the IPV6 address configured on the NIC
Using the net-tools:$ ifconfig eth1 using iproute2:$ ip-6 addr Show Dev eth1
650) this.width=650; "class=" Alignnone size-full wp-image-358 "src=" http://www.simlinux.com/wp-content/uploads/2014 /09/ipv6.jpg "alt=" IPv6 "width=" 640 "height=" 374 "style=" Border:0px;height:auto; "/> Remove the IPV6 address on the NIC
Use net-tools:$ sudo ifconfig eth1 inet6 del 2002:0db5:0:f102::1/64 using iproute2:$ sudo ip-6 addr del 2002:0db5:0:f102::1/64 D EV eth1
Change the NIC MAC address
Use net-tools:$ sudo ifconfig eth1 hw ether 08:00:27:75:2a:66 use iproute2:$ sudo ip link set dev eth1 address 08:00:27:75:2a:6 7
View the routing table
Use Net-tools: $route-n$ netstat-rn use iproute2:$ IP route show
650) this.width=650; "class=" Alignnone size-full wp-image-359 "src=" http://www.simlinux.com/wp-content/uploads/2014 /09/route.jpg "alt=" route "width=" 640 "height=" 312 "style=" Border:0px;height:auto; "/> Add modify default route
Use net-tools:$ sudo route add default GW 192.168.1.2 eth0$ sudo route del default GW 192.168.1.1 eth0 use iproute2:$ sudo ip r Oute add default via 192.168.1.2 dev eth0$ sudo ip route replace default via 192.168.1.2 Dev eth0
Adding and removing static routes
Use net-tools:$ sudo route add default GW 192.168.1.2 eth0$ sudo route del default GW 192.168.1.1 eth0 use iproute2:$ sudo ip r Oute add default via 192.168.1.2 dev eth0$ sudo ip route replace default via 192.168.1.2 Dev eth0
View Socket Statistics
Use net-tools:$ netstat$ netstat-l using iproute2:$ ss$ ss-l
650) this.width=650; "class=" Alignnone size-full wp-image-360 "src=" http://www.simlinux.com/wp-content/uploads/2014 /09/socket.jpg "alt=" socket "width=" 640 "height=" 333 "style=" border:0px;height:auto; "/> View arp Table
Use net-tools:$ arp-an with iproute2:$ IP neigh
650) this.width=650; "class=" Alignnone size-full wp-image-361 "src=" http://www.simlinux.com/wp-content/uploads/2014 /09/arp.jpg "alt=" ARP "width=" 546 "height=" 293 "style=" Border:0px;height:auto; "/> Add and remove static ARP
Use net-tools:$ sudo arp-s 192.168.1.100 00:0c:29:c0:5a:ef$ sudo arp-d 192.168.1.100 using iproute2:$ sudo ip neigh add 192.168 .1.100 lladdr 00:0c:29:c0:5a:ef dev eth0$ sudo ip neigh del 192.168.1.100 dev eth0
Add, remove, and view multicast addresses
using net-tools:$ sudo ipmaddr add 33:44:00:00:00:01 dev eth0$ sudo ipmaddr del 33:44:00:00:00:01 dev eth0$ ipmaddr show dev eth0$ Netstat -g using iproute2:$ sudo ip maddr add 33:44:00:00:00:01 dev eth0$ sudo ip maddr del 33:44:00:00:00:01 dev eth0$ ip maddr list dev eth0
Reference Documentation:
Iproute2 HowTo http://www.policyrouting.org/iproute2.doc.html
Iproute2 Mans http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2/
Rtnetlink http://www.man7.org/linux/man-pages/man7/rtnetlink.7.html
NetLink http://www.man7.org/linux/man-pages/man7/netlink.7.html
This article is from the "Geekwolf" blog, make sure to keep this source http://linuxgeek.blog.51cto.com/6014609/1549191
Linux TCP/IP network management tools: Net-tools VS iproute2