0

I understand how subnet masks work mechanically and how to convert from the mask to the CIDR bits notation, and I understand the concept of a default gateway. What I don't understand is what setting the subnet mask or default gateway on a device does and/or how it affects the ability to connect to the device.

For more context, I am developing a network device and I have a requirement that the device's IP address, subnet mask, and default gateway need to be configurable. I have learned how to set all these things in Linux, but I don't know how to test that they are working.

For the IP address, I can:

  1. Successfully connect to the device on its current IP address.
  2. Set a different (static) IP address.
  3. Disconnect.
  4. Fail to connect on the old address.
  5. Connect successfully on the new address.

Those steps verify that my process for changing the IP address works.

For the subnet mask and default gateway, I can set them and my machine tells me that they are set, but now I want to verify that these settings are working properly.

What basic test can I perform that will verify that the subnet mask and default gateway are getting changed?

2

1 Answer 1

1

Each IP packet needs to be routed - not only by routers/gateways but be the source node as well. For that purpose the node needs to match the destination IP address to its local routing table entries. The best match determines the route to take.

In the most basic scenario, a host has got a single interface with an IP address and network mask (determining the local subnet) and a default gateway (for anything not local).

Before you actually bind a new IP address you should check that it's not already in use (by ARPing it). To validate the new settings there's not much more than trying to ping the default gateway. The gateway might be valid but not responding to ping, so you also need to check if it's been ARPed correctly. If that also fails the setup is flawed.

Testing whether the gateway IP is actually a working isn't trivial. You could try running a short traceroute against a known (or any) destination and see how the "gateway" reacts.

You could also check reaching other hosts with a specific service but that requires you to locate them, e.g. by DNS.

And of course there's DHCP where your device is configured dynamically by the network (which is pretty much the standard).

1
  • Thanks for the response, but I'm having a lot of trouble understanding it. And the question was closed unfortunately.
    – nullromo
    Dec 6, 2021 at 18:53

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