# problems with network setup scripts

## _Max_

Hi,

I just installed Gentoo and am having problems with the network setup scripts - when I setup eth0 manually it seems to work fine ...?

I get the following messages on boot:

```

* Bringing eth0 up...

*    Setting default gateway

SIOCADDRT: Network is unreachable

* Failed to bring eth0 up

* Bringing eth0 down

* ERROR: Problem starting needed services

               "netmount" was not started

```

Once I login, the network doesn't work. When I set it up manually with 

```
ifconfig eth0 $MYIP broadcast $MYBC netmask $MYNM
```

and

```
/sbin/route add -net default gw $MYGW netmask 0.0.0.0 metric 1
```

, it seems to work just fine.

My /etc/conf.d/net file:

```
iface_eth0="$MYIP broadcast $MYBC netmask $MYNM"

gateway="eth0/$MYGW"
```

When I run

```
rc-update add net.eth0 default
```

I get no errors.

Any ideas of what might be going on? Where do I start looking?

Thanks,

_Max_

PS: I am using 1.4_rc3, built from stage 1

----------

## gilesjuk

Are $MYIP etc... set to anything?

It's simpler IMHO just to stick the values in the config file. If they're static then there's no need to store the values in env variables.

----------

## pjp

Moved from Installing Gentoo.

----------

## _Max_

Sorry, I should have been clear about that. I am not using variables and I did not actually write $MYIP in the config file but something like

192.16.0.192

and so on (255.255.240.0 for the network mask etc)

The above is not my real IP   :Wink:  - I would be a little bit uneasy about publicizing it in a forum.

Again, when I do the same thing with ifconfig (ifconfig eth0 192.16.0.192 ... etc, i.e. with real numbers, not variables), the connection is fine.

----------

## Sven Vermeulen

Perhaps the module of your networkcard isn't loaded yet when the net.eth0 initscript is started?

After logging in, does /etc/init.d/net.eth0 start work?

----------

## _Max_

I compiled that into the kernel. (CONFIG_E1000=y - I am using the integrated Intel Pro 1000 card). So I don't think there should be an issue of when I load it, right? (I am still new to Linux - tell me if I am wrong)

It does tell me '*Bringing eth0 up...' etc as described above when I boot, so the script is executed.

In fact, when I execute it manually (after I have already set up the connection manually using ifconfig - ping www.google.com works fine)

/etc/init.d/net.eth0 restart

I get:

* Bringing eth0 up...

*   Setting default gateway...

SIOCADDRT: Network is unreachable

* Failed to bring eth0 up

Could it be to do with the variables in the script? When I type

echo $IFACE

I just get an empty line.

Hmm....

----------

## Noneroy

I am having the same problem, but I can run dhcpcd and it will lease an IP address, so I dont think its an issue of it working because you assign a static. Once I issue 'ifconfig eth0' everything. But once I lease an IP address and try to bring up samba I get this error again and then my eth0 becomes unconfigured and I have to run dhcpcd to get an IP and get online.

----------

## EnricoHorn

Hi,

is $MYGW really reachable through eth0?

What happens, if you do a

```
/sbin/route add default gw $MYGW dev eth0 netmask 0.0.0.0 metric 1
```

(thats what the startup script does!)

On a firewall Im administrating I had the same problem. The solution was:

I specified the wrong IP-Adress for the default gateway (instead aaa.bbb.ccc.ddd i wrote aaa.ccc.bbb.ddd in /etc/conf.d/net)  :Embarassed: 

----------

## _Max_

After poking around a little bit and not finding the root of the problem, I gave up and reinstalled everything (well, the network script was not the only reason I reinstalled. I did manage unmerge my glibc as well...  :Embarassed:  don't ask...)

This is as far as I got, for what it's worth: I checked the net.eth0 script and found that the following line was the problem:

```

/sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \

                        netmask 0.0.0.0 metric 1 >/dev/null

```

All the variables were substituted fine, but for some reason, 'route' didn't like the syntax. When I did

```

/sbin/route add default gw somenumber dev eth0 netmask 0.0.0.0 metric 1 >/dev/null

```

it didn't work (somenumber replaced by the appropriate IP). When I did 

```

/sbin/route add -net default gw somenumber netmask 0.0.0.0 metric 1

```

it did. I checked the `route' man page, and the syntax in the script should have worked. It does now, on my fresh install. Go figure...

----------

## MyZelF

Well, I'm having the same problem since yesterday, when I upgraded sys-apps/baselayout... any suggestion?

----------

## MyZelF

I solved my problem, that wasn't due to a baselayout bug. I use a trivial self-made shell script to link /etc/conf.d/net to my actual network configuration, and after emerging baselayout the link was broken.

----------

