How to skip pushing the default gateway via DHCP in OpenWRT?
Solution 1
Well, the question is already old, but here's the solution. dnsmasq
implicitly sets its host as the DNS server and default gateway. To disable this behavior, use the following configuration directives:
-
dhcp-option=3
to disable setting the default gateway -
dhcp-option=6
to disable setting the DNS server
Solution 2
Building off of Daniel B's answer, for OpenWRT, modify /etc/config/dhcp
to add the appropriate options:
config dnsmasq
...
# To disable setting the default gateway
option dhcp_option '3'
# To disable setting the DNS server
option dhcp_option '6'
...
Related videos on Youtube
francadaval
Updated on September 18, 2022Comments
-
francadaval over 1 year
I have a router with OpenWRT that I want to resolve IP addressing with DHCP without setting a default gateway.
I have added a
DHCP-Option
parameter with value3,0.0.0.0
that is supposed to set the default gateway by DHCP. Instead, the router IP is defined as default gateway for DHCP connections.How can I set a null default gateway (0.0.0.0) for connections configuration by DHCP?
As said in a comment: I want this router to service a VirtualBox network that doesn't set a default gateway via DHCP.
-
Ƭᴇcʜιᴇ007 almost 11 years0.0.0.0 != NULL. See en.wikipedia.org/wiki/0.0.0.0 :)
-
Frank Thomas almost 11 yearsDefault gateway is fundamental to the workings of the IP stack, and many internal functions will not work correctly without it. the system WILL infer one, whether correctly or incorrectly for your desired result.
-
francadaval almost 11 yearsFrank, I want the system to take the default gateway from other router connected to the Internet. They already have a default gateway but the wrong one is taken. I want this one to do as VirtualBox network that doesn't set a default gateway via DHCP.
-
-
francadaval almost 11 yearsBy not supplying the option I get the same default gateway.
-
francadaval almost 11 yearsIf this roter set de default gateway as localhost and other router set its IP as default gateway (to Internet connection) the last one takes precedence over the other?
-
Nevin Williams almost 11 yearsAm I to understand you have two routers...?
-
Nevin Williams almost 11 yearsSo you have two networks; Are you trying to serve both networks with one router's DHCP server?
-
Nicolas almost 9 yearsYou have a point about setting this up on the client, but the question is about the gateway, not the DNS server.