Add "default gateway" setting to static lease configuration

Some network have more than one default gateway, it would be great to be able switch static leases between them.

Example
192.168.1.1 direct internet
192.168.1.2 vpn
192.168.1.254 no internet (for hostile devices such as apple, microsoft, google and chinese products)

Here is what the interface might look like

The interface might be a drop down, with a selection of known and named default gateways, but that's definetly and extra feature

I would also like if a device could have a static lease that defines a particular default gateway without specifying a static IP address. That is a lease that only forces a particular gateway but nothing else.

At the same time, specifying a DNS server override might be very useful but I will make a separate request for this. (think switching between google 8.8.8.8 , your isp dns and a pihole for instance)

1 Like

This is a companion request to Add "DNS" setting to static lease configuration

What's wrong with the standard, OpenWrt and RFC-method way of doing so?

:bulb: (Setting a Router/Gateway is done via DHCP Option No. 3 - works the same way as DNS Option No, 6.)

1 Like

Setting is not accessible in openwrt, yes I want it to add to static lease the option gateway.
As you can see from my screenshot, this option is missing.

  • I provided a link with the example - it works, so it is accessible.
  • Your screenshot does show it.

You may want to clarify and provide more details.

  • Are you saying you also want some mechanism where the OpenWrt "guesses" gateways other than itself (even false and arbitrary ones made up - used to provide no Internet)?
  • If so, how would it "know" that other gateway information without you configuring it (i.e. as above or your screenshot)?

Sorry, I was not clear

The screenshot above is a mockup, a fabrication

Here is the actual dialog, it lacks options for setting a gateway

I have reviewed your link and it requires console use. I am really talking about the luci web interface here.

I also tried editing the /etc/config/dhcp manually

image

I have test with an android and microsoft dhcp client both have apparently ignored the option gateway and instead have filled in the "real" gateway of 192.168.1.1

As for having a drop down list of gateways, I would assume that like the mac address drop down, it would check for the gateways it always knows about. That would be other existing option gateway entries in /etc/config/dhcp and the routes. That is really a minor convenience though, just having a textbox to enter a forced gateway would be an improvement.

For now, I don't know why it doesn't even work in the documented way of using the console. This is why I would like the web interface to have a box. These kind of manual hacks don't work half the time.

Wait, you already programmed/wrote the code? :slightly_smiling_face:

Because you improperly configured it. See the link again. I'm not sure why you didn't follow the correct syntax:

config host
	option name 'cam2'
	option dns '1'
	option ip '192.168.1.82'
	option mac '26:2x:xx:xx:xx:32'
	option tag 'gtwy_2'

config tag 'gtwy_2'
	list dhcp_option '3,192.168.1.2'

(Note - using the tag, you can assign an alternate gateway to any DHCP host config.)

  • (Gateways must be specified by IP.)
  • A static IP (i.e. like assigned a gateway/router) would be unknown to the OpenWrt thru the methods it discovered other MAC/IPs
  • How would the OpenWrt be configured to know one IP from another as a subsequent gateway?

Perhaps it should be be noted that your initial sentence is somewhat of a false premise and misnomer. There's only 1 default gateway. Others would require custom - and usually manual configs (at the client itself usually). Policy-Based routing can be used at the router level (the PBR app available for the web GUI, as well as setting up basic IP routes and rules without an additional install).

This isn't a manual hack. That's the OpenWrt Unified Configuration Interface that the web GUI manipulates too. Anything coded on the web GUI simply edits the file I'm showing you. :bulb:

:spiral_notepad: This is the actual of section code that would need to be programmed into your mockup to produce the config above.

See:

To be sure it's referenced:

:spiral_notepad: The UCI is the "layer-of-abstraction" that is used to make configs. This includes the LuCI web GUI.