Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
2  
0.0.0.0 != NULL. See en.wikipedia.org/wiki/0.0.0.0 :) –  Ƭᴇcʜιᴇ007 May 15 '13 at 22:10
    
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. –  Frank Thomas May 15 '13 at 22:55
    
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 May 16 '13 at 7:36
    
Default gateway is set by the DHCP. If the client is on the same subnet than the wanted gateway, then you can use its DHCP server, or set your DHCP to send this gateway. However, it is probably not the case. That's why you've to use your router as a DHCP server and a gateway, with routing rules to route packet from the client's subnet to the wanted gateway's subnet. –  piernov Mar 6 at 22:07

4 Answers 4

By not supplying the option at all ?

Please note that not supplying a default gateway is not going to work on some Operating Systems. Some will automatically assume that the DHCP server is the default gateway if no default gw (or an invalid one. 0.0.0.0 is technically invalid) is specified.
Others will listen for router advertisements send out by the router and get the routers address from that.

share|improve this answer
    
By not supplying the option I get the same default gateway. –  francadaval May 15 '13 at 22:05

Since all other routes will take precedence over default route, then specify the default gateway as localhost (127.0.0.1), which will keep hosts configured via DHCP from working unless they've a more specific route defined.

share|improve this answer
    
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? –  francadaval May 16 '13 at 7:32
    
Am I to understand you have two routers...? –  Nevin Williams May 16 '13 at 7:39
    
Yes. I have a router conected to Internet and other one just for a local network. –  francadaval May 16 '13 at 8:18
    
So you have two networks; Are you trying to serve both networks with one router's DHCP server? –  Nevin Williams May 16 '13 at 9:41
    
No, the main router is for internet connection via wifi (no posibilities to connect to it by cable :-( ) and the other to ensure independent local network connection beetwen computers for home development environment. –  francadaval May 16 '13 at 10:02

You are approaching the task from the wrong end. That kind of configuration should be set on the client side. Don't know what kind of clients do you have. For Debian (Ubuntu) add to

/etc/dhcp/dhclient.conf

the following line

supersede domain-name-servers 8.8.8.8

change 8.8.8.8 (Google Public DNS) to your DNS server.

share|improve this answer

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:

  • option-dhcp=3 to disable setting the default gateway
  • option-dhcp=6 to disable setting the DNS server
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.