# [SOLVED] Can't autoconnect to wired net using NetworkManager

## sirlark

Hi all,

I run a desktop machine at home as a day-to-day work machine, media server etc. It is connected to my ADSL router by an ethernet cable, and both router and PC are always on. Previously, I used /etc/conf.d/net to configure and bring up my wired network device automatically during boot. But recently I installed NetworkManager mainly because it's the only thing I've ever to get my particular USB 3G modem working in Linux, and also becasue it's make turning the VPN to my office network on and off easy. Since I installed NetworkManager though, when the machine boots, it has an empty /etc/resolv.conf, with a single comment line saying the non-existent contents were set by dhcpcd. The NetworkManager try applet believes I'm connected, and indeed I can ping the router, but obviously DNS doesn't work. Only when I disconnect and reconnect does NetworkManager populate /etc/resolv.conf and then everything works. Also, I get some error messages during boot relating to /etc/conf.d/net, listed below; The eth0 connection is available to all users, and NetworkManager is in the default runlevel, so to my understanding eth1 should come up automatically should start automatically

The error messages on boot

```
/etc/init.d/../conf.d/net: line 7: default via 192.168.37.1: command not found

/etc/init.d/../conf.d/net: line 9: 192.168.37.2/24: No such file or directory
```

The file in question (/etc/conf.d/net)

```
#Generated by NetworkManager

###### Global Configuration ######

###### Connection Configuration ######

#----------------------------------

dns_servers_eth1="192.168.0.2 208.67.222.222 208.67.220.220"

routes_eth1= "default via 192.168.0.2" 

auto_eth1="true"

config_eth1= "192.168.0.2/24" 

enable_ipv6_eth1="false"

#----------------------------------

dns_domain="MASKED"

#----------------------------------

module_eth="!plug"
```

It seems the spaces are causing the issue, but NetworkManager is creating the file, not me... Also why is dhcpcd trying to run on eth1 when I start and wiping my /etc/resolv.conf?

----------

## sirlark

I've fixed the issues in my /etc/conf.d/net (it was the spaces). I also then modified the connection and saved it in the NetworkManager tray applet, and it doesn't modify the file... I don't know where those comments came from originally? Maybe a cut 'n paste? Anyway, the point is that the error messages at boot have disappeared, but the problem about dhcpcd running and clobbering the resolv.conf is still there.

----------

## khayyam

 *sirlark wrote:*   

> the error messages at boot have disappeared, but the problem about dhcpcd running and clobbering the resolv.conf is still there.

 

sirlark ...

set dhcpcd not to request DNS, resolv.conf will then be untouched:

```
modules_eth0="dhcpcd"

dhcp_eth0="nodns"
```

best ... khay

----------

## sirlark

Thanks, just a quick question though... I notice you suggest disabling dchp on eth0, although eth0  isn't  the issue. I've disabled dns on  eth1, to no  effect. Are you thinking that dhcp on eth0 is clobbering resolv.conf?

----------

## khayyam

 *sirlark wrote:*   

> Thanks, just a quick question though... I notice you suggest disabling dchp on eth0, although eth0  isn't  the issue. I've disabled dns on  eth1, to no  effect. Are you thinking that dhcp on eth0 is clobbering resolv.conf?

 

sirlark ... well, the above is just an example, I wasn't disabling dhcp but setting it so than no DNS is requested from the dhcp server.

Whatever interface is using dhcp then without "nodns" the resolv.conf will be effected, so if you want dhcp on both interfaces, but no DNS, then:

```
modules="dhcpcd"

dhcp_eth0="nodns"

dhcp_eth1="nodns"
```

or similarly ... don't request NIS, NTP, DNS, don't send the hostname, and release the licence.

```
dhcp_eth0="release nontp nonis nosendhost nodns"
```

best ... khay

----------

## sirlark

Hi Khay,

I now have the following in /etc/conf.d/net, but still have the same problem.

```
dns_servers_eth1="192.168.0.2 208.67.222.222 208.67.220.220"

routes_eth1="default via 192.168.0.1" 

auto_eth1="true"

config_eth1="192.168.0.2/24" 

enable_ipv6_eth1="false"

dns_domain="MASKED"

module_eth="!plug"

dhcp_eth1="nodns nontp nonis"

dhcp_eth0="nodns nontp nonis"
```

Also, I note that one of my boot messages is 

```
 * Starting DHCP Client Daemon ...                                        [ ok ]
```

So dhcp is still being initiated by the rc scripts somewhere, instead of from NetworkManager. Despite the prohibition of "nodns" my /etc/resolv.conf is still being clobbered.

Is there some current documentation for /etc/conf.d/net you could point me too?

----------

## khayyam

 *sirlark wrote:*   

> I now have the following in /etc/conf.d/net, but still have the same problem.
> 
> ```
> dns_servers_eth1="192.168.37.2 208.67.222.222 208.67.220.220"
> 
> ...

 

sirlark ... note that here eth1 is not configured via dhcp so the 'dhcp_eth1=' serves no purpose. Also, 'module_eth=' will likewise do nothing as 'eth' is not an interface. I'm not sure if this is a case of NetworkManager just not understanding the required constructs or if this is the result of subsequent manual edits, but the logic should follow the following: global, ie, 'modules=' (note 'modules' not 'module'), or per interface, ie, 'modules_${IFACE}, 'dhcp_${IFACE}, config_${IFACE}, etc.

I'm not sure what 'auto_eth1=true' is supposed to do, its not a construct I've seen documented ... but anyhow, probably the following is whats intended:

```
modules_eth1="!plug iproute2"

config_eth1="192.168.37.2/24"

routes_eth1="default via 192.168.37.1"

dns_servers_eth1="192.168.37.2 208.67.222.222 208.67.220.220"

dns_domain_eth1="volundr.dyndns.org"

enable_ipv6_eth1="false"

modules_eth0="!plug dhcpcd"

config_eth0="dhcp"

dhcp_eth0="nodns nontp nonis"

enable_ipv6_eth0="false"
```

 *sirlark wrote:*   

> Also, I note that one of my boot messages is 
> 
> ```
>  * Starting DHCP Client Daemon ... [ ok ]
> ```
> ...

 

If its not in the runlevel (that is, your sure you haven't added it) then something depends on 'net' and so starts dhcpcd, which would mean that NetworkManager isn't providing 'net'. I've given up supporting NetworkManager so that is something you will have to work out for your self, however dhcpcd can be configured *not* to provide 'net' by adding the following to /etc/rc.conf

```
rc_dhcpcd_provide="!net"
```

 *sirlark wrote:*   

> Despite the prohibition of "nodns" my /etc/resolv.conf is still being clobbered.

 

In your above configuration /etc/resolve.conf will be written (as you define domain and nameservers) ... also, as 'dns_domain=' is global it'll be run for both interfaces, so your best to either omit this entirely (that is make resolv.conf static) or simply define it (as I have above) for one interface. 

 *sirlark wrote:*   

> Is there some current documentation for /etc/conf.d/net you could point me too?

 

yes, /usr/share/doc/openrc-{version}/net.example.bz2

best ... khay

----------

## sirlark

Right, so it seems no amount of editing /etc/conf.d/net would prevent dhcpcd from being started at boot. The reason being dnsmasq and apache both require "net", and NetworkManager weirdly enough doesn't provide it.

So I added these two lines to my /etc/rc.conf

```
rc_NetworkManager_provide="net"

rc_dhcpcd_provide="!net"
```

Leaving the 'rc_NetworkManager_provide="net"' line out just meant that apache, dnsmasq, etc just wouldn't start.

----------

