net-tools起源于BSD的TCP/IP工具箱,后来成为老版本Linux内核中配置网络功能的工具,但Linux社区自2001年起已对其停止维护。最新的Linux发行版,如Arch Linux、CentOS 7/8、RHEL 7及以后版本等已经完全抛弃net-tools,默认仅支持iproute2。 iproute2的出现旨在从功能上取代net-tools。
iproute2 最常用的3个命令
ip a 等效ip address show : 查看ip地址ip r 等效ip route show : 查看网关地址ip link set 网络接口名 up 和 ip link set 网络接口名 down : 启用/禁用网络接口
查看ip地址 : ip addr 等效 ip address show 等效 ip a s 等同 ip a
ip address show ip address sho ip address sh ip address s ip address ip addres ip addre ip addr ip add ip ad ip a ip a s ip a sh ip a sho ip a show ip ad show ip add show ip addr show ip addre show ip addres show ip address show
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
root@ds10:~
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:7e:5a:68 brd ff:ff:ff:ff:ff:ff
inet 10.10.12.25/8 brd 10.255.255.255 scope global ens33
valid_lft forever preferred_lft forever
inet 10.12.25.1/8 scope global secondary ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe7e:5a68/64 scope link
valid_lft forever preferred_lft forever
查看网关地址 : ip r 等效 ip route 等效 ip route show
ip route show 可写为:
- ip route show
- ip route sho
- ip route sh
- ip route s
- ip route
- ip rout
- ip rou
- ip ro
- ip r
- ip r s
- ip r sh
- ip r sho
- ip r show
- ip ro show
- ip rou show
- ip rout show
- ip route show
ip route sh
ip route s
ip route
ip rout
ip rou
ip ro
ip r
ip r s
ip r sh
ip r sho
ip r show
ip ro show
ip rou show
ip rout show
ip route show
例如:
root@ds10:~
default via 10.82.10.12 dev ens33 onlink
10.0.0.0/8 dev ens33 proto kernel scope link src 10.10.12.25
169.254.0.0/16 dev ens33 scope link metric 1000
第一行, default via 后面的就是网关, via是:经由,通过,路过的意思
启用停用网络接口 : ip link set 网络接口名 up/down
ip link set ens33 up 可写为:
ip link set ens33 down 可写为:
ip 后面可接 link , address , route , rule , neigh , tunnel , maddr , mroute
link对象支持的命令:set、show。
addr对象支持的命令:add、del、flush、show。
route对象支持的命令:list、flush、get、add、del、change、append、replace、monitor。
rule对象支持的命令:list、add、del、flush。
neigh对象支持的命令:add、del、change、replace、show、flush。
tunnel对象支持的命令:add、change、del、show。
maddr支持的命令:add、del。
mroute支持的命令:show
|