1

The popular answer to the question " How does IPv4 Subnetting Work? " does a nice job in explaining subnets.

I remember learning about the network classes back in CCNA class but that answer mentions "Classless Inter-Domain Routing" (CIDR) in the following way:

Back in the "old days", subnet masks weren't specified, but rather 
were derived by looking at certain bits of the IP address. An IP address 
starting with 0 - 127, for example, had an implied subnet mask of
255.0.0.0 (called a "class A" IP address).

These implied subnet masks aren't used today and 
I don't recommend learning about them anymore.

So my question is if I have an ip address such as 71.75.232.132, (that is my public ip address assigned to my cable modem via my ISP), how do I figue out what the subnet mask is so that I can annotate the address in the proper format with something like 71.75.232.132/32

cwd
  • 2,693
  • 9
  • 32
  • 47

3 Answers3

9

Whoever assigned you that IP address should have also told you the subnet mask, default gateway, and whatever other information you need to configure your machine. If they're using DHCP, the DHCP server will tell your computer the subnet mask. Then you don't need to know it, but you can look it up with the appropriate command for your OS if you're curious.

David Schwartz
  • 31,215
  • 2
  • 53
  • 82
  • This is true, but in a hosting environment it could be that you're only given the ip address and told "just route out anything on your ethernet interface". This works, but it's better to have a default route anyway, since otherwise the arp table could fill up - your hosts thinks everybody is on this ethernet segment. – AndreasM Nov 23 '11 at 06:31
  • 2
    I have never had that happen (since CIDR), and I've been in the networking business on almost every possible end since CIDR took over. I have always given, or been given, a complete IP configuration sheet. Everyone who has been in this business for more than a month knows you just give them all the information they could possibly need and then they don't have to go back and forth with you. – David Schwartz Nov 23 '11 at 06:43
  • I had it happen to me, with one of the largest hosters in Germany. – AndreasM Nov 23 '11 at 07:14
  • 1
    In that case, you go back and tell them you need the rest of the information. You're the customer, after all. – Rob Moir Nov 23 '11 at 09:41
  • 1
    For **shared hosting** only IP of server play game, but it's from different area, unrelated to topic – Lazy Badger Nov 23 '11 at 11:30
  • Yeah, if the machine is already setup or DHCP is in use and you only have one IP address, they may not give you any other information. (And for a dynamic IP, even the subnet mask might change.) But then you can always use your device's network information tools to find the subnet mask. – David Schwartz Nov 23 '11 at 21:36
4

I don't think there is a way except calling your ISP/network admin to find out about it.

But you can attempt following.

An ICMP type 17 message, is a mask request. An ICMP type 18 is an ICMP mask reply. So you can use icmpush tool to build custom icmp packet and can request mask of the host. But remember not all routers and systems allow all icmp responses.

But according to this document(page no. 11).

If the Router is following RFC 1812 closely, it should not forward on an Address Mask Request to another network.

ICMP Address Mask Request aimed at a LINUX machine would not trigger an ICMP Address Mask Reply, nor a request aimed at a Microsoft Windows box.

But sending an ICMP Address Mask request aimed at a router on will receive a reply.

Sachin Divekar
  • 2,445
  • 2
  • 20
  • 23
1

You can't imagine netmask if only IP is given to you - mask can be of any size

In dirty form, as first iteration, you can get netmask from 2 known IP (your and GW) and knowing fact, that host and default GW must reside in the same network

HTH

Lazy Badger
  • 3,067
  • 14
  • 13