# SOLVED: Very strange hostname / DHCP issue

## James Wells

Greetings,

   I have recently begun having a strange problem on my laptop, when my system loses it's hostname entries after I start the wireless network.

   To test this, I have run various combinations of hostname -a, hostname -f, etc.   Before I bring up my wireless network, they all show the correct hostname and domainname combinations, however, after dhcp completes for my wireless device, all hostname entries fail.   This causes various other things to fail my syslog-ng, kdeinit, sendmail, and a few others.

   If I run /etc/init.d/hostname restart after dhcp completes for my wireless, everything works correctly, assuming that I haven't yet started any of the affected processes.

EDIT:   I got around the issue by commenting out lines 135 - 146 in dhcp-3.0.5_beta1's /sbin/dhclient-script.Last edited by James Wells on Sat Aug 19, 2006 2:33 am; edited 1 time in total

----------

## magic919

It's worth sticking your FQDN in the hosts file if you haven't already.

----------

## James Wells

Yup.  In my /etc/hosts file I have;

   127.0.0.1        <MyLaptop FQDN> <MyLaptop> localhost.localdomain localhost

Something else I just noticed is that when I run DHCP at home, I get the same host as I have configured in my /etc/hosts so I have not issues there.   Is there a way to tell dhcp not to set the hostname?   I can see there is an option not to send the hostname, but I see nothing about not setting the hostname.

----------

## UberLord

Depends on which dhcp client you use. So which one is it?

----------

## OldTango

I need some assistance getting my network working properly again after a world update.  

I am using dhcpcd for eth0 on the server to get an IP form my ISP and using DHCP (via eth1) to assign IP's automatically to the machines on the lan which are using dhcpcd to get their IP's

When I reboot the server I get a message telling me I need to update my /etc/conf.d/net file because I am using old style syntax.  After reading the net.example file and changing some settings I can get eth0 to come up and get and IP but still get this errror message.  Eth0 now comes up and gets an IP (via DHCP).  DHCP fails to run (no error message) and eth1 comes up but dosen't get an IP.

Before my clients on the lan can use the internet or connect to the server I have to manually run

```
 ifconfig eth1 192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0 up
```

 every time.

I followed this little how-to http://www.gentoo.org/doc/en/home-router-howto.xml a couple of years ago to help set up my server but never used the built-in dhcp server in dnsmasq because I had installed DHCP and it was working just fine untill recently.

However things in gentoo have changed recently and now I need to deal with these error messages and get my server working correctly again.

TIA

----------

## UberLord

Alas my crystal ball has broken, but I suspect you are getting that message as you're still trying to use an old var such as gateway or iface_eth0

----------

## magic919

Did someone remove the New Topic button??

----------

## James Wells

 *UberLord wrote:*   

> Depends on which dhcp client you use. So which one is it?

 

   Using dhcp-3.0.5_beta1.

   Anyway, I found what was causing the issue, though I am unsure whether this is intentional or accidental.  In /sbin/dhclient-script, around line 135, the client script checks to see if the current hostname is different from the dhcp assigned name.  If they are different, then it sets the hostname to the dhcp assigned name.    While I can see where this would be valuable, I think it would be even better if there was a way to disable this, short of commenting the offending lines out as I have done to get around the issue.

----------

## lbrtuk

From /etc/conf.d/net.example:

```
# GENERIC DHCP OPTIONS

# Set generic DHCP options like so

#dhcp_eth0="release nodns nontp nonis nogateway nosendhost"

# This tells the dhcp client to release it's lease when it stops, not to

# overwrite dns, ntp and nis settings, not to set a default route and not to

# send the current hostname to the dhcp server and when it starts.

# You can use any combination of the above options - the default is not to

# use any of them.
```

----------

## James Wells

The option you are showing, says to send or not to send the hostname to the DHCP server.  As I understand it, that option has no effect if the dhcp server sends a pre-generated name.   I should also point out that I already had the nosendhost option set and still had my hostname changed on me when I recieved a DHCP option host-name entry from the DHCP server.  The only time it doesn't change is when I am at home where my DHCP server sends the hostname that my laptop uses ayway.   :Wink: 

----------

## lbrtuk

I was more looking at the nodns entry. If the host settings your DHCP is sending you are breaking your connection, set nodns.

----------

