Disable automatic routes

Weird question. I'm wanting to disable all automatic routes in the routing table. I am trying to use OpenWrt for a learning exercise and I want the individuals to only be able to setup their own static routes and not have routing working at the start. It is a very simple exercise (1 WAN and 1 LAN interface) to learn about routing tables, but since the routing table is already updated by default in OpenWrt, they already have everything working without adding the necessary routes themselves.

@andyluse, welcome to the community!

What automatic routes?

  • Are you referring to the routes created when a network is recognized on each interface (e.g. when the LAN is addressed 192.168.1.1, it makes a route for 192.168.1.0/24 on eth0.1)?
  • Are you referring to the default route to the Internet?
    • If the latter, what happens if you configure the DHCP server not hand out a gateway upon the WAN port's IP request?

Link-local routing is so critical to operation, I would be surprised if it can easily be disabled.

One approach for a learning environment would be to force use of an empty routing table with pre-routing rules.

Another might be to “hack” the interface-up script to remove the default routes associated with the interface.

I'm looking to not fill all three of the default routes 1) the LAN route, the WAN route, and the default route.

If I deleted them in the interface-up script wouldn't this also delete any routing table entries they may have added themselves?

That it would, yes.

Neither option is "great", but I wouldn't want to guess how long it would take to find where in the kernel the routes are automatically added and patch it out.

How would I use prerouting rules to force an empty table? I have used prerouting for firwall/NAT rules but not sure how I would use that to clear out a table?

Simply run a script with commands to delete the rules.

(BTW, not sure why the exercise would remove something required [to be dynamic/robustly established] since RFC 1009.)

The simplest routing table of a device with 2 interfaces will have at least 2 routes for the directly connected interfaces (LAN and WAN).
Instead of messing with these 2, I suggest you teach your students how to add static routes for the router to be able to reach addresses beyond these the LAN and WAN networks.

1 Like