Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring metric for default gateway is not working with NM renderer #5877

Closed
xiachen-rh opened this issue Nov 15, 2024 · 0 comments · Fixed by #5878
Closed

Configuring metric for default gateway is not working with NM renderer #5877

xiachen-rh opened this issue Nov 15, 2024 · 0 comments · Fixed by #5878
Labels
bug Something isn't working correctly new An issue that still needs triage

Comments

@xiachen-rh
Copy link
Contributor

Similar issue as #5776

Bug report

The following config

            network:
              config:
                - name: enp1s0
                  subnets:
                    - address: 10.0.2.2/24
                      gateway: 10.0.2.1
                      type: static
                      routes:
                        - destination: 0.0.0.0/0
                          gateway: 10.0.2.1
                          metric: 99
                  type: physical
              version: 1

when using NM renderer,
produced a interface config file something like this:

# cat /etc/NetworkManager/system-connections/cloud-init-enp1s0.nmconnection
# Generated by cloud-init. Changes will be lost.

[connection]
id=cloud-init enp1s0
uuid=a41601f3-3acc-5f60-ac5f-9d9011ab7c25
autoconnect-priority=120
type=ethernet
interface-name=enp1s0

[user]
org.freedesktop.NetworkManager.origin=cloud-init

[ethernet]

[ipv4]
method=manual
may-fail=false
address1=10.0.2.2/24
gateway=10.0.2.1
route1=0.0.0.0/0,10.0.2.1

However, the route is not configured with this metric:

# ip route show
default via 10.0.2.1 dev enp1s0 proto static metric 100
10.0.2.0/24 dev enp1s0 proto kernel scope link src 10.0.2.2 metric 100

NM uses route-metric, see below documents
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html-single/configuring_and_managing_networking/index#con_how-networkmanager-manages-multiple-default-gateways_managing-the-default-gateway-setting
https://networkmanager.dev/docs/api/latest/nm-settings-nmcli.html

we need to fix it.

@xiachen-rh xiachen-rh added bug Something isn't working correctly new An issue that still needs triage labels Nov 15, 2024
TheRealFalcon pushed a commit that referenced this issue Nov 20, 2024
Most RHEL systems use network manager to bring up manage network connections.
Network Manager uses route-metric for the default route
and route/plen[,gateway,metric] for the additional static routes,
please see
https://networkmanager.dev/docs/api/latest/nm-settings-nmcli.html
https://networkmanager.dev/docs/api/latest/nm-settings-keyfile.html

This changes ensures that cloud-init generates nmconnection files with
route metric settings that are compatible with RHEL and network manager.

Fixes: GH-5877

Signed-off-by: Amy Chen <xiachen@redhat.com>
mathmarchand pushed a commit to mathmarchand/cloud-init-onb1204 that referenced this issue Nov 29, 2024
Most RHEL systems use network manager to bring up manage network connections.
Network Manager uses route-metric for the default route
and route/plen[,gateway,metric] for the additional static routes,
please see
https://networkmanager.dev/docs/api/latest/nm-settings-nmcli.html
https://networkmanager.dev/docs/api/latest/nm-settings-keyfile.html

This changes ensures that cloud-init generates nmconnection files with
route metric settings that are compatible with RHEL and network manager.

Fixes: canonicalGH-5877

Signed-off-by: Amy Chen <xiachen@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly new An issue that still needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant