# [solved] Network configurations ignored in /etc/conf.d/net

## dezydery

After setting up a server today I experienced a really odd problem with /etc/conf.d/net - it won't recognise any static IP configurations and always drops back to DHCP:

```
Configuration not set for eth0 - assuming dhcp
```

 - same happens for eth1.

Both NICs are identical, and support is compiled into the kernel.

Initial setup was done in an environment where a DHCP server is available, but in production the machine won't have DHCP, all static config.

Both NICs can pick up an IP from the DHCP server and access the Internet (even when I don't want this!)

Both NICs can be configured manually, like this:

```
ifconfig eth0 10.10.10.10 netmask 255.255.255.0
```

When configured as above, I can ping/SSH to/from the machine on that IP. So I'm fairly sure it's not a kernel problem - it seems to be the init script or my config file. I've tried a few combinations, for example:

```
iface_eth0="10.10.10.10 netmask 255.255.255.0"
```

also tried:

```
config_eth0=( "10.10.10.10 netmask 255.255.255.0 broadcast 10.10.10.255" )
```

Whatever I try always gives me the config message (above) about dropping back to DHCP. However, I'm fairly sure the config file is being read on some level:

```
# echo "aaaa" >> /etc/conf.d/net

# /etc/init.d/net.eth1 start
```

gives me the error in the output:

```
/etc/conf.d/net: line 10: aaaa: command not found
```

(actually I get this 4 times)

Until this point, /etc/init.d/net.eth0 (and 1) were symlinked to net.lo. In an attempt to work around/investigate the problem I've made net.eth0 a copy instead, and done this:

Find this section:

```
# New style config - one variable fits all

eval config=( \"\$\{config_${ifvar}\[@\]\}\" )

eval fallback=( \"\$\{fallback_${ifvar}\[@\]\}\" )

eval fallback_route=( \"\$\{fallback_route_${ifvar}\[@\]\}\" )
```

Immediately after, add:

```
config="10.10.10.10 netmask 255.255.255.0"
```

This now "works" - /etc/init.net/net.eth0 brings up the IP address fine; however any resemblance to a proper solution is purely coincidental (no need to go into some obvious limitations here).

So, why is my config not being picked up? (When I test it on my local machine I don't have the same problem).Last edited by dezydery on Fri May 05, 2006 8:04 am; edited 1 time in total

----------

## overkll

Please post your /etc/conf.d/net file.

----------

## dezydery

Thanks for your help - I don't have access to the box right now but this was the only non-comment line in the file:

```
iface_eth0="172.25.5.73 netmask 255.255.254.0"
```

and later on that was commented out and replaced with:

```
config_eth0=( "172.25.5.73 netmask 255.255.254.0 broadcast 172.25.5.255" )
```

I can access the server again tomorrow if I need to post anything else...

----------

## overkll

The "iface_eth0" is the old baselayout syntax and the "config_eth0" is the current baselayout syntax.  Don't recall what the version number was when the change was made but if your system is up to date, then you should be using the "config_ethX" syntax.

I was able to replicate your error message by changing eth0 (eth-zero) to ethO (eth-uppercase oh).  AFAIK the fallback to dhcp behavior occurs when no configuration data can be found/correctly parsed.

Have you tried backing up the current /etc/conf.d/net file and creating one from scratch with only the necessary info?  Make sure there are no unexpected line breaks/returns.  Nano in wrap mode can do that to ya.

----------

## dezydery

I'm fairly sure it wasn't a capital O because I had also tried getting eth1 working at one point, with the same problem... but yeah it's useful to know how it behaves.

Sorry to be annoying but I'll be away (with no net access) until end of next week, but I'll definitely try your suggestion when I return and make a completely new file - I appreciate your trying to help.

----------

## dezydery

OK I'm back, and I have remote access to the machine. I'm using eth1 for testing, and /etc/init.d/net.eth1 is linked to the unmodified net.lo script.

I've done as you suggested, completely re-created the file /etc/conf.d/net (while saving a copy of the original), and here are the contents copied & pasted:

```
iface_eth0="172.25.5.73 broadcast 172.25.5.255 netmask 255.255.254.0"

gateway="eth0/172.25.5.254"

iface_eth1="10.10.10.1"
```

If I try to start net.eth1 I get this (as there's no DHCP server available now):

```
# /etc/init.d/net.eth1 start

 * Starting eth1

 *   Bringing up eth1

 *     Configuration not set for eth1 - assuming dhcp

 *     dhcp

 *       Running dhcpcd ...               [ !! ]
```

BTW here's what emerge -pv baselayout says:

```
[ebuild   R   ] sys-apps/baselayout-1.11.14-r8  -bootstrap -build -static -unicode 0 kB
```

(I did once rebuild baselayout but it didn't make any difference)

----------

## overkll

You're still using the "old" syntax.  The new baselayout can't parse the old syntax so the behavior defaults to DHCP.  Try:

```
config_eth0=( "172.25.5.73 brd 172.25.5.255 netmask 255.255.254.0" )

routes_eth0=( "default via 172.25.5.254" )

config_eth1=( "10.10.10.1 brd ???.???.???.??? netmask ???.???.???.???" )

routes_eth1=( "default via ???.???.???.???" )
```

Of course you'll need to replace the question marks for the correct IP's.  And I'm assuming these are 2 PHYSICAL interfaces, not one PHYSICAL and one VIRTUAL interface.

Take a gander at /etc/conf.d/net.example for the new syntax and examples.

Hope this helps.

----------

## dezydery

I've changed it to the new config as you suggested, checked it several times and used exactly the same spacing. The file has been newly created again... unfortunately, I get exactly the same error as above (it drops back to DHCP).

Again I've tried to look in the init script and determine what's going wrong, but unfortunately I'm very unfamiliar with these scripts. What I've found is just bizarre. If I add these lines to just before where I had the hack above:

```
echo $config_eth1

eval echo \"\$\{config_${ifvar}\[@\]\}\"
```

This works fine on my desktop machine (echos out the contents of the variables defined in the config file), but just echos out blank lines from the problem server. It really doesn't pick up variables from that config file!

Yet, this command works just fine to start networking (don't need a default gw on eth1, it's just for test):

```
config_eth1="10.10.10.1 brd 255.255.255.0 netmask 255.255.255.0" /etc/init.d/net.eth1 start
```

So the script can get variables, just not from the config file.

Edit: After looking at the /etc/init.d/net.eth1 script again, I've found what looks like the entry point - the run() function - and put the above echo commands there too. As before, this works on my desktop box but not on the server. I don't know what /sbin/runscript does or what pulls in /etc/conf.d/net.

----------

## dezydery

Doh!

This is now solved. There is either a flaw in my working practices, or in the way Gentoo's config scripts work, or both.

Solution:

```
rm /etc/conf.d/net.default
```

Basically, I had decided to be neat and get into the habit of backing up the original config files to config-name.default before making any changes (and later changes I back up to config-name~). 

Unfortunately, it looks like .default has a special meaning in the conf.d directory and the settings (or lack of) in /etc/conf.d/net.default are overriding those in /etc/conf.d/net, even though I proved the latter was being read. Just had a quick look around for documentation on this and can't find any - I will use another extension in future for saving original files!

Anyway thanks for all the patient help & suggestions with this problem, much appreciated.  :Smile: 

----------

## overkll

Didn't know about the net.default file.  ".bak" or ".orig" are good backup extensions.

Glad you figured it out.

----------

## oktal

Gah, I've just been bitten by this apparently undocumented behaviour too.

Many thanks for figuring it out!

----------

