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 sysconfig renderer #5776

Closed
ani-sinha opened this issue Oct 3, 2024 · 0 comments · Fixed by #5777
Closed

Configuring metric for default gateway is not working with sysconfig renderer #5776

ani-sinha opened this issue Oct 3, 2024 · 0 comments · Fixed by #5777
Labels
bug Something isn't working correctly

Comments

@ani-sinha
Copy link
Contributor

ani-sinha commented Oct 3, 2024

The following config

# cat /etc/cloud/cloud.cfg.d/custom.cfg 
            network:
              config:
                - name: ens160
                  subnets:
                    - address: 172.16.127.125/24
                      gateway: 172.16.127.2
                      type: static
                      routes:
                        - destination: 0.0.0.0/0
                          gateway: 172.16.127.2
                          metric: 99
                  type: physical
              version: 1

produced a interface config file something like this:

# cat /etc/sysconfig/network-scripts/ifcfg-ens160 
# Created by cloud-init automatically, do not edit.
#
AUTOCONNECT_PRIORITY=120
BOOTPROTO=none
DEFROUTE=yes
DEVICE=ens160
GATEWAY=172.16.127.2
IPADDR=172.16.127.125
METRIC=99
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

However, the route is not configured with this metric:

# # ip r show
default via 172.16.127.2 dev ens160 proto static metric 100
172.16.127.0/24 dev ens160 proto kernel scope link src 172.16.127.125 metric 100

NetworkManager does not recognize METRIC for global generic metric value

nmcli con mod 'System ens160' ipv4.route-metric 90
# grep -i metric /etc/sysconfig/network-scripts/ifcfg-ens160
IPV4_ROUTE_METRIC=90

nmcli con up 'System ens160'
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
# ip r show
default via 172.16.127.2 dev ens160 proto static metric 90
172.16.127.0/24 dev ens160 proto kernel scope link src 172.16.127.125 metric 90

NM uses IPV4_ROUTE_METRIC and IPV6_ROUTE_METRIC.

See also https://people.freedesktop.org/~lkundrak/nm-docs/nm-settings-ifcfg-rh.html and
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

We need to fix this.

@ani-sinha ani-sinha added bug Something isn't working correctly new An issue that still needs triage labels Oct 3, 2024
ani-sinha added a commit to ani-sinha/cloud-init that referenced this issue Oct 3, 2024
Most RHEL systems use Network manager to bring up manage network connections.
Network manager does not recognize "METRIC" option for network connections.
It uses IPV4_ROUTE_METRIC and IPV6_ROUTE_METRIC options. Please see
https://people.freedesktop.org/~lkundrak/nm-docs/nm-settings-ifcfg-rh.html

This change ensures that cloud-init generates ifcfg network connection files
with IPV{4/6}_ROUTE_METRIC options that are compatible with RHEL and
network manager.

Fixes: canonicalGH-5776
Signed-off-by: Ani Sinha <anisinha@redhat.com>
@TheRealFalcon TheRealFalcon removed the new An issue that still needs triage label Oct 3, 2024
@TheRealFalcon TheRealFalcon added this to the cloud-init-24.4 milestone Oct 3, 2024
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants