TransWikia.com

How is the information regarding the IP address for a Default Gateway in a home network stored and communicated around the network

Super User Asked by CB1066 on February 18, 2021

I’m exploring possible ways to manually set my primary and secondary DNS server addresses.

My home network uses a consumer-grade router (issued by the Internet Service Provider) and all my devices connect via WiFi.

I’ve an older, discarded router that has the option to manually set primary and secondary DNS server addresses but my current router (despite lots of additional features) doesn’t offer this facility, but I may be able to combine the two:

Both routers had an initial ‘admin page’ at 192.168.1.1 so I’ve changed the setup as followed:

Newer router is at 192.168.1.20 and the older router at 192.168.1.30 and I’ve disabled DHCP on the newer router and enabled DHCP on the older router (with a range 192.168.1.40 – 192.168.1.80 which is more than enough for my total number of devices).
The newer router is to remain the Default Gateway.

The setup worked regarding DHCP; my laptop was allocated an IP address within range (192.168.1.41) – but, inspecting ipconfig/all at the laptop’s DOS prompt, showed the IP address for the Default Gateway was now set to the older router.

My possible misconception:
I’ve been assuming that my laptop would become aware of the actual Default Gateway (which is still my newer router at 192.168.1.20) via some ‘broadcasting discovery process’. However, it seems the Default Gateway IP address is perhaps part of the information that’s issued (by the older router in this case) during the DHCP process and that it sets the address to that of itself and that this can’t be overridden.

Conclusion: I now reckon that I’m most likely wrong about what’s possible and that what I’m attempting wouldn’t ever work.

Question: How is the information regarding the IP address for a Default Gateway in a home network stored and communicated around the network.

Any information, advice or guidance greatly appreciated.

3 Answers

As the other answers already point out, it is indeed DHCP that supplies this information to devices on a home network. Typically it’s the following details:

  • IP address + network mask
  • IP address of the default gateway
  • A list of DNS servers the device should use

There’s nothing in the protocol preventing DHCP servers from providing arbitrary values for any of the DHCP “options”. However, SOHO routers rarely offer configuration options. Instead, they are hardwired to send their IP address as the gateway as well as the DNS server. Sometimes, they also send the configured DNS servers directly.

You indicate you have a Raspberry Pi. I suggest using it instead of the old router, which cannot do what you want.

On the Raspberry Pi, you need only one thing: A DHCP server. However, because it is so easy to use, I recommend using Dnsmasq. As the name suggests, it is also a DNS server (and other stuff).

A basic configuration could look somewhat like this:

domain=localnet
interface=eth0
dhcp-range=192.168.1.100,192.168.1.200
dhcp-option=option:router,192.168.1.20
dhcp-option=option:dns-server,8.8.8.8,1.1.1.1

(Note that I haven’t tested this.)

You could also let Dnsmasq do its DNS thing; it’d be something like this:

domain=localnet
interface=eth0
dhcp-range=192.168.1.100,192.168.1.200
dhcp-option=option:router,192.168.1.20

server=8.8.8.8
server=1.1.1.1

Please note that the Raspberry Pi must be configured with a static IP address on the correct subnet for this to work.

Answered by Daniel B on February 18, 2021

  Question: How is the information regarding the IP address for a Default Gateway in a home network stored and communicated around the network.

This information is typically provided by the DHCP server. In the case of a router, the router can deduce this by providing its owninternal IP address.

If you can flash dd-wrt onto your router you can configure this functionality. Of-course, you don't need a router - any device that is on your LAN, on 24*7 and can run a DHCP server can do this - even something like a Raspberry or regular PC thats on 24/7.

Answered by davidgo on February 18, 2021

On the older router DHCP settings, you have to set the default gateway to the IP of the newer router. DHCP works by broadcast, and the gateway is assigned through DHCP. Your setup will work, but with some minor tweaks. For your DNS settings, you have the choice of allowing a router to serve as a DNS cache/forwarder for the LAN, or give all clients public DNS servers with DHCP. Some of the steps I'm going to outline you have already completed, but I'm going to include them in the answer for sake of completeness.

My topology will use Router B as the DNS cache and forwarding server for the LAN.

  • New router = Router A = 192.168.1.20
  • Old router = Router B = 192.168.1.30
  • LAN clients = 192.168.1.40-80
  • All subnet masks are 255.255.255.0, abbreviated as /24

On Router A:

  1. Set static IP of 192.168.1.20/24 and 192.168.1.20 as gateway.
  2. Set LAN DNS server to 192.168.1.30.
  3. DHCP Disabled.

On Router B:

  1. Set static IP of 192.168.1.30/24 and 192.168.1.20 as gateway.
  2. On the static assigned router interface, configure your public DNS servers.
  3. DHCP Enabled.
  4. On the LAN DHCP settings:
  5. DHCP IP range: 192.168.1.40 - 192.168.1.80/24
  6. DHCP Gateway: 192.168.1.20
  7. DHCP DNS: 192.168.1.30

If you have issues getting this to work just right, or don't need any local LAN DNS resolves, you could assign the public DNS servers in the DHCP settings, instead of 192.168.1.30. That will allow each LAN client to directly query and cache their own DNS records.

I'm actually using a very similar topology in my home LAN. Here is a screenshot of how ipconfig /all comes out on my primary network adapter for my desktop PC. The red underline is my Default Gateway, the ISP supplied modem/router. The blue lines are another client on my LAN, that offers DHCP and DNS services. The DHCP server at 192.168.50.199 is telling my PC that 192.168.50.1 is the default gateway for the subnet.

ipconfig example

Answered by Jim Diroff II on February 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP