Jump to content

Setting priorities on NIC


sergei
 Share

Recommended Posts

Hi,

I usually use my laptop in two environments: work, where I am connected to the net through wired eth0; and home where I use onboard wireless NIC configured as eth1.

At boot time at home, configuration of eth0 passes rather quickly, perhaps because no beat is detected at eth0 and the net is bound to eth1. But when I boot at the office, eth0 is also quickly configured, but it takes about 1 minute for eth1 to time out. Worse even, sometimes it picks up a distant signal from some other department where I do not have access, takes over eth0 settings and I finish with completely non-working network configuration. Is there any way to set priorities on NIC? Say, do not attempt to configure eth1 if eth0 is up and running? Or, at least, to reduce time to set up the wireless eth1?

Any help is greatly appreciated!

Thanks!

PS. System: Mandriva 2005LE

 

[moved to Networking by arctic]

Link to comment
Share on other sites

Here is what I did. Create separate netprofiles for home and work. For each profile, edit interfaces which you want to start. E.g., if you don't want to use eth1 at work, tell the network init scripts not to start eth1 on boot. You can do it via mcc and some other fancy GUIs, but the simplest and most bullet-proof way is to do it by hand. If anything does not work, you can always roll back changes. Also, it's a good idea to make backup copies of config files which you edit.

 

Go to /etc/netprofile/profiles/, create two dirs, say home and work, and copy the content of dir default into those dirs, including all subdirectories. Go to the subdir work/files/etc/sysconfig/network-scripts/ and edit the script ifcfg-eth1 to tell eth1 not to start on boot. As root, open that script in your favourite text editor, and set ONBOOT=No. That will tell init script that this interface should not be started.

 

Now, again as root, edit the file /etc/lilo.conf as follows. Open it in editor and create two copies of the lilo entry which you normally boot to. For example, I have these two entries in my lilo.conf

          label="home-profile"
       root=/dev/hda5
       initrd=/boot/initrd.img
       append="xxxx xxxx xxxx PROFILE=home"
       vga=788
       read-only
image=/boot/vmlinuz
       label="work-profile"
       root=/dev/hda5
       initrd=/boot/initrd.img
       append="xxxx xxxx xxxx PROFILE=work"
       vga=788
       read-only
image=/boot/vmlinuz

Note the PROFILE option. You will need to add it to append. Certainly, you will have to modify the names of the profiles according to your choice. Save, close. You don't need to edit anything else. If any of the lines/options are different, let them be.

 

AS ROOT RUN lilo -v Make sure, you don't have any errors.

 

Have you run lilo -v? If yes, reboot. Now if at the lilo screen you choose work-profile, the interface eth1 won't start at all. You can also modify all other services to start/stop depending on whether you are at work or at home.

Link to comment
Share on other sites

Agaaa, finally I know how the profiles work, thanks a lot! This seems to be much involved solution to what I've been looking for. Do you know if this may help for another problem: setting local variables like proxy server, smtp server etc.? By now I am resolving this by running a small script at the login time which sniffs the network and basing on arp output runs and changes (or just swap links) config files like .profile, kmailrc, prefs.js etc.

I see the profiles you mention work for boot. Can it be propagated to user-level too? Can, for instance, /etc/netprofile/profiles/home/files/

contain

/home/sergei/.profile

with correspondingly set variables PRINTER, CUPS_SERVER etc? Is the original /home/sergei/.profile overwritten with

/etc/netprofile/profiles/home/files/home/sergei/.profile ?

 

Sorry, to bother you with these questions, but I couldn't find any explanations how to work with profiles... A reference would do.

Thanks again!

Link to comment
Share on other sites

I should have said that adding profiles to lilo is optional. You can switch profiles by hand or via GUI after the system is up.

 

You said you did not like waiting until ifup eth1 timed out. A solution to this is to call the correct profile at boot time. By default, the system boots to the most recently used profile. So if you used eth1 at home, next time at work your ifcfg-eth1 still contains the line ONBOOT=yes. This will make the network script try to start eth1 (ie connect to your home wireless LAN) until it times out. For that reason, I prefer selecting profiles at boot time to switching them at a user level.

 

I don't know whether you can add your own files to /etc/netprofile/profiles/home/files/. But you can run your script from /etc/rc.local. It will do shiffing and copying files for you at boot time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...