# Server will not connect to internet, defaultgw: Unknown host

## shgadwa

I have a very weird problem here.

I just installed Gentoo Hardened on a computer. I intend to use it as a squid server/internal DNS server/apache server... server. But right now, it will not connect to the internet. Everything goes fine when I start net.eth0 until it gets to the "adding routes" part... then it gives me this error, defaultgw: Unknown host. What happens is it acts like its online and I can ping the router as well as any computer on the network but I cannot ping a external IP address or a website.

I talked to a bunch of people in the #gentoo chat room (on freenode) but they could not help me. 

Here is my /etc/conf.d/net:

```
config_eth0=( "192.168.254.4 netmask 255.255.255.0 brd 192.168.254.255" )

routes_eth0=( "default via 192.168.254.254" )
```

The only way to get it to work, that I know of, is to manually add a route to the router. But I don't want to do that every time I need to reboot.

Any help would be greatly appreciated.

----------

## NeddySeagoon

belikeyeshua,

Please post the output of route

----------

## shgadwa

```
squid ~ # route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.254.0   *               255.255.255.0   U     0      0        0 eth0

loopback        *               255.0.0.0       U     0      0        0 lo
```

----------

## shgadwa

Another question:

Why does it read defaultgw and not default gw as it ought to read?

----------

## NeddySeagoon

belikeyeshua,

Your routing table shows you are missing a default route.

```
$ /sbin/route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.100.0   *               255.255.255.0   U     0      0        0 eth0

192.168.10.0    bloodnoc        255.255.255.0   UG    2      0        0 eth0

loopback        localhost.local 255.0.0.0       UG    0      0        0 lo

default         bloodnoc        0.0.0.0         UG    2      0        0 eth0

roy@NeddySeagoon ~ $ /sbin/route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

192.168.10.0    192.168.100.1   255.255.255.0   UG    2      0        0 eth0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

0.0.0.0         192.168.100.1   0.0.0.0         UG    2      0        0 eth0

```

What does 

```
emerge baselayout -vp
```

show?

My /etc/conf.d/net contains 

```
config_eth0="192.168.100.20/24 brd 192.168.100.255"

routes_eth0="default via 192.168.100.1

             192.168.10.0/24 via 192.168.100.1"
```

but I have baselayout-2, the syntax for baselayout-1 is different.

I was half expecting you to have two default routes - but thats clearly not the case here.

You could try 

```
routes_eth0=( "default gw 192.168.254.254" )
```

both used to work. It may change your error message, which might help.

----------

## shgadwa

 *Quote:*   

> 
> 
> What does
> 
> Code:
> ...

 

It shows that I have baselayout 1.12.13

Using default gw allows me to start eth0 without errors but its obviously not working as I cannot ping the router or a website.

----------

## NeddySeagoon

belikeyeshua,

Thats odd as the router is in the same subnet as you own PC, so no default route is required.

```
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.254.0   *               255.255.255.0   U     0      0        0 eth0 
```

is provided as a result of your 

```
config_eth0=( "192.168.254.4 netmask 255.255.255.0 brd 192.168.254.255" ) 
```

so you should be able to ping the router properly.

What does route show when you use gw instead of via?

----------

## shgadwa

using default gw instead of defaultvia does change the output of the route command. It shows a default gateway of 192.168.254.254 whereas before it did not. However, it still does not work.

Also, I found out... I am not able to ping the router or any other device on the network, or the web for that matter. At one time I could, but right now I can't. And you'd think its supposed to just work... but its not. And that makes me think that there must be more wrong with this computer than just the route table. 

Huh. Do you think maybe the NIC might be bad??Last edited by shgadwa on Sun Aug 08, 2010 8:57 pm; edited 1 time in total

----------

## NeddySeagoon

belikeyeshua,

Try the cable first, if you have a laptop, connect it in place of the server.

If that works, swap the NIC.

----------

