Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to create a virtual interface for the purpose of NameBased Virtual Hosting on my CentOS linux box; please find below is the devices' information:-

DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0c:29:4e:1c:14
MTU=1500
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
IPV6INIT=no


DEVICE=eth0:1
BOOTPROTO=none
IPADDR=192.168.1.5
NETMASK=255.255.255.0
NM_CONTROLLED=yes
ONBOOT=no
HWADDR=00:0C:29:4E:1C:14
TYPE=Ethernet
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0:1"
UUID=7758ac79-c4a2-dd87-1760-71284a316d00

Running ifconfig doesn't show the virtual device eth0:1;

[root@centos network-scripts]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:4E:1C:14
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4e:1c14/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24368 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21884 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9793531 (9.3 MiB)  TX bytes:4460526 (4.2 MiB)
          Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:799 errors:0 dropped:0 overruns:0 frame:0
          TX packets:799 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:82196 (80.2 KiB)  TX bytes:82196 (80.2 KiB)

pan0      Link encap:Ethernet  HWaddr EE:75:AD:75:9C:84
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Any ideas what I might be missing.

----------Edit 1:-

Restarted my linux box and could see all the configured virtual interfaces as below:- After System Restart:-

[root@centos ~]# date
Tue Apr 30 21:25:16 PDT 2013
[root@centos ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:4E:1C:14
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4e:1c14/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:97 errors:0 dropped:0 overruns:0 frame:0
          TX packets:117 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9756 (9.5 KiB)  TX bytes:17204 (16.8 KiB)
          Interrupt:19 Base address:0x2000

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:4E:1C:14
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:19 Base address:0x2000

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:4E:1C:14
          inet addr:192.168.1.40  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)

But after doing system-network-restart all my settings are gone: Please find below is the result after running the command:-

[root@centos ~]# service network restart
Shutting down interface eth0:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
state: activated
Connection activated

[root@centos ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:4E:1C:14
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe4e:1c14/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:290 errors:0 dropped:0 overruns:0 frame:0
          TX packets:292 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25640 (25.0 KiB)  TX bytes:41720 (40.7 KiB)
          Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)
share|improve this question
add comment

3 Answers 3

The virtual interface (aka. alias device) needs to be in it's own separate file ifcfg-eth0:1 like so:

# /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.1.5
NETMASK=255.255.255.0
NM_CONTROLLED=yes
ONBOOT=yes
HWADDR=00:0C:29:4E:1C:14
TYPE=Ethernet
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0:1"
UUID=7758ac79-c4a2-dd87-1760-71284a316d00

References

share|improve this answer
    
Sorry I forgot to mention, but I did create the file. –  Ankit May 13 '13 at 3:29
    
change none to static. –  slm May 13 '13 at 3:40
add comment

You need to set

ONBOOT=yes

then that interface will Up when you start/restart network service Or you can manually Up that interface using

ifup eth0:1

for down

ifdown eth0:1 
share|improve this answer
    
after restarting my linux box; I can see all the configured virtual interfaces but restarting the network only doesn't work. I have add ed sample in my question –  Ankit May 13 '13 at 8:23
    
are you using /etc/init.d/network restart or what ? –  Rahul Patil May 13 '13 at 8:49
    
i am using service network restart –  Ankit May 13 '13 at 8:53
    
seems fine.. but also stop NetworkManager service from startup and also check /var/log/messages for any error –  Rahul Patil May 13 '13 at 8:59
add comment

You must change BOOTPROTO=none to BOOTPROTO=static.

share|improve this answer
    
both means are same... means static –  Rahul Patil May 13 '13 at 3:45
    
@RahulPatil Not according to the documentation. My man page (ifcfg) says: "For bonding slaves and bridge ports to skip the interface configuration." Hard to believe that this should have changed. –  Hauke Laging May 13 '13 at 4:02
    
hmm good to know.. but have you tried.. they work the same.. –  Rahul Patil May 13 '13 at 4:03
    
@RahulPatil No, I haven't tried. But that is strange. –  Hauke Laging May 13 '13 at 4:10
    
Actually none is one of the possible values for BOOTPROTO, not static according to the Red Hat Enterprise Linux Deployment Guide (for RHEL5). Another way to check this would be to run less /usr/share/doc/initscripts-*/sysconfig.txt followed by a search for BOOTPROTO. –  Cristian Ciupitu Jul 17 at 20:04
add comment

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.