Dhcp custom Default gateway

hi pals!
I need to set specific gateway for a host, different from the default all clients get.
Is it possible?
I have add list dhcp_option '3,192.168.10.1' but did not worked.
Any idea?
Thanks

@markab2015, welcome to the community!

:-1: That would do it for all DHCP clients (i.e. change the default).

Yep.

# in /etc/config/dhcp

config host
	option ip '192.168.10.xxx'
	option mac 'xx:xx:xx:xx:xx:xx'
	option name 'xxxxxxxxxxxxx'
	option dns '1'
	option tag 'custom_gtwy'

config tag 'custom_gtwy'
	list dhcp_option '3,192.168.10.1'
2 Likes

excelente!!!!
thanks!!!

1 Like

This solution is outdated now. It can be done entirely in the web GUI now (I'm using OpenWrt 22.03.5).

This non-standard default gateway should be changed in 2 places:

  1. "Network" menu -> "Interfaces" submenu -> for your "lan" interface -> Edit button -> "General Settings" tab -> "IPv4 gateway" textbox, fill in the non-standard gateway IP
  2. In the "DHCP Server" tab (and we're still inside editing lan interface) "Advanced Settings" sub-tab -> "DHCP-Options" textbox, fill in the non-standard gateway IP with "3," prefixed on the front (eg. "3,192.168.1.2", minus double-quotes) -> Save" button -> "Save and Apply" button -> press the "Restart" button beside your "lan" interface

Now renew your DHCP lease on your client (disconnect, re-connect your client to wifi/wired LAN)

Check your new gateway in Linux:

  1. in a Desktop Environment (DE), in NetworkManager (in your "tray", or whatever it's called in your DE), click "Network Settings". Then click the Gear icon beside your network connection. The "Default Route" is shown. It's the IP address of the custom Gateway now, right?

  2. In the CLI, use "route -n" (this "route" command is available in the "net-tools" package, in Debian). Under the "Gateway" column, your custom gateway is now shown, right (look for the one line which is not 0.0.0.0)?

1 Like

It could always be done in the web GUI.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.