Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Subnet mask and IP Address

  1. Aug 1, 2016 #1
    Dear PF Forum,
    I want to understand computer networking.
    There's a problem that I'd like to know the answer. This problem might not come out in day to day practice, but by having the answer of this problem, I hope I can, at least, understand how router works.

    Consider there are 3 computer. A, B and C.
    There IP address and subnet mask are.
    A: 192.168.1.1, mask: 255.255.0.0, so its network address is: 192.168.0.0
    B: 192.168.1.2, mask: 255.255.255.0, so its network address is: 192.168.1.0
    C: 192.168.2.3, mask: 255.255.255.0, so its network address is: 192.168.2.0

    My question is.
    1. Can A ping B?
    My reasoning is this.
    A will see that B(IP) AND A(Mask) = A(IP) AND A(Mask) = 192.168.0.0
    So basically A will consider B in the same network.
    And so does B will see that A is at the same network. A(IP) AND B(Mask) = 192.168.1.0

    2. Can B ping A?

    3. Can A ping C?
    My reasoning is this.
    A will see that C(IP) AND A(Mask) = A(IP) AND A(Mask) = 192.168.0.0
    So basically A will consider C in the same network.
    Although C will see that A is at different network. A(IP) and C(Mask) = 192.168.1.0

    Thank you very much.
     
  2. jcsd
  3. Aug 1, 2016 #2

    fresh_42

    Staff: Mentor

  4. Aug 1, 2016 #3
    Haven't pinged an internal IP on my network before (only the likes of websites). However trying now it appears you can, so I've learned something new today!
     
  5. Aug 1, 2016 #4
    Yeah, it's like reverse engineering. I have a theory, why it can/can't connect.
    If it can then... (this is the theory)
    If it cannot then...(this is the other theory).
    I should have tried it in my office.
    Thanks anyway.
     
  6. Aug 2, 2016 #5
    Simply put in my opinion,
    1. Yes
    2. Yes
    3. No
    Explanation: 1 and 2 share the same network 192.168.1.x whereas 3 stays in a different one 192.168.2.x
     
  7. Aug 2, 2016 #6
    A: 192.168.1.1, mask: 255.255.0.0, so its network address is: 192.168.0.0
    B: 192.168.1.2, mask: 255.255.255.0, so its network address is: 192.168.1.0

    The network address for
    A: 192.168.0.0
    B: 192.168.1.0
    Different, are you sure?
     
  8. Aug 2, 2016 #7
    Let's do a simple experiment to verify this.
    Use 2 routers (uh oh what is your pronunciation of this word ? mine is /rounter/ :oldbiggrin:) and nat your network with them, one is 192.168.0.x and the other 192.168.1.x . And try pinging a computer in one network to another in the other network. The pinging would fail. I am sure about this. My ways to answer questions might make readers think I seem unsure about what I say but that is who I am, a humble person with a true sense to pursue beauty to its lair. :blushing:
     
  9. Aug 2, 2016 #8
    Good idea, I'll try it. Thanks.
     
  10. Aug 7, 2016 #9

    Svein

    User Avatar
    Science Advisor

    The network mask only shows the IP handler which hosts (IP dialect for computer) it can reach without going through a router. Thus:

    Assume that your PC has the IP address 192.168.1.17 with a subnet mask of 255.255.255.0 and a default gateway of 192.168.1.1 (this is old-fashioned IP dialect for router). Then
    • If you want to connect to 192.168.1.33, the IP handler uses the subnet mask and discovers that both hosts are on the same subnet. It then establishes a connection directly with 192.168.1.33 without bothering the router at all.
    • If you want to connect to 74.86.200.109 (the IP address of this forum), the IP handler uses the subnet mask and discovers that the destination host is not on the same subnet. It then sends the connection request (with the destination IP address) to the router, leaving the problem of locating the destination host to the Internet collection of routers. The routers have their own set of protocols between them (OSPF (https://en.wikipedia.org/wiki/Open_Shortest_Path_First), BGP (https://en.wikipedia.org/wiki/Border_Gateway_Protocol)) to help them find their way to the destination.
     
  11. Aug 8, 2016 #10
    Thanks, may I discuss further?
    * If you want to connect to 192.168.1.33, the IP handler uses the subnet mask and discovers that ...
    192.168.1.17 and 255.255.255.0 = 192.168.1.0
    192.168.1.33 and 255.255.255.0 = 192.168.1.0
    both hosts are on the same subnet. It then establishes a connection directly with 192.168.1.33 without bothering the router at all.


    * If you want to connect to 74.86.200.109 (the IP address of this forum), the IP handler uses the subnet mask and discovers that...
    192.168.1.17 and 255.255.255.0 = 192.168.1.0
    74.86.200.109 and 255.255.255.0 = 74.86.200.0

    the destination host is not on the same subnet. It then...

    Ok, but what about this.
    My IP 192.168.1.17, mask: 255.255.0.0
    Target. 192.168.2.18, mask 255.255.255.0
    Can I ping to target without?
    Can I ping to target even with router?
    Thanks.
    And thanks for the wiki links.
     
  12. Aug 8, 2016 #11

    Svein

    User Avatar
    Science Advisor

    Your subnet mask is the only one that matters. You promise the IP handler that you can access the complete 192.168.0.0.network directly. If you have made a false promise, change your subnet mask (255.255.252.0 will promise access to 192.168.1.0, 192.168.2.0 and 192.168.3.0).

    As you state it, the IP handler will try to connect directly. Since you have promised the IP layer that you are able to connect directly, it will not try to go through a router.
     
  13. Aug 8, 2016 #12

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor

    Stephanus, do you realize you are asking us "what will happen if I have a misconfigured network?"?

    The subnet mask is a property of the network, not any PC on it. If you misconfigure the PCs (e.g. A is reachable from B and B is not reachable from A) you should expect problems.
     
  14. Aug 8, 2016 #13

    Svein

    User Avatar
    Science Advisor

    Some additional information:

    Private IPv4 address spaces (https://en.wikipedia.org/wiki/Private_network)
    The Internet Engineering Task Force (IETF) has directed the Internet Assigned Numbers Authority (IANA) to reserve the following IPv4 address ranges for private networks, as published in RFC 1918 (https://tools.ietf.org/html/rfc1918):
    • 10.0.0.0 - 10.255.255.255
    • 172.16.0.0 - 172.31.255.255
    • 192.168.0.0 - 192.168.255.255
    This means that your 192.168.1.17 address is not allowed on the Internet. Your (modern) router will map that address onto a valid Internet address.
     
  15. Aug 9, 2016 #14
    Thank you staffs/mentors for you advice.
    I think I have to try it myself. I'm in a process of learning networking here.
    Code (Text):
    A Ping to B:


    All ping to 192.168.1.223

    Trial 1
    A: 192.168.2.222,  255.255.255.0
    B: 192.168.1.223,  255.255.0.0
    Result: Destination host unreachable

    Trial 2
    A: 192.168.1.222,  255.255.255.0
    B: 192.168.1.223,  255.255.0.0
    Result: Success

    Trial 3
    A: 192.168.1.222,  255.255.0.0
    B: 192.168.1.223,  255.255.255.0
    Result: Success

    Trial 4
    A: 192.168.2.222,  255.255.0.0
    B: 192.168.1.223,  255.255.255.0
    Result: Reguest time out

    --------------------------------------
    ping Computer_B_Name: could not find host
    pinging to computer name will yield
    "Could not find host",
    even if pinging to IP address is successful
    @Svein, I'll rearrange your reply without quote tag.
    - Your subnet mask is the only one that matters. You promise the IP handler that you can access the complete 192.168.0.0.network directly.
    Yes
    - If you have made a false promise, change your subnet mask (255.255.252.0 will promise access to 192.168.1.0, 192.168.2.0 and 192.168.3.0).
    No false promise. I just what to check that my promise is to 192.168.0.0, and I want to ping to a computer that promises to 192.168.1.0
    I want to see if it works.
    See trial 3 and 4 above.

    - As you state it, the IP handler will try to connect directly. Since you have promised the IP layer that you are able to connect directly, it will not try to go through a router.

    Yes, but my promise should somehow meet the other computer promise (?)
    In class C
    192.168.1.222 can ping to 192.168.1.223
    192.168.2.222 cannot ping to 192.168.1.223

    In class B
    192.168.2.222 can ping to 192.168.1.223

    But
    192.168.2.222 (B) cannot ping to 192.168.1.223 (C)
    192.168.1.222 (B) can ping to 192.168.1.223 (C)

    I'm new in networking here.

    Misconfiugre? Well..., I did it intentionally. I just want to know the effect.
    (Now I have reset my IP to 10.1.xxx.xxx back, or I won't be able to answer this thread :smile:)

    That's right! And I don't want to set my network that way. I just want to understand about mask and router and IP. It turns out that network mask also plays an important role here, not just router. Less than a month ago I just understand this. Before that, I think it only takes IP to do this networking. Thanks for the tips.

    Thanks for the links.

    Not trying to show off here, but most computer programmers will remember 224, 220, 216, 210, 28 .. 20. :smile:

    Of course not. As someone working in a supermarket, it's just like item barcode.
    https://en.wikipedia.org/wiki/List_of_GS1_country_codes
    100: USA
    300: France
    49: Japan
    890: India
    899: Indonesia, etc...
    But what if your company intends to create barcode for internal use. What kind of barcode number that will not collide other international barcode. So we have to use local barcode number: 200.
    It's just like IP address that you have given us.
    10.x.x.x,
    172.16.x.x to 172.31.x.x,
    192.168.x.x.
    @Svein Thanks for the answer.
     
  16. Aug 9, 2016 #15

    Svein

    User Avatar
    Science Advisor

    Just a tip: If you have several computers on your local area network, use a DHCP server to distribute correct IP information to all computers (and pads and smartphones). You give the DHCP server an address range to administer and specify the netmask and "default gateway".

    If you want to know more about DHCP, check out https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol.
     
  17. Aug 9, 2016 #16
    DHCP? Sure why not. I'm new in computer networking I just learn now.

    Perhaps the reason I create this thread was I needed confirmation.
    I read this two rules in computer networking.

    Rule A: Network address is IP Address masked by mask bit.
    Netwok Address = IP Address and Subnet Mask.
    For example
    IP: 192.168.1.15
    Mask: 255.255.255.0
    So network address is 192.168.1.0

    Rule B: Only computers with the same network address can communicate without router.

    So according to Rule A.
    Computer A with
    IP: 192.168.1.222, Mask: 255.255.0.0
    will see that Computer B with IP: 192.168.2.223, is in the same network address/range.

    But according computer B.
    IP: 192.168.2.223, mask: 255.255.255.0
    will see that computer A is in different network address.

    Some literature in the internet don't address this issue.
    But as I tried it myself yesterday, I found the answer, but still no network rule that states it can/cannot be done.

    Thanks anyway @Svein
     
  18. Aug 10, 2016 #17

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor

    That's because you are [still] asking about the properties of a misconfigured network. A subnet has a range if IP addresses, and every computer on it needs to have the same range. If you tell one computer the range is 192,168.0-255.0-255 and another something different, like 192.168.2.0-255, you do not have the same range, your network is misconfigured.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Subnet mask and IP Address
  1. IP address (Replies: 4)

  2. Ports on IP addresses (Replies: 5)

  3. IP Address Assignment (Replies: 5)

Loading...