Linux配置静态路由
程序员文章站
2022-03-01 17:01:56
...
1. Ubuntu16
# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet static
...
up route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.0.0.4 dev ens33
$ sudo /etc/init.d/networking restart
2. Ubuntu20
$ cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
eno1:
...
routes:
- to: 192.168.1.0/24
via: 10.0.0.4
$ sudo netplan apply
$ ip route show
...
192.168.1.0/24 via 10.0.0.4 dev eno1 proto static metric 100
...
上一篇: LeetCode 13 罗马数字转整数
下一篇: Swift 基础