I'm building an edge router using Ubuntu Server 18.04.03 LTS and need to configure the routing table to define the default route as being the upstream / WAN interface, which gets its IP address and (presumably) the gateway / nexthop address dynamically from the ISP's DHCP server.

A Netplan configuration would seem be the obvious means to do this, and preferable because the configuration would be persistent, but because (according to the Netplan Reference page), the route block's "via" directive (which specifies the gateway IP) is required, Netplan simply isn't up to the task: One obviously can't specify a dynamically assigned IP address even if specifying an outbound interface is straightforward. Netplan also provides no obvious means to assure that the route received via DHCP is the default route. It's as if the Netplan developers simply ignored the entire concept of a default route, which is quite well documented.

This seems to leave ip route, which while volatile and requiring scripting and scheduling to persist nevertheless offers the opportunity to specify a default route by interface alone, so lamentably absent from Netplan.

So, the question is how best to accomplish this. Can one hack around Netplan's inadequacies, and is the ip route approach viable (albeit via scripting and an associated systemd .service) and perhaps even more robust?

Many thanks for any thoughts.

  • I'm afraid I don't understand your question. If you are getting your WAN IP address assigned via DHCP, then you should also be getting your default route assigned via DHCP. Why is that not working in your case? – slangasek Sep 24 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.