Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Choosing IP address at startup
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
marce
n00b
n00b


Joined: 09 Jul 2002
Posts: 21

PostPosted: Thu Jun 05, 2003 7:02 am    Post subject: Choosing IP address at startup Reply with quote

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 :D

(if this post belongs to a different forum please accept my apologies)
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20552

PostPosted: Thu Jun 05, 2003 5:20 pm    Post subject: Reply with quote

Moved from Documentation, Tips & Tricks.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
mfairchi
n00b
n00b


Joined: 23 Apr 2002
Posts: 57
Location: Ventura, California

PostPosted: Fri Jun 06, 2003 6:45 am    Post subject: Reply with quote

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
View user's profile Send private message
bsolar
Bodhisattva
Bodhisattva


Joined: 12 Jan 2003
Posts: 2764

PostPosted: Fri Jun 06, 2003 6:48 am    Post subject: Reply with quote

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. :wink:
_________________
I may not agree with what you say, but I'll defend to the death your right to say it.
Back to top
View user's profile Send private message
Rocker
n00b
n00b


Joined: 12 Dec 2002
Posts: 67
Location: The Netherlands

PostPosted: Fri Jun 06, 2003 7:03 am    Post subject: Reply with quote

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
View user's profile Send private message
uzik
Apprentice
Apprentice


Joined: 17 Apr 2003
Posts: 257

PostPosted: Fri Jun 06, 2003 9:54 pm    Post subject: Re: Choosing IP address at startup Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum