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'm trying to setup two network profiles in Centos. One for at home, one for at work. The home profile has a fixed IP address, fixed gateway and DNS server addresses. The work profile depends on DHCP.

I've created a 'home' and a 'work' directory in /etc/sysconfig/networking/profiles. Each has the following files containing the proper configuration:

> -rw-r--r-- 2 root root  422 Apr 17 20:17 hosts
> -rw-r--r-- 5 root root  223 Apr 17 20:18 ifcfg-eth0
> -rw-r--r-- 1 root root  101 Apr 17 20:17 network
> -rw-r--r-- 2 root root   73 Apr 17 20:18 resolv.conf

There was already a 'default' profile, which contains the same files.

Then I issued these commands:

system-config-network-cmd --profile work --activate
service network restart

I was expecting these files to get copied from the profiles/work directory to /etc/sysconfig/ and /etc/sysconfig/networking-scripts. And most files do get copied, except for ifcfg-eth0.

Stangely enough that files seems to be overwritten with the current settings when I issue system-config-network-cmd. The other files are also touched, but there contents stays in tact.

The system is Centos 5.7 running on a virtual pc within a windows 7 machine. Here is the output for ifconfig:

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:03:FF:6F:2E:AB
          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::203:ffff:fe6f:2eab/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4199761 errors:7 dropped:0 overruns:0 frame:0
          TX packets:1733750 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2316624688 (2.1 GiB)  TX bytes:415533386 (396.2 MiB)
          Interrupt:9

Can someone tell what I'm missing here?

share|improve this question
    
What version of CentOS is this? Are both home/work connections wired/wireless/one of each? –  uther Apr 19 '12 at 13:40
    
Centos 5.7 final. Both are wireless connections in reality but the system is running on a virtual machine hosted on windows 7 so the adapter may in fact be mapped to a wired virtual adapter, I'm not sure. I've added ifconfig output to the original post, maybe that helps? –  Leven Apr 20 '12 at 9:18
1  
What VM are you using (vmware, virtual pc etc) and what have you got the virtual adapter set to (bridged, NAT, Host only etc)? –  Tim Alexander May 24 '12 at 16:03

2 Answers 2

up vote 1 down vote accepted

As it follows from the RedHat's documentation on networking profiles, you should not use base interface name (eth0) for profile interfaces, but have one called as eth0_work and so on. BTW, you don't need to restart network configuration, since profile switching handles it by its own. An example:

# system-config-network-cmd --profile foobar --activate
Network device deactivating...
Deactivating network device eth0, please wait...
Network device activating...
Activating network device eth0_foobar, please wait...
share|improve this answer

Why use profile here ?

Suppose eth0 was the home line , static IP , edit:

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
IPADDR=192.168.57.200
NETMASK=255.255.255.0
STATIC=yes
ONBOOT=yes

And for the other work line , use DHCP , edit:

/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp

And ensure the network service starts on boot.

e.g if you run the service at level 2 , 3 , you can do:

chkconfig --level 23 network on

Reboot to see changes.

share|improve this answer

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.