LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 01-06-2004, 11:23 PM   #1
TheSwine
Member
 
Registered: Dec 2003
Location: London
Distribution: Debian
Posts: 34

Rep: Reputation: 15
Disabling DHCP on laptop boot.


Hi,

When my laptop is unpluged to the network, it take DHCP client about a minute, before it gives up trying to connect the server. This delays my boot time in additional minute.

Is there a way to select DHCP yes/no when linux boot?

Thanks.
 
Old 01-06-2004, 11:25 PM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 143Reputation: 143
It varys from distro to distro. What are you running?
 
Old 01-06-2004, 11:43 PM   #3
TheSwine
Member
 
Registered: Dec 2003
Location: London
Distribution: Debian
Posts: 34

Original Poster
Rep: Reputation: 15
It says under my user name: Debian.
 
Old 01-07-2004, 01:03 AM   #4
balaji2001com
Member
 
Registered: Jun 2003
Location: Chennai,India
Distribution: Almost all the flavours of linux
Posts: 39

Rep: Reputation: 15
Go to the /etc/sysconfig/network-scripts/ifcfg-eth0 and change the dhcp to static.Then try restarting the network.Get back if this works.

Good luck.
 
Old 01-07-2004, 05:48 AM   #5
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 143Reputation: 143
Debian doesn't use that network config file. I'm not sure how to do it in debian, but I believe the corresponding config file for debian is /etc/network/interfaces. The syntax is different than ifcfg-eth0 and I'm not sure how to edit it. However, you don't want to set it to static. You may try posting on the debian forum; I'm sure someone there can help you.
 
Old 01-07-2004, 06:31 AM   #6
cdlen
Member
 
Registered: Oct 2003
Location: EU
Distribution: RH7.2 Mdk9.2
Posts: 39

Rep: Reputation: 15
dhcp is run as a daemon; you can shut it down like any daemon
(on RH : /etc/rc.d/init.d/dhcpd stop
or /sbin/service dhcpd stop )
That's for the current session, to make that permanent use chkconfig (or an equivalent graphical tool like SysV-Init Editor on RH).
I would suggest setting dhcpd off permanently and when needed re-start it for the session only using the service command..
 
Old 01-07-2004, 07:33 AM   #7
leckie
Member
 
Registered: Dec 2003
Location: Australia
Distribution: Mandrake 9.2
Posts: 151

Rep: Reputation: 30
man don't u wish more people knew what they were talking about.
to cdlen dhcp is a client and cannot be shut down.

kilgoretrout is spot on with the file location. and the file is almost the same as an ifcfg file except all interfaces are in the same file.


There should be a line reading onboot=

change that to no and all should be good.

like kilgoretrout debian is not my native distro, and i am not 100% sure if that line exists.

if not try and add it.
 
Old 01-07-2004, 10:42 AM   #8
computergeek84
Member
 
Registered: Nov 2003
Location: /dev/null
Distribution: Gentoo, Ubuntu
Posts: 61

Rep: Reputation: 15
No, there's no line that says onboot in /etc/network/interfaces . Assuming eth0 is your interface, change line

iface eth0 inet dhcp

to

iface eth0 inet static


and then add this line directly under it, replacing the x's with your IP:

address x.x.x.x
 
Old 01-07-2004, 11:12 AM   #9
TheSwine
Member
 
Registered: Dec 2003
Location: London
Distribution: Debian
Posts: 34

Original Poster
Rep: Reputation: 15
Hmmm... Sorry, my fault... didn't explain myself well enough:

I'm using my laptop in three different places (home, work, university) where I use DHCP-client to configure my network; this DHCP-client runs when Linux load. Yet, in other places I have no network at all - when linux load in these places I need to wait a minute for the DHCP-client to fail.

My ideal solution would be to have sort of a startup menu (before Linux starts) where I can choose between loading linux with network, or without network. My guess was that this should be done by passing parameter to the kernel before it load (using GRUB in my case).

