From owner-freebsd-questions@FreeBSD.ORG Fri Aug 12 18:32:29 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4E8F7106566B for ; Fri, 12 Aug 2011 18:32:29 +0000 (UTC) (envelope-from cjr@cruwe.de) Received: from cruwe.de (cruwe.de [188.40.164.98]) by mx1.freebsd.org (Postfix) with ESMTP id D2F488FC0C for ; Fri, 12 Aug 2011 18:32:28 +0000 (UTC) Received: from cruwe.de (unknown [127.0.0.4]) by cruwe.de (Postfix) with ESMTP id 8A2E9221EF for ; Fri, 12 Aug 2011 20:32:23 +0200 (CEST) Received: by cruwe.de (Postfix, from userid 65534) id 4E9BF221EA; Fri, 12 Aug 2011 20:32:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.cruwe.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.1 Received: from cruwe.de (p5B37A314.dip.t-dialin.net [91.55.163.20]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cruwe.de (Postfix) with ESMTPSA id 6B7EA221E1; Fri, 12 Aug 2011 20:32:14 +0200 (CEST) Date: Fri, 12 Aug 2011 20:32:04 +0200 From: "Christopher J. Ruwe" To: dave jones Message-Id: <20110812203204.931270c4.cjr@cruwe.de> In-Reply-To: References: <20110727223034.0c0f0c8d@dijkstra> X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; amd64-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: ClamAV on mail.cruwe.de using ClamSMTP Cc: "freebsd-questions@freebsd.org" Subject: Re: How to get ip address automatically from different dhcp server X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 18:32:29 -0000 On Fri, 12 Aug 2011 11:46:34 +0800 dave jones wrote: I rearrange your mail and post bottom to enable others to have a look. >On Thu, Jul 28, 2011 at 4:30 AM, Christopher J. Ruwe wrote: >> On Wed, 27 Jul 2011 10:49:42 +0800 >> dave jones wrote: >> >>> Hi, >>> >>> I cat get an IP address from dhcp server by adding the line >>> in /etc/rc.conf: >>> >>> ifconfig_em0=3D"DHCP" >>> >>> If I move my laptop to another place, I have to manually run >>> "dhclient em0" to get an IP. Otherwise, it won't get an IP >>> automatically. >>> >>> My question is it's possible to get ip address automatically from >>> different dhcp server? thanks. >>> >>> Regards, >>> Dave. >>> _______________________________________________ >>> freebsd-questions@freebsd.org mailing list >>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >>> To unsubscribe, send any mail to >>> "freebsd-questions-unsubscribe@freebsd.org" >> >> Have a look at /etc/devd.conf. Mine include a portion >> >> # >> # Try to start dhclient on Ethernet like interfaces when the link comes >> # up. =A0Only devices that are configured to support DHCP will actually >> # run it. =A0No link down rule exists because dhclient automaticly exits >> # when the link goes down. >> # >> notify 0 { >> =A0 =A0 =A0 =A0match "system" =A0 =A0 =A0 =A0 =A0"IFNET"; >> =A0 =A0 =A0 =A0match "type" =A0 =A0 =A0 =A0 =A0 =A0"LINK_UP"; >> =A0 =A0 =A0 =A0media-type =A0 =A0 =A0 =A0 =A0 =A0 =A0"ethernet"; >> =A0 =A0 =A0 =A0action "/etc/rc.d/dhclient quietstart $subsystem"; >> }; >> # >> notify 0 { >> =A0 =A0 =A0 =A0match "system" =A0 =A0 =A0 =A0 =A0"IFNET"; >> =A0 =A0 =A0 =A0match "type" =A0 =A0 =A0 =A0 =A0 =A0"LINK_DOWN"; >> =A0 =A0 =A0 =A0media-type =A0 =A0 =A0 =A0 =A0 =A0 =A0"ethernet"; >> =A0 =A0 =A0 =A0action "/etc/rc.d/dhclient quietstop $subsystem ; ifconfi= g $subsystem inet 0.0.0.0"; >> }; >> >> I am under the impression that this rule does what you want to do. >> >> Cheers, >> -- >> Christopher J. Ruwe >> TZ GMT + 2 >> > Hi Christopher, >=20 > Thanks for your solution. It does help a lot, but there's one problem. > For example, DHCP server is not started for some reason and my computer's > ethernet cable is plugged. Once dhcp server started, I can't get the IP u= nless > I unplug and then plug the ethernet cable. Do you know how to solve > this issue? Thank you. >=20 > Regards, > Dave. >=20 Ok. To check whether I understand what you are saying: Your computer is run= ning, but an external DHCP-server is not. Your computer tries to get an IP = from the external DHCP server, which is down, so dhclient is unsuccessful. = You then kick the DHCP-server back to live and then you have to plug in and= out to get an IP? Assuming I understand correctly, that is exactly what should happen. You se= e, normally DHCP-servers don't flood the network with "Hello all dhclients,= I am dhcp-server, please tell me if you need an IP", usually the opposite = direction is in order as in "hello dhcp-server, I am dhclient, I need an IP= , please give me one".=20 You now have two options: 1) You coerce a manual request be running dhclien= t. 2) You plug in and out, which runs dhclient as you have configured to do= so in your devd.conf. Of course you can set the retry-time for dhclient (see `man dhclient`) to a= n absurldly low threshold, so you are saved doing the dhcp-discover-procedu= re manually. It is, however, dubious, whether you want to do so. It might b= e a smarter way to fix that DHCP-server of yours. Hope to have been of some help here,=20 cheers --=20 Christopher J. Ruwe TZ GMT + 2