[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: DHCP and hostname

Thanks for all of you who have helped me.  I solved the hostname problem
by using the "-c commandfile" option in the "dhcpc" init script in
/etc/init.d.  Now if I can make the rest of the init scripts (particularly
xdm) wait for the hostname to be set (it takes the DHCP server about 15
seconds to complete the IP assignment) then I will be set.


On Wed, 29 Jul 1998, Mark H. Mabry wrote:

>   Venkat> My linux machine is in a network where the IP addresses are
>   Venkat> assigned using DHCP.  I use "dhcpcd" to get the IP address
>   Venkat> but it also mangles my machine's hostname (probably because
>   Venkat> the DHCP server is not properly configured).  Is there a way
>   Venkat> to query the DNS server for the correct hostname from the
>   Venkat> assigned IP address and assign it?  Can this be automated?
>   Venkat> Thanks.
> Sorry for coming in late on this thread.  
> If I understand correctly, you want to update your hostname when DHCP
> gives you a (new) IP address.  Here is what I do:
>   1) In the dhcpcd call there is an option to execute a script after
> the IP address gets BOUND.  Add that option to your call, in
> /etc/init.d/dhcpcd, if it is not already there.  I don't remember the
> option, off hand.
>   2) In this script add a line that runs ifconfig and greps out your
> local IP address.  Then it takes that field and inserts it into
> /etc/hosts with sed.  I made a /etc/hosts.start that has my local IP
> address as "XXX".  Then I have the script run
>   sed -e "s/XXX/$new_ip/" /etc/hosts.start > /etc/hosts
>   3)  Make sure that /etc/hosts has your fully qualified pathname in
> it.  I have something like:
>    <IP addr>  foo.bar.com foo
> That should do it.  Pls note that I'm typing all of this from memory,
> so you should check everything.  All the concepts should be solid
> though.  
> Mark Mabry				Tel: (978)250-3344 x264   
> Avici Systems Inc.			Fax: (978)250-3377        
> 12 Elizabeth Dr.,			Email: mmabry@avici.com   
> Chelmsford,MA 01824			Web: http://www.avici.com/
> --  
> Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null

Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null

Reply to: