What causes routing table 30400 to be created automatically in RHEL 8 on AWS which causes connectivity issues?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 8
  • AWS

Issue

  • Why am I not able to ping the server from the same subnet instances?
  • What causes routing table 30400 to be created automatically in RHEL 8 on AWS which causes connectivity issues?
  • What is the reason for internal or same subnet traffic to be routed via gateway instead of a local route?

Resolution

Stop and disable nm-cloud-setup.timer & nm-cloud-setup.service service.

# systemctl disable nm-cloud-setup.timer
# systemctl disable nm-cloud-setup.service

Root Cause

  • When running a virtual machine in a public cloud environment, it is desirable to automatically configure the network of that VM. In simple setups, the VM only has one network interface and the public cloud supports automatic configuration via DHCP, DHCP6, or IPv6 Autoconf. However, the virtual machine might have multiple network interfaces, or multiple IP addresses and IP subnets on one interface which cannot be configured via DHCP. Also, the administrator may reconfigure the network while the machine is running. NetworkManager's nm-cloud-setup is a tool that automatically picks up such configuration in cloud environments and updates the network configuration of the host.

  • nm-cloud-setup configures the network by fetching the configuration from the well-known metadata server of the cloud provider. That means, it already needs the network configured to the point where it can reach the metadata server. Commonly that means, that a simple connection profile is activated that possibly uses DHCP to get the primary IP address. NetworkManager will create such a profile for ethernet devices automatically if it is not configured otherwise via the "no-auto-default" setting in NetworkManager.conf. One possible alternative may be to create such an initial profile with nmcli device connect "$DEVICE" or nmcli connection add type ethernet.

  • By setting the user-data org.freedesktop.nm-cloud-setup.skip=yes on the profile, nm-cloud-setup will skip the device.

  • nm-cloud-setup modifies the run time configuration akin to nmcli device modify. With this approach, the configuration is not persisted and only preserved until the device disconnects. More information on nm-cloud-setup

Amazon EC2 (AWS):

For AWS, the tools try to fetch configuration from http://169.254.169.254/. Currently, it only configures IPv4 and does nothing about IPv6. It will do the following.

- First, fetch http://169.254.169.254/latest/meta-data/ to determine whether the expected API is present. This determines whether the EC2 environment is detected and whether to proceed to configure the host using EC2 metadata.

- Fetch http://169.254.169.254/2018-09-24/meta-data/network/interfaces/macs/ to get the list of available interfaces. Interfaces are identified by their MAC address.

- Then for each interface fetch http://169.254.169.254/2018-09-24/meta-data/network/interfaces/macs/$MAC/subnet-ipv4-cidr-block and http://169.254.169.254/2018-09-24/meta-data/network/interfaces/macs/$MAC/local-ipv4s. Thereby we get a list of local IPv4 addresses and one CIDR subnet block.

- Then nm-cloud-setup iterates over all interfaces for which it could fetch IP configuration. If no ethernet device for the respective MAC address is found, it is skipped. Also, if the device is currently not activated in NetworkManager or if the currently activated profile has a user-data org.freedesktop.nm-cloud-setup.skip=yes, it is skipped.

- Then, the tool will change the runtime configuration of the device.

- Add static IPv4 addresses for all the configured addresses from local-ipv4s with prefix length according to subnet-ipv4-cidr-block. For example, we might have here 2 IP addresses like "192.0.2.1/24,198.51.100.1/24".

- Choose a routeing table 30400 + the index of the interface and add a default route 0.0.0.0/0. The gateway is the first IP address in the CIDR subnet block. For example, we might get a route "0.0.0.0/0 192.0.2.1 10 table=30401".

- Finally, add a policy routing rule for each address. For example "priority 30401 from 192.0.2.1/32 table 30401, priority 30401 from 192.0.2.1/32 table 30401".

With above example, this roughly corresponds for interface eth0 to nmcli device modify "eth0" ipv4.addresses "192.0.2.1/24,192.0.2.1/24" ipv4.routes "0.0.0.0/0 192.0.2.1 10 table=30401" ipv4.routing-rules "priority 30401 from 192.0.2.1/32 table 30401, priority 30401 from 192.0.2.1/32 table 30401". Note that this replaces the previous addresses, routes, and rules with the new information. But also note that this only changes the run time configuration of the device. The connection profile on the disk is not affected.

Diagnostic Steps

  • Check if the route table exists.
# nmcli connection show eth0 | grep -i table
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 192.0.2.1, mt = 100
IP4.ROUTE[2]:                           dst = 198.51.100.0/27, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 198.51.100.1/32, nh = 0.0.0.0, mt = 10, table=30400  <----
IP4.ROUTE[4]:                           dst = 0.0.0.0/0, nh = 198.51.100.1, mt = 10, table=30400   <----

# ip -4 rule show
0:  from all lookup local
30400:  from 192.0.2.1 lookup 30400
32766:  from all lookup main
32767:  from all lookup default
  • Check the status of nm-cloud-setup.timer & nm-cloud-setup.service.
* nm-cloud-setup.service - Automatically configure NetworkManager in cloud
   Loaded: loaded (/usr/lib/systemd/system/nm-cloud-setup.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/nm-cloud-setup.service.d
           `-10-rh-enable-for-ec2.conf
   Active: inactive (dead) since Tue 2021-08-07 10:32:57 UTC; 3min 11s ago
    Unit ntpd.service could not be found.
Unit ntpdate.service could not be found.
Unit plymouth-quit-wait.service could not be found.
Unit plymouth-start.service could not be found.
 Docs: man:nm-cloud-setup(8)
  Process: 878 ExecStart=/usr/libexec/nm-cloud-setup (code=exited, status=0/SUCCESS)
 Main PID: 878 (code=exited, status=0/SUCCESS)

Sep 07 10:32:56 ip-xx-xx-xx-xx.ap-test-1.compute.test systemd[1]: Starting Automatically configure NetworkManager in cloud...
Sep 07 10:32:57 ip-xx-xx-xx-xx.ap-test-1.compute.test systemd[1]: nm-cloud-setup.service: Succeeded.
Sep 07 10:32:57 ip-xx-xx-xx-xx.ap-test-1.compute.test systemd[1]: Started Automatically configure NetworkManager in cloud.

* nm-cloud-setup.timer - Periodically run nm-cloud-setup
   Loaded: loaded (/usr/lib/systemd/system/nm-cloud-setup.timer; enabled; vendor preset: disabled)
   Active: active (waiting) since Tue 2021-09-07 10:32:54 UTC; 3min 14s ago
  Trigger: Tue 2021-08-07 10:38:04 UTC; 1min 55s left

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments