PREFIX versus NETMASK
The issue is probably that the IP address you are using confuses ipcalc when it tries to divine the NETMASK. Looking at the network scripts:
/etc/sysconfig/network-scripts/network-functions:
133 expand_config ()
134 {
135 if [ -z "${NETMASK}" ]; then
136 eval `/bin/ipcalc --netmask ${IPADDR}`
137 fi
138
139 if [ -z "${PREFIX}" ]; then
140 eval `/bin/ipcalc --prefix ${IPADDR} ${NETMASK}`
141 fi
142
143 if [ -z "${BROADCAST}" ]; then
144 eval `/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}`
145 fi
146
147 if [ -z "${NETWORK}" ]; then
148 eval `/bin/ipcalc --network ${IPADDR} ${NETMASK}`
149 fi
150 }
So say you are using 10.0.0.0 space which is technically in a /8, if you give this to ipcalc:
# /bin/ipcalc --netmask 10.34.102.1
NETMASK=255.0.0.0
You can test if this was the issue by putting your address in there and seeing if it returns the value you expected to see as NETMASK. Personally, I think this is really a bug in CentOS, it seems like if NETMASK is null but PREFIX is specified it should use that to set NETMASK.
Related videos on Youtube
Clodoaldo
Updated on September 18, 2022Comments
-
Clodoaldo almost 2 years
I did setup a virtual network interface in Centos 6 copying the ifcfg-eth0 to ifcfg-eth0:1 and changing the appropriate variables. But the connection was unstable. Although one of the pre-existent variables was
PREFIX=24
I had to addNETMASK=255.255.255.0
to the virtual interface script to make the connection stable. Shoudn't these variables have the same effect?EDIT:
This is ifcfg-eth0:1 unstable:
DEVICE="eth0:1" NM_CONTROLLED="yes" ONBOOT=yes HWADDR=00:26:18:24:4D:xx TYPE=Ethernet BOOTPROTO=none IPADDR=69.64.93.x PREFIX=24 GATEWAY=64.150.183.1 DNS1=69.64.66.11 DNS2=69.64.66.10 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0:1"
In the stable one I just added this line:
NETMASK=255.255.255.0
ifconfig
output with unstable first and stable after:eth0:1 Link encap:Ethernet HWaddr 00:26:18:24:4D:xx inet addr:69.64.93.x Bcast:69.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:28 Base address:0x6000 eth0:1 Link encap:Ethernet HWaddr 00:26:18:24:4D:xx inet addr:69.64.93.x Bcast:69.64.93.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:28 Base address:0x6000
-
Zoredache almost 13 yearsWhat is the output of
ip addr show
andip route show
with two different configurations? Is there any difference? -
Clodoaldo almost 13 yearsI don't want to touch the configuration again as that is a production server and I don't know how that affects the real interface.
ifconfig
before and after addingNETMASK
showed 255.0.0.0 and 255.255.255.0 respectively as Mask of the virtual interface.
-
-
Clodoaldo almost 13 yearsYes I get the wrong netmask:
# /bin/ipcalc --netmask 69.64.93.x NETMASK=255.0.0.0
But the real interface's IP, from where the script was copied, also gets a wrong netmask from ipcalc but the output from ifconfig is correct.