PREFIX versus NETMASK

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 add NETMASK=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 

Solution 1:

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.