简介:
ip 命令类似于 ifconfig,但更加强大,有route、arp、netstat等功能,旨在替换它们!(对比见下图)
一、查看它们属于哪些包
1.查看 IP
rpm -qf `which ip` iproute-2.6.32-31.el6.1.x86_64 #实际还包括 arpd 、 ss 、ifcfg、 tc 、nstat 等命令
2.查看 ifconfig
rpm -qf `which ifconfig` net-tools-1.60-110.el6_2.x86_64 #实际上还包括 netstat 、hostname 、route 、arp 等命令
二、5个常用的 ip 命令
1.给网卡增加、删除 ip
ip addr add 192.168.100.9 dev eth0 ip addr del 192.168.100.9 dev eth0
2.查看ip、路由、网卡 信息
ip addr show # 等于ip a / ip addr ip route show #等于 ip r / ip route ip link ip -s link #更加详细
3.起停网卡
ip link set eth0 up ip link set eth0 down
4.增加、删除静态路由
ip route add 192.168.12.0/24 via 192.168.12.1 dev eth0 ip route del 192.168.12.0/24
5.增加默认路由
ip route add default via 192.168.12.1
结束语:
以上命令只是暂时更改,如果要永久生效,还要写更改相应的配置文件
其实很好记。 ip link 针对的是二层 ip route 对应的是三层
参考资料: