Date: Sun, 14 Aug 2011 15:35:21 +0800 From: dave jones <s.dave.jones@gmail.com> To: "Christopher J. Ruwe" <cjr@cruwe.de> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: How to get ip address automatically from different dhcp server Message-ID: <CANf5e8atq2-L578vo8uu_n=S0b_9%2BaaeCa3bafze-bQv50NJ%2BQ@mail.gmail.com> In-Reply-To: <20110812203204.931270c4.cjr@cruwe.de> References: <CANf5e8ZtkdWZhM6f=MeWv6%2BmNJOZ75jjox28Ss7L9RWpGNG3=g@mail.gmail.com> <20110727223034.0c0f0c8d@dijkstra> <CANf5e8bHvznRJmZ=j0T3gJ3jdf3=piUdCNSOvQx4DgQ-ukYJTA@mail.gmail.com> <20110812203204.931270c4.cjr@cruwe.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Aug 13, 2011 at 2:32 AM, Christopher J. Ruwe wrote: > On Fri, 12 Aug 2011 11:46:34 +0800 > dave jones <s.dave.jones@gmail.com> 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 =A0wrote: >>> On Wed, 27 Jul 2011 10:49:42 +0800 >>> dave jones <s.dave.jones@gmail.com> 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 exit= s >>> # 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 ; ifconf= ig $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, >> >> 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 = unless >> I unplug and then plug the ethernet cable. Do you know how to solve >> this issue? Thank you. >> >> Regards, >> Dave. >> > > Ok. To check whether I understand what you are saying: Your computer is r= unning, but an external DHCP-server is not. Your computer tries to get an I= P 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 a= nd out to get an IP? Right. I'm sorry for the confusion. > Assuming I understand correctly, that is exactly what should happen. You = see, normally DHCP-servers don't flood the network with "Hello all dhclient= s, I am dhcp-server, please tell me if you need an IP", usually the opposit= e direction is in order as in "hello dhcp-server, I am dhclient, I need an = IP, please give me one". > You now have two options: 1) You coerce a manual request be running dhcli= ent. 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= an absurldly low threshold, so you are saved doing the dhcp-discover-proce= dure manually. It is, however, dubious, whether you want to do so. It might= be a smarter way to fix that DHCP-server of yours. Thank you for the clear explanation. I will add "retry 10" in dhclient.conf and give it a try. I'm wondering if net/ifstated will work in this case. I'll give it a shot as well. Thanks again! > Hope to have been of some help here, > cheers > -- > Christopher J. Ruwe > TZ GMT + 2 > Regards, Dave.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANf5e8atq2-L578vo8uu_n=S0b_9%2BaaeCa3bafze-bQv50NJ%2BQ>