How to configure two segment's IP addresses' gateway use netplan ?

  version: 2
  renderer: networkd
        addresses: [,]
      dhcp4: no
      optional: no

You see I configured two IP segment and

but there I only configured one gateway, gateway4:, is there I need two IP segments' gateway?

if I need two, how can I configured it?

should I configured like this?

gateway4: [,]
  • Given that there are multiple addresses, each with their own gateway, we do not specify gateway4 here, and instead configure individual routes to (everywhere) using the address of the gateway for the subnet. The metric value should be adjusted so the routing happens as expected. Refer section: Using multiple addresses with multiple gateways – Marmayogi Apr 6 at 4:31

"gateway" is shorthand for "default router". You only need to specify one default route to the Internet. If you have multiple routes to the Internet via different routers and you want to use all of them, you will need to configure this using the more detailed routes section.

See https://netplan.io/examples#using-multiple-addresses-with-multiple-gateways for example of how to do this.

  • Can you give an example. – aircraft Apr 7 at 0:22
  • Updated the answer with a link to the examples on the website. – slangasek Apr 8 at 3:35

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.