LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   8 or 16 Bit netmask (https://www.linuxquestions.org/questions/linux-server-73/8-or-16-bit-netmask-4175652313/)

chrisguk 04-17-2019 01:51 PM

8 or 16 Bit netmask
 
I thought I was loosing my mind but I setup an interface with the IP 10.10.0.254 and a netmask of 16 bit. Once I brought the interface up and ran ifconfig it stated that the address was 8 bit 255.0.0.0

Anyone know why?

TB0ne 04-17-2019 01:54 PM

Quote:

Originally Posted by chrisguk (Post 5986007)
I thought I was loosing my mind but I setup an interface with the IP 10.10.0.254 and a netmask of 16 bit. Once I brought the interface up and ran ifconfig it stated that the address was 8 bit 255.0.0.0

Anyone know why?

Since you tell us absolutely NOTHING about version/distro of Linux, hardware, network environment, what you were expecting, etc., then no...we don't know why. Read the "Question Guidelines".

Without any sort of details, there's no way anyone can even guess.

chrisguk 04-17-2019 02:09 PM

Sorry,

Distro ubuntu server 16.04
Virtual Machine on KVM
Network is a small LAN with a standard gateway.

I was expecting the output to show a 16bit netmask considering this is what I put in the iface config file.

ehartman 04-17-2019 02:41 PM

Quote:

Originally Posted by chrisguk (Post 5986007)
I thought I was loosing my mind but I setup an interface with the IP 10.10.0.254 and a netmask of 16 bit. Once I brought the interface up and ran ifconfig it stated that the address was 8 bit 255.0.0.0

Anyone know why?

You must have specified the netmask wrong because 255.0.0.0 is neither an 8- nor a 16-bit netmask, it is the default 24-bit netmask that belongs to a 10.*.*.* private network.
The number of 0-bits from the RIGHT is the netmask, so an 8-bit mask gives 255.255.255.0 and a 16-bit one would result in 255.255.0.0

I.e, in my private network I use only a 3-bit netmask, so ifconfig returns:
netmask 255.255.255.248
as that private net contains less than 7 systems anyway.

michaelk 04-17-2019 03:05 PM

Quote:

I.e, in my private network I use only a 3-bit netmask, so ifconfig returns:
netmask 255.255.255.248
as that private net contains less than 7 systems anyway.
The CIDR netmask notation is based upon the number of ones not zeros...

255.255.255.248 i.e 11111111.11111111.11111111.11111000 or /29

10.0.0.0 is a class A network which by default is a 255.0.0.0 or /8 network. I do agree with you that the OP probably entered an invalid format and the default was automatically used.

Post the interface config file.

scasey 04-17-2019 05:21 PM

Quote:

Originally Posted by michaelk (Post 5986034)
Post the interface config file.

...also the ifconfig output.

ehartman 04-17-2019 08:32 PM

Quote:

Originally Posted by michaelk (Post 5986034)
The CIDR netmask notation is based upon the number of ones not zeros...

You're right, thanks for the correction. It was rather too late (for me) when I posted that reply. Sorry to the OP.

michaelk 04-17-2019 08:59 PM

I knew what meant :)

kaushalpatel1982 04-18-2019 05:46 AM

This might be a configuration issue. When you don't provide netmask while configuring, it will take default netmask based on IP address you have given. in your case, it is /8.

Please provide your configuration here.

TB0ne 04-18-2019 07:20 AM

Quote:

Originally Posted by kaushalpatel1982 (Post 5986246)
This might be a configuration issue. When you don't provide netmask while configuring, it will take default netmask based on IP address you have given. in your case, it is /8.

Please provide your configuration here.

Right; based on the question, we already knew this was a misconfiguration issue, and we've asked for the configuration here several times already. OP already stated they put a 16 bit value in the interface config file.


All times are GMT -5. The time now is 10:35 AM.