# hostname and startx very slow

## ajg112

Hi All,

I have a new and up-to-date installation of Gentoo. However, I am finding that startx is a lot slower to start with the PC's network cable disconnected. After some googling this seems to be related to domain/hostname lookup.

Sure enough, with the network cable plugged in hostname -f returns very quickly. When the cable is unplugged there is a delay, but it does eventually return with the same response.

Here is the contents of /etc/hosts:

```
127.0.0.1       onion.allotment onion localhost.localdomain localhost
```

/etc/conf.d/net:

```
config_eth0="192.168.1.35 netmask 255.255.255.0 brd 192.168.1.255"

routes_eth0="default via 192.168.1.5"

dns_servers_eth0="192.168.1.5"
```

/etc/resolv.conf

```
nameserver 192.168.1.5
```

/etc/hosts.conf

```
order hosts, bind

multi off
```

hostname -f returns

```
onion.allotment
```

Does anyone know how I can stop this delay when the network cable is disconnected? I've noticed that if I remove the nameserver line from /etc/resolv.conf then hostname -f returns successfully and quickly with and without the cable. However, this of course stops any other name lookups!

The PC's ip address is 192.168.1.35. My router is 192.168.1.5

The PC is running mythtv, so I want to reduce to time from switch on to the X frontend starting as much as possible.

Many thanks

Andy

----------

## BillWho

ajg112,

I'm not sure if this is what you're looking for, but what about a preup function in /etc/conf.d/net to check if eth0 has a link or not.

I use that method to connect wired if I have I have eth0 connected otherwise it connects with the usb wireless adapter.

Another avenue you can pursue is a runlevel for offline use.

Good luck   :Wink: 

----------

## krinn

 *ajg112 wrote:*   

> 
> 
> Here is the contents of /etc/hosts:
> 
> ```
> ...

 

Change it to this format, if a program see that onion.allotmen is going down, the 127.0.0.1 entry might be invalidate as it point to onion.allotmen, something unplugging a cable might do.

----------

## ajg112

BillWho, thanks for the suggestions, but I'd hoped there would be a simpler solution; I can't help but think I've just got something simple missing in a config file somewhere!

krinn, I tried your suggestion, but it made no difference. I've tried a number of different entries in /etc/hosts, but none have sorted the problem.

Surely this must be a common problem? My setup sounds very common; a single machine connected to an ADSL router. What is frustrating is that I'm sure I didn't see this problem with my old Gentoo installation (from about 2 years ago).

Any other suggestions anyone?

Thanks

Andy

----------

## dansou90

What differences are there between your old Gentoo installation and the new one?

----------

## ajg112

My old installation was from about 3 years ago! 

I think the major difference to my updated system is the introduction of baselayout 2 and openRC.

Andy

----------

## dansou90

When I said difference to your old installation, I meant the network configuration differences.

But another question: Doesn't your router provide DHCP? Why do you use a static ip? It's much easier with DHCP, just set it in /etc/conf.d/net. Also, try this in your /etc/hosts:

```
127.0.0.1 localhost.localdomain localhost

127.0.0.1 onion.allotment onion
```

This is a bit like my own configuration, though I do not set the domain in my /etc/hosts. Hope this helps.

----------

