0

I received a datasheet with which I need to configure a server that doesn't do dhcp but rather needs to use a static IP address. The sheet tells me to set the subnet mask 255.255.252/22. I tried to "translate" this into a subnet mask I am used to but obviously failed.

I tried many variations but Ubuntu complains about them. My assumption is that this is neither an error nor an Ubuntu question, therefore I seek help here.

255.255.252.0/24 doesnt't work either, an entry like 255.255.252.0 is not accepted because Ubuntu insists on a CIDR.

enter image description here

Marged
  • 105
  • 3
  • Not sure what the question is, but using a simple subnet caluclator shows this : https://www.calculator.net/ip-subnet-calculator.html?cclass=any&csubnet=22&cip=10.16.192.251&ctype=ipv4&printit=0&x=63&y=21 . What happens when you configure the address(es) by hand in `/etc/network/interfaces` ? – schaiba Nov 12 '19 at 08:34
  • @schaiba I will try this next but I wanted to use the configuration utility provided by Ubuntu – Marged Nov 12 '19 at 11:32
  • The answers to the above-linked question explain how to do that. – Ron Maupin Nov 12 '19 at 14:30
  • https://askubuntu.com/questions/1188147/installation-of-server-does-not-accept-subnet-cidr – vidarlo Nov 13 '19 at 17:25

1 Answers1

2

You can write a subnet mask in 3 ways:

  • in binary, the real notation, but never used in practice since it is not really practical, for example 11111111111111111111110000000000or 11111111111111111111111100000000
  • with the slash notation it is written as /22 or /24
  • in decimal, it will be 255.255.252.0 or 255.255.255.0

As you can see the 22or 24 noted after the slash is simply the count of contiguous 1. The decimal notation divides the 32 bits in four octets and convert them from binary to decimal and write them separated by points, the same way an IP address is written in decimal.

Personally I would never write 255.255.252/22 which only cause confusion, because it looks like an IP address assigned to an interface rather than a subnet mask.

In a documentation / procedure, I would write it 255.255.252.0 (/22), which give the same information in 2 different formats, so the reader can choose the format it prefers or avoid the pain to convert from one to another.

When you configure a device you will always use a single format. Some devices only accept the "slash" notation, will other only accept the decimal notation, and some can use both (but one at a time).

If you must enter a subnet, an IP address and a gateway this would be:
Subnet: 10.16.192.0/22 Address: 10.16.192.251 Gateway: 10.16.192.1

(But this is a bit odd since you have the gateway IP that is somewhere in the subnet, usually it will be the first or the last address of the subnet)

Marged
  • 105
  • 3
JFL
  • 19,405
  • 1
  • 32
  • 64
  • OK, so the subnet CIDR I specified is correct. Then this should be an Ubuntu issue, I guess. – Marged Nov 12 '19 at 11:32
  • @Marged edited. This is not a ubuntu issue, the /22 subnet which contains 10.16.192.251 is 10.16.188.0/22 – JFL Nov 12 '19 at 11:48
  • /22 has 4 /24s. 192 is evenly divisible by 4. So 10.16.192.251 is inside subnet 10.16.192.0/22 using CIDR notation. Highest IP in that subnet is 10.16.195.255. The notation 255.255.252.0/22 is wrong. 255.255.252.0 is a netmask and does not need a CIDR notation. 10.16.188.0/22 is also wrong. Highest IP in that subnet is 10.16.191.255. Please edit. – Darrell Root Nov 12 '19 at 19:22