0

Morning folks !

I have multiple public ips set on my server, and I would need to use one in particular for the outgoing traffic, as it has been whitelisted on some services I need to reach.

I have the following in my /etc/netplan/netcfg.yaml file :

  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      dhcp4: true
      dhcp4-overrides:
        route-metric: 200
  vlans:
    enp2s0.1013:
      id: 1013
      link: enp2s0
      mtu: 1400
      addresses:
        - x.x.x.12/29
        - x.x.x.13/29
      routes:
        - on-link: true
          to: 0.0.0.0/0
          via: x.x.x.1
          metric: 100

What should I change to make the .13 IP the one used for outgoing traffic ? I saw some examples but none that was looking similar to my config file so I'm a bit lost.

Anton Danilov
  • 5,082
  • 2
  • 13
  • 23

1 Answers1

0

I've looked up into the netplan source code. You can specify the source address for a particular route with the "from" attribute. In your case it will be look something like:

...
routes:
  - on-link: true
    to: 0.0.0.0/0
    via: x.x.x.1
    from: x.x.x.13
    metric: 100
Anton Danilov
  • 5,082
  • 2
  • 13
  • 23