How to skip pushing the default gateway via DHCP in OpenWRT?

15,447

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' 
    ...
Share:
15,447

Related videos on Youtube

francadaval
Author by

francadaval

Updated on September 18, 2022

Comments

  • francadaval
    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 value 3,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
      Ƭᴇcʜιᴇ007 almost 11 years
      0.0.0.0 != NULL. See en.wikipedia.org/wiki/0.0.0.0 :)
    • Frank Thomas
      Frank Thomas almost 11 years
      Default 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
      francadaval almost 11 years
      Frank, 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
    francadaval almost 11 years
    By not supplying the option I get the same default gateway.
  • francadaval
    francadaval almost 11 years
    If 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
    Nevin Williams almost 11 years
    Am I to understand you have two routers...?
  • Nevin Williams
    Nevin Williams almost 11 years
    So you have two networks; Are you trying to serve both networks with one router's DHCP server?
  • Nicolas
    Nicolas almost 9 years
    You have a point about setting this up on the client, but the question is about the gateway, not the DNS server.