View previous topic :: View next topic |
Author |
Message |
marce n00b
Joined: 09 Jul 2002 Posts: 21
|
Posted: Thu Jun 05, 2003 7:02 am Post subject: Choosing IP address at startup |
|
|
Hi to all, I have the latest Gentoo installed on my laptop, I'm looking for a way to to have it try to pull an IP address from a dhcp server and, if this is not available, to use another IP (specified by me).
The optimum would be that the process be set in the background, so that I must not wait for the dhcp timeout and can proceed with the boot process.
The reason I'm asking is that I hook this laptop to different networks (some with a dhcp server, some without), and it's a PITA to have to change the config file each time.
Any suggestions?
Thank you
(if this post belongs to a different forum please accept my apologies) |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20552
|
Posted: Thu Jun 05, 2003 5:20 pm Post subject: |
|
|
Moved from Documentation, Tips & Tricks. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
mfairchi n00b
Joined: 23 Apr 2002 Posts: 57 Location: Ventura, California
|
Posted: Fri Jun 06, 2003 6:45 am Post subject: |
|
|
don't know why this got moved,
but anyway, if ther is a tip trick or documentation for how to do this i'd like to see it. I got the same setup.
-Michael |
|
Back to top |
|
|
bsolar Bodhisattva
Joined: 12 Jan 2003 Posts: 2764
|
Posted: Fri Jun 06, 2003 6:48 am Post subject: |
|
|
mfairchi wrote: | don't know why this got moved |
This got moved because it's a support request. The Documentation, Tips & Tricks forum is meant to post HOWTO's, hints, tricks and so forth, not to post requests for them. _________________ I may not agree with what you say, but I'll defend to the death your right to say it. |
|
Back to top |
|
|
Rocker n00b
Joined: 12 Dec 2002 Posts: 67 Location: The Netherlands
|
Posted: Fri Jun 06, 2003 7:03 am Post subject: |
|
|
Hi,
2 days ago, I modified my /etc/conf.d/net, to deal with this issue.
The idea behind it is to give an append at my lilo prompt, to set a location. Here is my modified /etc/conf.d/net:
Code: |
if [ $LOCATION = "utilitas" ]; then
echo "Location set to Utilitas"
iface_eth0="192.168.50.115 broadcast 192.168.50.255 netmask 255.255.255.0"
gateway="eth0/192.168.50.6"
elif [ $LOCATION = "dhcp" ]; then
echo "Location set on dhcp"
iface_eth0="dhcp"
dhcpcd_eth0="-t 10"
else
echo "Unknown location, setting default"
iface_eth0="192.168.0.10 broadcast 192.168.0.255 netmask 255.255.255.0"
gateway="eth0/192.168.0.1"
fi
|
Of course you can set your own block of code within the if-else statements.
After modifying my /etc/conf.d/net, I changed my lilo.conf for selecting the correct location. Simple add
Code: | append = "LOCATION=dhcp" | , where the variable can be set to anything you want.
Now I've 2 items for my current kernel, one with LOCATION=utilitas, and one with LOCATION=dhcp.
If I need to connect frequently to another network, I add a new item in my lilo.conf, and a new elif block in my /etc/conf.d/net
Goodluck with it! |
|
Back to top |
|
|
uzik Apprentice
Joined: 17 Apr 2003 Posts: 257
|
Posted: Fri Jun 06, 2003 9:54 pm Post subject: Re: Choosing IP address at startup |
|
|
marce wrote: |
The reason I'm asking is that I hook this laptop to different networks (some with a dhcp server, some without), and it's a PITA to have to change the config file each time.
Any suggestions?
|
Set up the system to use NO networking by default.
It will boot fast. Whip up a little shell script called
"NETWORK-A" that tries to configure the networking for
that setup. Whip up another for "NETWORK-B" which
configures it for the other network. When you boot
run the correct script.
If you're really a whiz you can run both as background tasks
after you boot up and one or the other will succeed.
The script can then in turn start all the network dependent daemons
by executing the start scripts:
# get a list of network dependent scripts
# I wish I could remember the exact syntax for grep...
NETSTUFF=`grep -l /etc/init.d/* net`
# run them
for SCRIPT in $NETSTUFF; do
/etc/init.d/$SCRIPT start
done |
|
Back to top |
|
|
|