Communicating with devices on a different subnet

99,874

Should I just change my computer's IP Address to be 192.168.10.something, or is there another way?

If you only temporarily need to speak to 192.168.10.10, this will be the easiest thing to do.


I'm simplifying the following a bit to explain better:

For your computer to talk to any computer, your system must have an entry in its local routing table (or Forwarding Information Base) for that subnet.

A subnet is a network address plus a subnet mask. (Note that the subnet mask can be in dotted form (255.255.255.0) or CIDR form (/24) - they express the same thing though certain things want only one or the other).

The subnet mask says how many bits long the network address is. All the bits that are 0 in the subnet mask (the last 8 for 255.255.255.0 or /24 - which is the last number in the dotted-four notation) will be 0 for the network address. A full IP address actually given to a machine will not have 0's in that spot - but routing table entries work with network addresses.

A routing table entry consists of a subnet plus an interface, and tells your system that if your system sends traffic out of that interface, it can reach that subnet.

You get a free routing table entry whenever your system gets an IP address plus a subnet mask, either by you doing that manually or it happening automatically via DHCP.

If you have a single ethernet adapter, and it gets the IP/subnet mask 192.168.7.4/24 via DHCP, the /24 is saying that your system can send something out of that ethernet adapter and reach anything else beginning with 192.168.7.

If you are in a typical LAN situation, where other machines on that LAN have the same network address (192.168.7) and subnet mask (/24 or 255.255.255.0), this works.

You also get a free routing table entry for your loopback address. 127.0.0.1/8.

If you add another ethernet interface, let's say a USB one, and manually configure it with an IP, say 192.168.10.1, the same thing happens above with free routes. Assumne you assigned the USB ethernet adapter 192.168.10.1 with subnet mask /24 (or 255.255.255.0). So now your computer can get to 192.168.10.7 because it has a route to it.

What if:

  • you have two adapters that can reach the same subnet?

    • If they differ in subnet mask, the more specific one (the higher CIDR number) will "win" and will be used. (One interesting side thing to mention is that you can think of /32 - or subnet mask 255.255.255.255 - as a shortcut that means "this specific IP" - so you can make traffic originating from your local system destined for a specific IP to go out a different interface - like a VPN interface - if you wanted by making a route table entry with a /32.)

    • Otherwise, there's another value called the metric - the adapter with the lowest metric will be used. Typically you'd set faster adapters to have lower metrics. Your wired adapter should have a lower metric than your wireless for this reason.

    • If they are same CIDR and equal metric your system might pick one and then stick with it, or load balance between them. This may be configurable depending on your OS and drivers.

  • your system wants to send traffic somewhere but it doesn't have a routing table entry? It uses the default gateway - this consists of an IP address (which must be reachable by some other local routing rule.) Typically this will point to your Internet-facing router on your same LAN in a home setup, and is set by DHCP though you can set it manually too as you probably already know.

  • you don't have a default gateway? It drops the traffic and doesn't send it.

  • you have multiple default gateways? It will probably either pick a random one and stick with it or it might load balance between them. This may be configurable depending on your OS and drivers.

Share:
99,874

Related videos on Youtube

nathan lachenmyer
Author by

nathan lachenmyer

Professional Designer and C++ programmer; I write custom software for interactive applications.

Updated on September 18, 2022

Comments

  • nathan lachenmyer
    nathan lachenmyer over 1 year

    Let me start this off by saying that I am very new to how IP Address / Subnet Addresses work, and networking in general. This stuff is generally mystifying, and I've had a hard time understanding what I've read so far.

    I have a network device that is hard coded with the IP Address 192.168.10.10 and the Subnet Mask 255.255.255.0.

    My computer sits at 192.168.0.17, and I can't connect to the device. I assume this is because the 192.168.10.* subnet and 192.168.0.* subnet (is that the right word?) can't communicate to each other.

    Is there a way I can configure my computer to talk to this device? Should I just change my computer's IP Address to be 192.168.10.something, or is there another way?

    thanks!

  • nathan lachenmyer
    nathan lachenmyer over 9 years
    So if I set my computer's subnet mask to be something like 255.255.0.0, would that allow me to talk to anything on 192.168.*.*? If the target device has a subnet mask of 255.255.255.0, does that mean that it couldn't talk to me, but I could potentially talk to it?
  • LawrenceC
    LawrenceC over 9 years
    Yes on your first question. Per your second question, you are mostly correct - many TCP/IP stacks will ignore incoming traffic that isn't matching the IP/subnet mask unless the adapter is in "promiscuous mode."
  • RalfFriedl
    RalfFriedl over 5 years
    Does this add anything to the previous answer?