1.4 KiB
1.4 KiB
router table
| device | eth | ip |
|---|---|---|
| PC1 | eth1 | 10.5.0.2/24 |
| PC2 | eth1 | 10.5.1.2/24 |
| router1 | eth1 | 10.5.0.1/24 |
| router2 | eth1 | 10.5.1.1/24 |
主要工具:ip
ip 是 IPRoute2 工具集中最常用的命令,能够管理和配置 IP 地址、路由、链路等多种网络参数。与旧版的 ifconfig 和 route 命令相比,ip 更加灵活和强大。
ip 命令的常见用法
-
查看网络接口:
ip link show显示所有网络接口及其状态,类似于
ifconfig。 -
启用或禁用网络接口:
sudo ip link set dev eth0 up # 启用接口 sudo ip link set dev eth0 down # 禁用接口 -
添加/删除 IP 地址:
sudo ip address add 192.168.1.10/24 dev eth0 # 为 eth0 接口添加 IP 地址 sudo ip address del 192.168.1.10/24 dev eth0 # 从 eth0 接口删除 IP 地址 -
显示路由表:
ip route show显示当前的路由表,类似于
route命令。 -
添加/删除路由:
sudo ip route add 192.168.1.0/24 via 192.168.1.1 # 添加路由条目 sudo ip route del 192.168.1.0/24 # 删除路由条目 -
查看 ARP 表:
ip neighbor show显示 ARP 表,类似于
arp -a。