# # Generated by net-scripts for interface lo - but static ip!

## ccgllc

Hi all -

Have a weird thing happening on a fairly newly installed box (about 30 days ago, lite usage).

Every time I reboot, my resolv.conf is being re-written.  I understand this is normal behavior if I was running a dhcp client, but I'm not!

```
avalon ~ # cat /etc/conf.d/net

dns_domain_lo="slan.carpenter-farms.us"

config_eth0="172.16.4.15 netmask 255.255.252.0"

routes_eth0="default via 172.16.4.1"
```

```
avalon /etc/init.d # ls

agetty            hostname           mysql-s6            root

apache2           hwclock            mysql-supervise     rsyncd

binfmt            iptables           net-online          runsvdir

bootmisc          keymaps            net.eth0            s6-svscan

busybox-ntpd      killprocs          net.lo              savecache

busybox-watchdog  kmod-static-nodes  netmount            sshd

cgroups           local              nullmailer          swap

consolefont       localmount         numlock             swclock

cronie            loopback           opentmpfiles-dev    sysctl

devfs             lvm                opentmpfiles-setup  sysfs

device-mapper     lvm-monitoring     osclock             sysklogd

dmesg             lvmetad            procfs              termencoding

dmeventd          modules            pydoc-2.7           udev

fsck              mount-ro           pydoc-3.6           udev-settle

functions.sh      mtab               redis               udev-trigger

git-daemon        mysql              redis-sentinel      urandom

```

```
avalon /etc/runlevels/default # ls

apache2  local  mysql  net.eth0  netmount  redis  rsyncd  sshd  sysklogd

```

Note the system boots just fine and assigns the static address.

I know I'm getting old, but what am I missing?  Been using Gentoo since at least the 2.2 kernel, first time I've seen this.

System is about 35 days out of sync, fixing that now.

----------

## eccerr0r

Yeah I think openrc will muck with your resolv.conf on startup, because you can specify your dns servers in /etc/conf.d/net by setting 

```
dns_servers_YOURINTERFACE="8.8.8.8"
```

Is there something you wish not to be removed?  Perhaps we can find a way to make openrc generate the right resolv.conf each reboot.

----------

## ccgllc

 *eccerr0r wrote:*   

> Yeah I think openrc will muck with your resolv.conf on startup, because you can specify your dns servers in /etc/conf.d/net by setting 
> 
> ```
> dns_servers_YOURINTERFACE="8.8.8.8"
> ```
> ...

 

Since the box is statically linked, I'd prefer if it didn't remove anything, which is the way it worked for years.

Otherwise, I'll need a way to set not just the dns_servers, but other resolve.conf records such as "search".  End result will hopefully look like:

```

domain slan.carpenter-farms.us

search lan.carpenter-farms.us carpenter-farms.us

nameserver 172.16.4.2

nameserver 8.8.8.8

nameserver 8.8.4.4

```

I have dozens of gentoo based servers (and dozens more created over the years), this is the only one I'm seeing this behavior with.

Thanks!

----------

## eccerr0r

Something like this should do, though you may need to add interface name...

```
dns_servers="172.16.4.2 8.8.8.8 8.8.4.4"

dns_search="lan.carpenter-farms.us carpenter-farms.us"

dns_domain="slan.carpenter-farms.us"
```

----------

## ccgllc

This worked, but honestly seems completely redundant with just leaving the original file alone and letting DHCPD modify it if its running.  I'm struggling to think of anything else that modifies configuration files in /etc at boot time.

```
dns_domain_lo="slan.carpenter-farms.us"

dns_servers_lo="172.16.4.2 8.8.8.8 8.8.4.4"

dns_search_lo="lan.carpenter-farms.us carpenter-farms.us"

config_eth0="172.16.4.15 netmask 255.255.252.0"

routes_eth0="default via 172.16.4.1"

```

In any case, thanks for your help!

----------

## eccerr0r

Well, have to go with the flow or fight it, but if you choose the latter, you're on your own... Some people start using workarounds (/etc/resolve.conf.head, /etc/resolv.conf.tail) to get around it, and yet others esoteric methods to prevent it (immutable flag.)  

I wouldn't call it totally "redundant" but rather keeping all configuration in one spot.  Advantages and disadvantages to everything as usual.

----------

## Hu

According to the documentation, you caused this by defining DNS parameters for interface lo.  If you remove all DNS related parameters from /etc/conf.d/net, it should cease rewriting /etc/resolv.conf.

```
# System

# For configuring system specifics such as domain, dns, ntp and nis servers

# It's rare that you would need todo this, but you can anyway.

# If you omit the _eth0 suffix, then it applies to all interfaces unless

# overridden by the interface suffix.

#dns_domain_eth0="your.domain"

#dns_servers_eth0="192.168.0.2 192.168.0.3"

#dns_search_eth0="this.domain that.domain"

#dns_options_eth0="timeout:1 rotate"

#dns_sortlist_eth0="130.155.160.0/255.255.240.0 130.155.0.0"

# See the man page for resolv.conf for details about the options and sortlist

# directives

# NOTE: Setting any of these will stamp on the files in question. So if you

# don't specify dns_servers but you do specify dns_domain then no nameservers

# will be listed in /etc/resolv.conf even if there were any there to start

# with.
```

----------

## ccgllc

Fair enough, just find it odd that this is behaving this way on only one of my dozen Gentoo systems.

Creating the dns_domain_lo record is part of the Gentoo AMD Handbook, which I always follow:

```
root #nano -w /etc/conf.d/net

# Set the dns_domain_lo variable to the selected domain name

dns_domain_lo="homenetwork"
```

If this is standard behavior, I'd expect the DNS server setting should be added to the handbook.

Regarding keeping all configurations in one place... that is what /etc is for.  We don't configure NTP in /etc/conf.d, we don't configure Rsync in /etc/conf.d, we don't configure Bind in /etc/conf.d, we don't configure fstab in /etc/conf.d...

----------

## eccerr0r

However this is all network related... It is frustrating that you configure the IP address and the networking still doesn't work because no resolutions go through.  Come to think of it, the default route is typically set up with a different command, and in the olden days usually a different file... and now openrc tries to consolidate that.

Dang,.. I've forgotten what file default routes used to be stored in.  Now I only remember how to actually override it by command line...

----------

## ccgllc

 *eccerr0r wrote:*   

> However this is all network related... It is frustrating that you configure the IP address and the networking still doesn't work because no resolutions go through.  Come to think of it, the default route is typically set up with a different command, and in the olden days usually a different file... and now openrc tries to consolidate that.
> 
> Dang,.. I've forgotten what file default routes used to be stored in.  Now I only remember how to actually override it by command line...

 

That has been in /etc/conf.d/net for several years now.

----------

## eccerr0r

But ask about other distributions...it's not consistent.  They have historically been placed in different files.  OpenRC got a better solution IMHO.

----------

## Hu

 *ccgllc wrote:*   

> Fair enough, just find it odd that this is behaving this way on only one of my dozen Gentoo systems.

 Are all those systems statically addressed?  If dhcp is also in use on those other systems, it would replace the forced entries with information from the DHCP server.

----------

