Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 
share|improve this question
1  
What is the output of ip addr show and ip route show with two different configurations? Is there any difference? –  Zoredache Aug 25 '11 at 16:16
    
I 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 adding NETMASK showed 255.0.0.0 and 255.255.255.0 respectively as Mask of the virtual interface. –  Clodoaldo Aug 25 '11 at 17:13
    
@Zoredache Just edited. I had already got the obvious problem and fixed it. My question is if there is any difference between those cited variables. –  Clodoaldo Aug 25 '11 at 17:37

1 Answer 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.

share|improve this answer
    
Yes 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. –  Clodoaldo Aug 25 '11 at 18:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.