I know about 'static' and 'dhcp' in interfaces (Debian, by the way, don't have /etc/sysconfig), but these are permanent changes. I wan't to be able to determine wheter or not using dhcp before linux loads, and not after.

I hope this is clearer now...
any suggestions?
 
Old 01-07-2004, 01:16 PM   #10
dubman
Member
 
Registered: Jan 2003
Distribution: Redhat 9, Fedora Core 1, Suse 8
Posts: 188

Rep: Reputation: 30
First, in your /etc/sysconfig/network-scripts/ifcfg-eth0, make ytour file read this:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=NO

this will stop eth0 from coming up during boot

then add something like this to your /etc/rc.local:

read -p "Do you want to enable dhcp? [y,n]" enable_dhcp

if [ var1 -eq "y" ]; then
ifup eth0
fi

this way it will only bring up eth0 if you type in "y" when prompted at boot. eth0 will never attemp to come up untill rc.local runs, which is the last process that runs during boot.

this should solve your problem.
 
Old 01-07-2004, 01:17 PM   #11
dubman
Member
 
Registered: Jan 2003
Distribution: Redhat 9, Fedora Core 1, Suse 8
Posts: 188

Rep: Reputation: 30
sorry, this is what rc.local should say:

read -p "Do you want to enable dhcp? [y,n]" enable_dhcp

if [ enable_dhcp -eq "y" ]; then
ifup eth0
fi
 
Old 01-07-2004, 01:47 PM   #12
computergeek84
Member
 
Registered: Nov 2003
Location: /dev/null
Distribution: Gentoo, Ubuntu
Posts: 61

Rep: Reputation: 15
There are at least two problems with your script, dubman:

1. Debian doesn't have the /etc/sysconfig directory, and it does NOT have an ifcfg-eth0 file (read the above posts!!!!!)!

2. Your script doesn't take into account if he wants a static IP on boot. It just leaves eth0 disabled otherwise.


It *might* work (don't hold me to this if I'm wrong) to have another copy of /etc/network/interfaces (you could call it /etc/network/interfaces.static or something similar) and go into rc.local and find where it references /etc/network/interfaces . You could then add something like the above if statement, except you'd also need an else statement (I'm not that familiar with shellscript, just C/C++).
 
Old 01-07-2004, 02:02 PM   #13
dubman
Member
 
Registered: Jan 2003
Distribution: Redhat 9, Fedora Core 1, Suse 8
Posts: 188

Rep: Reputation: 30
There are at least two problems with your script, dubman:

1. Yes, I realize this. Just trying to give some ideas as to how this issue can be solved with some simple shell scripting.

2. my mistake, script should read as follows:

read -p "Do you want to enable dhcp? [y,n]" enable_dhcp
if [ $enable_dhcp -eq "y" ]; then
ifup eth0
elif [ $enable_dhcp eq n ]; then;
read p Do you want to set a static IP Address? [y,n] enable_static
if [ $enable_static eq y ]; then
read p What IP address would you like to set? ipaddress
ifconfig eth0 $ipaddress
fi

I could go even further to error check the input, and prompt for the interface, etc, but I think the idea is clear.

Having multiple profiles could work also but, I think a simple shell script is easier than moving and copying files around, and you would still need an ifup once the profiles are copied.
 
Old 01-07-2004, 05:20 PM   #14
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 143Reputation: 143
Don't know if this will work but here's something simple you can try. Edit your /etc/network/interfaces file by commenting out the eth0 line. You do this by putting a "#" in front of the line. That should stop the network from coming up on boot.

When you plug into the network, you might be able to bring it up by running:

# ifup eth0

Try it; if it works fine, if not uncomment the line to be back where you started.
 
Old 01-07-2004, 06:22 PM   #15
cdlen
Member
 
Registered: Oct 2003
Location: EU
Distribution: RH7.2 Mdk9.2
Posts: 39

Rep: Reputation: 15
My mistake ! On my old gear dhcpcd, the client part of dhcp , is run like a daemon (daemons are not necessarily network servers !). But i admit that my solution was rather naive since the script had already started the daemon ,you can only shut it down.
I think that everything must be attempted before seducing people into messing their startup scripts up.
As i can gather dhcp-client uses dhclient.conf as config file.
There are several ways to tweak how the client is started (check the dhclient man pages). At, http://www.risc.uni-linz.ac.at/syste...g/index_3.html
i found an interesting idea :
set first timeout very low to speed booting up
but use a retry after a long delay

I'm no expert in these matters , you could go to the linux-debian-laptop newsgrp . There is also a dhcp client newsgroup!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Password when opening Laptop Lid 300_baud Suse/Novell 3 10-13-2005 07:49 AM
Disabling APM on older laptop litlmary Linux - Laptop and Netbook 2 06-08-2005 09:18 PM
Disabling DHCP gatamah Linux - Networking 7 11-04-2004 12:19 AM
dhcp server will not connect to laptop after laptop OS upgrade phamnewan Linux - Networking 0 06-21-2003 11:47 AM
Disabling DHCP Yohhan Linux - Networking 3 12-21-2002 07:27 PM


All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration