260119-Ubuntu20-04(netplan apply)系统启动后直接加载固定路由-系统启动固定路由

作用:(Ubuntu20.04系统启动后直接加载固定路由)让本机一启动就把 192.168.0.2 / .4 / .102 / .104 / .106 这 5 个地址“当成跟自己同一链路(link)上的邻居”,无需网关即可直达,ARP 解析后直接发包。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
network:
ethernets:
eno1:
dhcp4: no
addresses: [192.168.0.100/24]
routes:
- to: default
via: 192.168.0.1
scope: link
metric: 10
enp1s0:
dhcp4: no
addresses: [192.168.0.110/24]
dhcp4-overrides:
use-routes: false # 拒绝 DHCP 下发的默认路由
routes: # 你的 5 条主机路由
- to: 192.168.0.2/32
scope: link
- to: 192.168.0.4/32
scope: link
- to: 192.168.0.102/32
scope: link
- to: 192.168.0.104/32
scope: link
- to: 192.168.0.106/32
scope: link
version: 2
wifis: {}