Is it possible to override subnet settings per machine/interface?

I have two subnets, both of which have valid gateways configured in the Subnets configuration area:
10.51.0.0/24 with gateway 10.51.0.1
192.168.243.128/25 with gateway 192.168.243.129

Many servers will either be connected to one or the other but some will need connectivity to both.
In those cases, I need to be able to make sure the default gateway is kept/set for the 10.51.0.0/24 subnet and no default gateway set for the 192.168.243.128/25 subnet.
So the end result for the machine would be something like:
eno1: 10.51.0.89/24 with default gateway 10.51.0.1
eno3: 192.168.243.160/25 with no default gateway

I am struggling to work out how this is possible in MAAS - is it?

You can. In the documentation is a little scattered.

Using the set-default-gateway API:
maas user interface set-default-gateway machine-id interface-id

How get the id of the interface:
maas user interfaces read machine-id | jq '.[] | [.name, .id] | join(" -- ")'

Example:

[root@machine]$ maas user machine read abcdefg | jq ".default_gateways"
{
  "ipv4": {
    "gateway_ip": "10.0.0.1",
    "link_id": 15438
  },
  "ipv6": {
    "gateway_ip": null,
    "link_id": null
  }
}

[root@machine]$ maas user interfaces read abcdefg | jq '.[] | select(.name | contains("bond0")) | .id'
1234

[root@machine]$ maas user interface set-default-gateway abcdefg 1234

[root@machine]$ maas user machine read abcdefg | jq ".default_gateways"
{
  "ipv4": {
    "gateway_ip": "192.168.0.1",
    "link_id": 15438
  },
  "ipv6": {
    "gateway_ip": null,
    "link_id": null
  }
}

A little note from the doc of the API (search clear_default_gateways):

This will transition the logic of identifing the best gateway to MAAS. This logic is determined based the following criteria:

  1. Managed subnets over unmanaged subnets.
  2. Bond interfaces over physical interfaces.
  3. Machine’s boot interface over all other interfaces except bonds.
  4. Physical interfaces over VLAN interfaces.
  5. Sticky IP links over user reserved IP links.
  6. User reserved IP links over auto IP links.
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.