66 lines
1.3 KiB
Markdown
66 lines
1.3 KiB
Markdown
|
# IPRoute2 说明
|
|||
|
|
|||
|
## Link 信息和设置
|
|||
|
|
|||
|
```bash
|
|||
|
# 显示链路
|
|||
|
ip link show
|
|||
|
# 仅显示 up 的链路
|
|||
|
ip link show up
|
|||
|
# 添加链路
|
|||
|
ip link add name <link name> type <bridge|bond|dummy|veth|vlan|vxlan>
|
|||
|
# 启动/停止链路
|
|||
|
ip link set <bridge name> <up/down>
|
|||
|
# 绑定
|
|||
|
ip link set <netif> master <bridge name>
|
|||
|
# 解绑
|
|||
|
ip link set <netif> nomaster
|
|||
|
# 删除链路
|
|||
|
ip link del name <bridge name> [type bridge]
|
|||
|
```
|
|||
|
|
|||
|
## IP 地址信息和设置
|
|||
|
|
|||
|
```bash
|
|||
|
# 显示地址(或ifconfig)
|
|||
|
ip addr show
|
|||
|
# 仅显示 up 设备的地址
|
|||
|
ip addr show up
|
|||
|
# 设定 IP 地址
|
|||
|
ip addr add <ip addr> dev <netif>
|
|||
|
# 删除 IP 地址
|
|||
|
ip addr del <ip addr> dev <netif>
|
|||
|
```
|
|||
|
|
|||
|
## 路由信息和设置
|
|||
|
|
|||
|
```bash
|
|||
|
# 显示路由(route -n)
|
|||
|
ip route show
|
|||
|
# 添加路由
|
|||
|
ip route add <ip addr> via <gateway>
|
|||
|
ip route add <ip addr> dev <netif>
|
|||
|
# 删除接口路由
|
|||
|
ip route del default dev <netif>
|
|||
|
# 查看本地静态路由
|
|||
|
ip route show table local
|
|||
|
# 查看直连路由
|
|||
|
ip route show table main
|
|||
|
```
|
|||
|
|
|||
|
## ARP
|
|||
|
|
|||
|
```bash
|
|||
|
# 显示 arp 表(ping 192.168.95.50,如果主机在同一局域网内,直接加到 arp 表)
|
|||
|
ip neigh show
|
|||
|
# 删除 arp 条目,条目仍然存在状态为 stale,下次通信需要确认
|
|||
|
ip neigh delete 192.168.95.50 dev <netif>
|
|||
|
```
|
|||
|
|
|||
|
## 其他
|
|||
|
|
|||
|
```bash
|
|||
|
# 显示缺省规则
|
|||
|
ip rule show
|
|||
|
```
|