Score:0

How to specify the source IP for outgoing traffic

tn flag

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.

Score:0
cn flag

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
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.