如何将 16.04lts 基于策略的路由 /etc/network/interfaces 示例转换为 netplan

如何将 16.04lts 基于策略的路由 /etc/network/interfaces 示例转换为 netplan

希望将此 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

相关内容