![如何将 16.04lts 基于策略的路由 /etc/network/interfaces 示例转换为 netplan](https://linux22.com/image/1151583/%E5%A6%82%E4%BD%95%E5%B0%86%2016.04lts%20%E5%9F%BA%E4%BA%8E%E7%AD%96%E7%95%A5%E7%9A%84%E8%B7%AF%E7%94%B1%20%2Fetc%2Fnetwork%2Finterfaces%20%E7%A4%BA%E4%BE%8B%E8%BD%AC%E6%8D%A2%E4%B8%BA%20netplan.png)
希望将此 16.04lts 基于策略的路由 /etc/network/interfaces 示例更新为 netplan
#
# Being able to reply to anyone that contact this host requires
# Policy-Base routing setup that also requires a that a routing
# table be defined in /etc/iproute2/rt_tables. ie append lines:
#
# #
# # Source Policy-Base Route Table
# 200 Policy-Based
#
# Update enp4s0f0 to the interface of your installation,
# set output of "sudo lshw -short -class network"
auto enp4s0f0
iface enp4s0f0 inet static
address 172.19.X.Y
netmask 255.255.255.0
# By default use a NAT service
gateway 172.19.X.254
# except when
# communicating to another UW IPv4 hosts
up ip route add 10.0.0.0/8 via 172.19.X.1
up ip route add 172.16.0.0/12 via 172.19.X.1
# or replying to someone who communicated directly to this host
up ip route add default via 172.19.X.1 table Policy-Based
post-up ip rule add from 172.19.X.Y lookup Policy-Based
# remember to clean up if the interface is taken down
down ip route del 10.0.0.0/8 via 172.19.X.1
down ip route del 172.16.0.0/12 via 172.19.X.1
down ip rule del from 172.19.X.Y
down ip route flush table Policy-Based