net-tools 和 iproute2 笔记221103

net-tools起源于BSD的TCP/IP工具箱,后来成为老版本Linux内核中配置网络功能的工具,但Linux社区自2001年起已对其停止维护。最新的Linux发行版,如Arch Linux、CentOS 7/8、RHEL 7及以后版本等已经完全抛弃net-tools,默认仅支持iproute2。

iproute2的出现旨在从功能上取代net-tools。

net-tools通过procfs(/proc)和ioctl系统调用去访问和改变内核网络配置,iproute2则通过netlink套接字接口与内核通讯。iproute2的用户接口比net-tools更加直观,如各种网络资源(如link、IP地址、路由和隧道等)均使用合适的对象抽象去定义,使得用户可使用一致的语法去管理不同的对象。

ifconfig、hostname、mii-tool、netstat、route等,均属于net-tools工具
iproute2的命令都以ip开头, 如ip address , ip route , ip link

在这里插入图片描述

在这里插入图片描述

iproute2net-toolsNote
ip link showifconfig -aDisplay all interfaces
ip link set down/up eth0ifconfig eth0 up/downEnable (UP)/Disable (DOWN) Network Interface
ip addr add 192.168.0.10/24 dev eth0ifconfig eth0 192.168.0.10/24Assign an IPv4 address to Network Interface
ip addr del 192.168.0.10/24 dev eth0ifconfig eth0 0Delete an IPv4 address from Network Interface
ip addr show dev eth0ifconfig eth0Display IPv4 address of a Network Interface
ip -6 addr add fe80::f0b7:57ff:fe2f:5f0d/64 dev eth1ifconfig eth1 inet6 add fe80::f0b7:57ff:fe2f:5f0d/64Assign an IPv6 address to a Network Interface
ip -6 addr show dev eth0ifconfig eth0Display IPv6 address of a Network Interface
ip link set dev eth0 address 02:42:20:d2:28:36ifconfig eth0 hw ether 02:42:20:d2:28:36Change the MAC Address of a Network Interface
ip route showroute -nShow IP Routing Table
ip route add default via 192.168.0.1 dev eth0route add default gw 192.168.0.1 eth0Add a Default Route
ip route replace default via 192.168.0.1 dev enp0s3route del default gw 192.168.0.1 enp0s3Delete a Default Route
ip route add 10.24.32.0/24 via 192.168.0.1 dev enp0s3route add -net 10.24.32.0/24 gw 192.168.0.1 dev enp0s3Add a Static Route
ip route del 192.168.10.0/24route del -net 192.168.10.0/24Delete a Static Route
ssnetstatDisplay socket - listening tcp/udp
arp -an ip neighDisplay ARP Table
bridgebrctlManage bridge addresses and devices
iproute2net-toolsNote
ip link showifconfig -a显示所有的外设
ip link set down/up eth0ifconfig eth0 up/down启用/禁用网络接口
ip addr add 192.168.0.10/24 dev eth0ifconfig eth0 192.168.0.10/24为网络接口分配IPv4地址
ip addr del 192.168.0.10/24 dev eth0ifconfig eth0 0从网络接口删除IPv4地址
ip addr show dev eth0ifconfig eth0显示网络接口的IPv4地址
ip -6 addr add fe80::f0b7:57ff:fe2f:5f0d/64 dev eth1ifconfig eth1 inet6 add fe80::f0b7:57ff:fe2f:5f0d/64为网络接口分配IPv6地址
ip -6 addr show dev eth0ifconfig eth0显示网络接口的IPv6地址
ip link set dev eth0 address 02:42:20:d2:28:36ifconfig eth0 hw ether 02:42:20:d2:28:36更改网络接口的MAC地址
ip route showroute -n显示IP路由表
ip route add default via 192.168.0.1 dev eth0route add default gw 192.168.0.1 eth0添加默认的路由
ip route replace default via 192.168.0.1 dev enp0s3route del default gw 192.168.0.1 enp0s3删除默认的路由
ip route add 10.24.32.0/24 via 192.168.0.1 dev enp0s3route add -net 10.24.32.0/24 gw 192.168.0.1 dev enp0s3新增一个静态的路由
ip route del 192.168.10.0/24route del -net 192.168.10.0/24删除静态的路由
ssnetstat显示 socket – listening tcp/udp
arp -anip neigh显示ARP表
bridgebrctl管理网桥地址和设备
用iproute2查看网关地址

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:~# ip r
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(8)
ip-route - routing table management
iproute2 (6.0.0-1)

用 net-tools查看网关地址 : route -n
route -n

例如

root@ds10:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.82.10.12     0.0.0.0         UG    0      0        0 ens33
10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 ens33
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kfepiza

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值