What's new

subnetting clarification

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

bwana

Regular Contributor
I have this config:
Router 1 WAN port connected to internet
LAN Gateway 192.168.1.1
NAS 192.168.1.2
255.255.255.0
DMZ 192.168.1.10

Router 2 WAN port plugged into LAN port of router 1
WAN Ip 192.168.1.10
LAN Gateway 192.168.3.1
subnet mask 255.255.255.0


PC plugged into LAN port of Router 2
IP 192.168.3.20
Subnet mask 255.255.255.0

In this config, the pc can navigate to 192.168.3.1 (the inner router)
and 192.168.1.1 (the outer router)

but if I change the subnet mask to 255.255.0.0 on the pc, it can no longer see the outer router although it can still see the inner router and all other clients on the lan.
I thought that making the subnet mask of the pc 255.255.0.0 was a 'superset' of 255.255.255.0 and less restrictive. It allows for more addresses.
So why can't the pc go to 192.168.1.1
 
You don't change the mask on the pc, it is not a router. Your ip subnet range, subnet mask, and gateway should be defined on the router. Devices inherit their IP address, subnet mask and gateway from the router, or what is configured on the router. The subnetmask you gave the pc, doesn't match the network. Typically you do it at the DHCP Server. Then you can assign the IP addresses based on what the network should be, not pulling a mask out of the sky.. There's a reason why they say "one network, one router" in a home network environment." You need to have a good handle on routing and static routes.

Check out this link for subnet masks: http://unixwiz.net/techtips/netmask-ref.html
 
Ok let me think this through. It is a superset so to speak but in your example when you change your PC subnet to 255.255.0.0 you are telling it to only use the first two octets for the network. Thus when you PC looks for anything in the 192.168 network it thinks it is local to its network. Thus it will not send any traffic to the default gateway that starts with 192.168 (b/c it thinks it is local to its network). So you will not be able to see anything beyond the 192.168.3.1, except maybe the internet. I would think it would be able to get to the internet. Can it?
 
with subnet on pc 255.255.0.0, the pc can go to the internet but nothing locally. but with that logic you used, a subnet of 255.255.255.0 on the pc would make it think that anything 192.168.3.x is local and therefore would send no traffic to anything on the lan. This article
https://bryce.fisher-fleig.org/blog/the-missing-guide-to-subnet-masks/
explains it well. Subnet masks are used to specify a range of ip addresses. To define the size of the internal network. Typically this mask tells the router what's in it's lan and what is outside its lan (on the wan) . But I do not understand what the function of a mask on a pc is. I would think it is useless because there is nothing 'downstream' of the pc. yet if the subnet mask specifies a network larger than what its gateway specifies, then the pc can not talk to anyone on the network. i wonder why the pc network adapter needs a subnet mask?
 
The function of the mask on the PC is the same as on the router. It tells the PC what is on its LAN. It needs to know this so it will know what to send to the default gateway (your router). When you set its subnet mask to 255.255.255.0 then that tells the PC that anything that starts with 192.168.3 is local and anything that does not start 192.168.3 is not local and therefore needs to be sent to the default gateway (your router). If you change the PC subnet mask to 255.255.0.0 then that tells the PC that anything that starts with 192.168 is local and therefore does not need to be sent to the default gateway. That is why you cannot see the 192.168.1 network any longer. That network is not local to the PC but the PC thinks it is. But when you try to get to the internet it works because those addresses don't start with 192.168.
Basically the PC needs to know what is local (which does not require a router to talk to) and what is remote (which does require a router to talk to).
When your PC tries to talk to a network that is remote, it knows to send the information to the default gateway.
 
thank you abailey for your clear reply. but the pc is connected to the lan with an ethernet cable. When it wants to talk to another pc it sends out a tcp packet with the destination address. It cannot decide 'where' to send the packet to. The packet goes to the switch in the router or if there is a switch before the router it goes there. The switch has a map of ip addresses and mac addresses. There is no 'subnet' decision going on there. if the ip address is not in the table, the packet goes to the router, no?

My understanding of the subnet mask is that it is XORed with the destination ip and that result is 'ANDed with the source ip address. And that is done in the router. I still do not know exactly how the subnet mask in the pc is used when a tcp packet is transmitted. Or is it used somehow when a switch sends it a packet?
 
