1

I'm running AlmaLinux 9 (a red hat 9 clone), and I would like to permanently remove a default route. My routing table is shown below, and I would like to remove the 172.31.252.1 route.

I know how to temporarily remove a route with 'ip route' command but it always appears on next boot. Instead, I want to permanently remove this route. The old RH /etc/sysconfig/network-scripts directory is no longer used (but kept for legacy reasons). I started a GUI but nowhere in the Network settings GUI do I see a default route setup.

How do I permanently remove that route?

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.31.252.1    0.0.0.0         UG    100    0        0 ens256
0.0.0.0         172.31.254.1    0.0.0.0         UG    101    0        0 ens192
172.31.252.0    0.0.0.0         255.255.255.0   U     100    0        0 ens256
172.31.254.0    0.0.0.0         255.255.255.0   U     101    0        0 ens192

The ManagementLan interface is stored in /etc/NetworkManager/system-connections, while EntertainmentVlan is stored in /etc/sysconfig/network-scripts/ifcfg-link:

BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME="Entertainment VLAN 30"
UUID=85810e29-e837-1d48-f5e7-9cd60d5a0ee4
IPADDR=172.31.252.31
PREFIX=24
DNS1=172.31.254.4
DOMAIN=mydomain.com
DNS2=172.31.234.4
HWADDR=00:0C:29:B6:49:0E

ip route:

default via 172.31.254.1 dev ens192 proto static metric 100
default via 172.31.252.1 dev ens256 proto static metric 101
172.31.252.0/24 dev ens256 proto kernel scope link src 172.31.252.31 metric 101
172.31.254.0/24 dev ens192 proto kernel scope link src 172.31.254.31 metric 100

ip rule show:

0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
TSG
  • 1,580
  • 6
  • 26
  • 42
  • 1
    Have you gone through `nmcli` ? For example. `nmcli conn show` ? Then Identify your connection, after that you should run `nmcli con modify -ipv4.routes "0.0.0.0/0 172.31.252.1 100"` Subsequently run `nmcli conn reload` or `nmcli conn up `. For more details see: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/configuring-static-routes_configuring-and-managing-networking – Valentin Bajrami Jul 21 '23 at 19:40
  • Have also a look at: `nmcli -f NAME,DEVICE,FILENAME conn show`. Other fields can be found in `man nmcli` – Valentin Bajrami Jul 21 '23 at 19:48
  • I tried the above and the second default route is still present. Using nmcli con show I see that there are NO ipv4.routes present. Does that mean something else is adding the route to the routing table? I also set ipv4.never-default=yes but no change in routes after NetworkManager service restart – TSG Jul 21 '23 at 20:31
  • I see you are running `netstat -rn` , can you show the output of `ip route` and `ip rule show` ? – Valentin Bajrami Jul 21 '23 at 20:32
  • ok question updated. The second command you suggested allowed me to correct my questions, the EntertainmentVLAN interface is stored in a legacy ifcfg file, but it's DEFROUTE=no – TSG Jul 21 '23 at 20:41
  • 1
    Solved: something above worked. I thought restarting the NetworkManager service would apply all changes, but it doesn't. I again had to run nmcli con reload and then things worked. – TSG Jul 21 '23 at 20:47
  • Ok, glad to hear it worked. I had that line in the first comment. – Valentin Bajrami Jul 21 '23 at 20:49

0 Answers0