SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to automate network setup for my laptop, particularly switching between wired/wireless connection according to availability.
I get the feeling udev or hal or something like that can do what I want, but I can't find a good entry point for the documentation.
Here's my setup :
Slack 12 just installed on laptop, with wired (eth0) and wireless (eth1) NICs. Both interfaces configured with static IPs on the same subnet. When the ethernet cable is plugged in, everything works properly. If the cable is not plugged in, the network is unreachable until I do :
# route del default
# route add default gw $MY_GATEWAY dev eth1
Does anyone have a way to do this automaticaly whenever cable/wifi state changes? I could write a script to set everything up by checking sysfs, along with judicious pinging, but I don't want to have to run it by hand every time.
So your wired network has the same subnet as your wireless? if you changed it to be different ones i think you wouldn't have as much trouble.
here's an example configuration.
wired: 10.1.1.0/24
wireless: 10.2.1.0/24
edit /etc/rc.d/rc.inet1.conf
Code:
# Config information for eth0:
IPADDR[0]="10.1.1.100"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""
# Config information for eth1:
IPADDR[1]="10.2.1.100"
NETMASK[1]="255.255.255.0"
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""
# Default gateway IP address:
GATEWAY=""
Make sure gateway is blank.
then in your rc.local
Code:
route add default gw 10.1.1.1 dev eth0
route add default gw 10.2.1.1 dev eth1
There might be a better way to do this and to be honest im not sure if this will work. it makes sense and it should work i just don't have a setup to test on.
Unfortunately, it's not my network at work, so I can't change anything other than my own configuration: everything must be in one subnet. On top of that, I doubt my home router can handle two different subnets.
Here's an example of what I'm looking for, to make it clearer :
I come in to work in the morning, use the cable available at my desk. Later on I have to work in another room for a meeting, so I use the wireless connection. In the afternoon I go home, connect through my home network. All network configuration happens silently, whithout me having to do anything other than plug/unplug the cable or boot the laptop.
My laptop works this way..
Office- IP address assigned by DHCP (win 2003 server)
Home - Small router on static IP addresses assigned net (2 machines + laptop)
I just created a second /etc/rd.d/inet1.conf, let's say /etc/rc.d/inet2.conf properly configured.
As I have only one ethernet port (eth0) my /etc/rc.d/inet1.conf is like this
# Config information for eth0:
IPADDR[0]=""
NETMASK[0]=""
USE_DHCP[0]="yes"
DHCP_HOSTNAME[0]=""
# Default gateway IP address:
GATEWAY=""
My second "/etc/rc.d/inet2.conf" is like this
# Config information for eth0:
IPADDR[0]="192.168.1.4"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""
# Default gateway IP address:
GATEWAY="192.168.1.1"
Now you need a small modification of your /etc/rc.d/inet1, very simple..at the very beginning of the script you'll find
. /etc/rc.d/rc.inet1.conf (the first uncommented line)
where /etc/rc.d/inet1.conf is "sourced" by the script. Change to a conditional sourcing this way
if cat /proc/cmdline | grep -w "Office" 1> /dev/null 2> /dev/null; then
. /etc/rc.d/rc.inet1.conf
else
. /etc/rc.d/rc.inet2.conf
fi
You are almost done, just one step..
Modify your /etc/lilo.conf from somethgig like
Of course you have to change this according to your configuration. Remember to launch lilo in order this take effect. The Kernel will not complain for such unusual boot parameter.
When you boot is just a matter of choice
Hope this helps
ciao
Statically configured hosts are rather not automated. Set up a DHCP daemon at home and stop worrying about this stuff, because you can be pretty sure that any wireless network you go to is going to be using DHCP to hand out IP addresses. We are long past the point where people should be dorking around with configuring individual machines on their network when they don't need to.
Last edited by evilDagmar; 12-07-2007 at 04:06 AM.
Thanks for all the answers - I'm getting a feeling I shouldn't be messing with all of this, but then I wouldn't be running slack if I didn't enjoy it .
I actualy have DHCP at home for guests, it's just that my cheapo DSL router ocassionaly decides to take a break. I also want to log in to the laptop from my other machines - it's not configurable enough to give me the same address every time.
For what it's worth, the solution i'm sticking to for now is using a script to check which connection is up and ping the gateways to find where I am. I'm running it at startup, and by hand from a panel launcher whenever appropriate.
If someone has a way to run this whenever network state changes I'm all set.
Just put these commands on /etc/rc.d/rc.local (or create a new section in /etc/rc.d/rc.inet1.conf) and it will set up your ethernet port for your home configuration.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.