No, switches are layer 2 devices and routers are layer 3 devices. Switches do not know anything about IP addresses. They just know MAC addresses (and they keep a table of MAC address). Your PC makes the decision to send its packets out to the local network or to the router (default gateway). Thus your PC must know what IP addresses are considered local. This is where your subnet mask comes in. When your PC needs to talk to something on the local network it must know the MAC address of the device it wants to talk to. This is found in its ARP table. If it does not know the MAC address (the address is not in its ARP table) and only knows the IP address it will send out an ARP request. When the ARP request gets to the switch, the switch will forward the request to every port (besides the originating port). When the devices on each port receive the request they will compare their IP address with the destination IP address in the ARP. If their IP address is the destination IP in the ARP they will reply with their MAC address. Now the original PC has the destination MAC address and it sends its information to the switch. The switch has a list of all MAC addresses that have passed through it and what port these addresses are on. That is how the switch knows which port to send the information to. Now Layer2 cannot span multiple networks. To span multiple networks you need Layer3. The router is a layer3 device. So when your PC wants to send a packet to a device that it sees is outside of its local network it sends it to the default gateway (router).
Here are a couple of resources: https://supportforums.cisco.com/document/68421/overview-layer-2-switched-networks-and-communication
and: http://www.tildefrugal.net/tech/arp/
 
Last edited:
again thank you. sorry for thinking that a switch has ip info. I understand how a router uses a subnet mask to determine whether to send a packet to the local network or to the WAN. But I am still fuzzy on how the pc uses the subnet mask. When an application on a pc wants to send data, it encapsulates it into a packet. Does the subnet mask determine how a packet is encapsulated? For example if the pc wanted to send a packet on the local net, it would use an ethernet frame http://en.wikipedia.org/wiki/Ethernet_frame
and if it wanted outside the network would it use a tcp packet
http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure
?

Basically, I do not know HOW a pc determines where to send its data to. The ethernet network is like a bus-it goes everywhere. Putting a packet out through the ethernet jack of a pc is a generic event-therefore the packet itself has to determine who responds to it. A packet that is destined to picked up by a local device (switch or other pc on the lan) has to look different than a packet that is going to be picked up by a router.
 
I think I understand what you are asking. Ok so at the local PC the computer looks at the destination IP address of the packet it is getting ready to send. It compares that to its own IP address and subnet mask to determine if that packet is destined for its local network or a remote network. If it is destined for the local network then it must know the MAC address of the destination. That process is described above in one of my post. Anyway once it has the MAC address it just sends the packet out and the switch will route it to the correct port. Ok now if the PC determines that the packet is destined for a host on a remote network it will put the MAC address of the Default Gateway (router) on the packet and send it there. This link I put in earlier describes it: http://www.tildefrugal.net/tech/arp/ under the heading "ARP operation for a remote host".
Here is a small excerpt: "your computer knows the subnet mask and has a default gateway set. Because of this, your own computer can figure out for itself that the packet is not destined for the local network. Instead, your computer will use the MAC address of the default gateway (which it will either have in it's ARP table or have to send out an ARP request for as outlined above). When the default gateway (router) receives the frame it will see that the MAC address matches it's own, so the frame must be for it. The router will un-encapsulate the data link frame and pass the data part up to the network layer. At the network layer, the router will see that the destination IP address (contained in the header of the IP packet) does not match it's own (remember, the IP address has not been touched at all in this process since your computer created the IP packet). The router will realize that this is a packet that is supposed to be routed."

So basically the packet is the same as you would see on a local network, it just uses the MAC address of the default gateway instead the MAC address of the destination host (since it does not know the MAC address of the destination host).
 
thank you. exactly what i needed. I appreciate your patience and clear exposition.
 
There was a long time ago when network administrators utilized to calculate subnets and IP address ranges on their own one by one as it takes a lot of time and energy.
1- These days there are unlimited software through which you can utilize and get to know how to calculate subnets and IP address ranges. For users we will explain how to subnet their networks in a simple way.
2- Locate the option of Advanced Subnet Calculator and move to Classful Subnet Calculator tab.
3- Now enter the IP address of your network and choose the number of subnets. You can also change the number of hosts you want per subnet by tapping Generate Subnets.
4- Here you will be given the number of subnets and first and last valid host address beneath the title of Host Range.
5- There you would also be able to see the broadcast address for that precise subnet. You can also see the network ID beneath Subnet.
6- There is also this option to copy these addresses to the place where you want them to be by pressing the option of Copy Subnets. To know more about subnetting just visit https://appuals.com/how-to-subnet-your-network-easily/ For the sake of importing addresses to other files or in Excel pick and click the option of Export.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top