3

I want to use loopback alias IP for all outcome IP traffic from my Ubuntu server directed to some subnets.

In /etc/network/interfaces that can be done by post-up statement with something like:

/sbin/ip route add 1.2.3.0/24 via 10.255.255.254 src 10.255.254.1

Is there a way to do that with Netplan and Networkd?

0

For information about configuring source-based policy routing in netplan, see: https://netplan.io/examples#source-routing

  • This is not source-based policy routing, it's destination base pbr with src-ip replacing. I want It to simulate some cisco-like logic with loopback address as source IP for outgoing packets. – user1227888 Jun 1 '18 at 10:04
0

The 'from' property of routes does the equivalent of src in ip route. I think your route would be:

  routes:
     - to: 1.2.3.4/24
       via: 10.255.255.254
       from: 10.255.254.1

Be aware that:

  • Because of LP: #1767849, this doesn't work at all until you get netplan 0.40. As of 2018-09-27, this hasn't been released for Bionic yet, only the still in-development Cosmic.
  • even with that fix, it doesn't work reliably for IPv6, because of systemd bug #5882. (You can work around this by running 'netplan apply' late in boot.)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.