Skip to main content
The 2024 Developer Survey results are live! See the results
added 462 characters in body
Source Link
grawity_u1686
  • 465.8k
  • 66
  • 978
  • 1.1k

First, ip addr does not automatically know the netmask. It is impossible to determine that from just the address itself, so you must specify the /prefixlen along with it. If you forget to do that, then the address will be added as /32 (single-host) and you will not be able to reach the rest of your subnet.

Second, your netmask is not a /4, it's a /30. The slash notation is used to indicate bit length of the netmask, not the literal subnet size. So the correct command would be:

ip addr add 172.31.255.253/30 dev enp0s25

(You can calculate /length as 32−log2(size) and size as 2(32-length), or just count the bits.)

Also, it'a "netmask" or "subnet mask" and not "DNS-mask", as it has nothing to do with DNS.


I see you're also specifying a rather unusal address as the gateway. With your netmask, .252 is the "zeroth" address of the subnet, and is usually considered reserved in IPv4. (Are you perhaps confusing 'gateway' and 'network address'?)

However, communications within the same subnet do not need a gateway in the first place – that's what a subnet is – so you can just skip that ip route add line entirely for now.


Finally, "Destination Host Unreachable" often means a different kind of error: it means the OS does know that the address is within a local subnet, but isn't receiving any responses from trying to look up its MAC address using ARP. (That step is mandatory before sending anything to a same-subnet device.)

Try to make manual ARP queries (similar to what the OS does) – if they succeed, then something is still wrong with your IP configuration:

arping -I enp0s25 172.31.255.254

First, ip addr does not automatically know the netmask. It is impossible to determine that from just the address itself, so you must specify the /prefixlen along with it. If you forget to do that, then the address will be added as /32 (single-host) and you will not be able to reach the rest of your subnet.

Second, your netmask is not a /4, it's a /30. The slash notation is used to indicate bit length of the netmask, not the literal subnet size. So the correct command would be:

ip addr add 172.31.255.253/30 dev enp0s25

(You can calculate /length as 32−log2(size) and size as 2(32-length), or just count the bits.)

Also, it'a "netmask" or "subnet mask" and not "DNS-mask", as it has nothing to do with DNS.


I see you're also specifying a rather unusal address as the gateway. With your netmask, .252 is the "zeroth" address of the subnet, and is usually considered reserved in IPv4. (Are you perhaps confusing 'gateway' and 'network address'?)

However, communications within the same subnet do not need a gateway in the first place – that's what a subnet is – so you can just skip that ip route add line entirely for now.

First, ip addr does not automatically know the netmask. It is impossible to determine that from just the address itself, so you must specify the /prefixlen along with it. If you forget to do that, then the address will be added as /32 (single-host) and you will not be able to reach the rest of your subnet.

Second, your netmask is not a /4, it's a /30. The slash notation is used to indicate bit length of the netmask, not the literal subnet size. So the correct command would be:

ip addr add 172.31.255.253/30 dev enp0s25

(You can calculate /length as 32−log2(size) and size as 2(32-length), or just count the bits.)

Also, it'a "netmask" or "subnet mask" and not "DNS-mask", as it has nothing to do with DNS.


I see you're also specifying a rather unusal address as the gateway. With your netmask, .252 is the "zeroth" address of the subnet, and is usually considered reserved in IPv4. (Are you perhaps confusing 'gateway' and 'network address'?)

However, communications within the same subnet do not need a gateway in the first place – that's what a subnet is – so you can just skip that ip route add line entirely for now.


Finally, "Destination Host Unreachable" often means a different kind of error: it means the OS does know that the address is within a local subnet, but isn't receiving any responses from trying to look up its MAC address using ARP. (That step is mandatory before sending anything to a same-subnet device.)

Try to make manual ARP queries (similar to what the OS does) – if they succeed, then something is still wrong with your IP configuration:

arping -I enp0s25 172.31.255.254
Source Link
grawity_u1686
  • 465.8k
  • 66
  • 978
  • 1.1k

First, ip addr does not automatically know the netmask. It is impossible to determine that from just the address itself, so you must specify the /prefixlen along with it. If you forget to do that, then the address will be added as /32 (single-host) and you will not be able to reach the rest of your subnet.

Second, your netmask is not a /4, it's a /30. The slash notation is used to indicate bit length of the netmask, not the literal subnet size. So the correct command would be:

ip addr add 172.31.255.253/30 dev enp0s25

(You can calculate /length as 32−log2(size) and size as 2(32-length), or just count the bits.)

Also, it'a "netmask" or "subnet mask" and not "DNS-mask", as it has nothing to do with DNS.


I see you're also specifying a rather unusal address as the gateway. With your netmask, .252 is the "zeroth" address of the subnet, and is usually considered reserved in IPv4. (Are you perhaps confusing 'gateway' and 'network address'?)

However, communications within the same subnet do not need a gateway in the first place – that's what a subnet is – so you can just skip that ip route add line entirely for now.