Linux Route Command Guide & Examples
The route command is used to display and manipulate the IP routing table. Here are some common examples of the route command:
- Display the current IP routing table:
route -n
- Add a static route.
sudo route add -net 目标网络地址 netmask 子网掩码 网关地址
- Remove a static route.
sudo route del -net 目标网络地址 netmask 子网掩码 网关地址
- Set up a default gateway:
sudo route add default gw 网关地址
- Remove the default gateway.
sudo route del default gw 网关地址
- Display help information:
route --help
Please note that using sudo permissions is required when using the route command, otherwise it may not be successfully executed.