Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] network interface static IP addr. vs DHCP and DNS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 632

PostPosted: Fri Jan 10, 2020 1:28 pm    Post subject: [SOLVED] network interface static IP addr. vs DHCP and DNS Reply with quote

Hi,

Something might have changed since the last time I installed a Gentoo system from scratch, or I might have overlooked something.

This is my network configuration:

Code:
# cat /etc/conf.d/net
dns_domain="mydomain.org"
dns_search="mydomain.org"
dns_servers="10.215.144.31 10.215.144.35"

config_lan="10.215.145.240/16"
routes_lan="
default via 10.215.144.91
"


I'm expecting two things when I start /etc/init.d/net.lan.

1) /etc/resolv.conf should be updated with:
Code:
domain mydomain.org
nameserver 10.215.144.31
nameserver 10.215.144.35


2) the "lan" interface should be assigned one (and only one) static IP address (10.215.145.240).

However, it's not behaving as expected.

1) The resolv.conf file contains:
Code:
# Generated by dhcpcd
# /etc/resolv.conf.head can replace this line
nameserver 8.8.8.8
# /etc/resolv.conf.tail can replace this line


I have no idea why it's grabbing Google's primary DNS server.

I see this too:
Code:
# ps aux | grep dhcp
root      4466  0.0  0.0   3396  2688 ?        Ss   12:28   0:00 /sbin/dhcpcd -q


My older Gentoo systems do not have the DHCP client in the background, and they're configured pretty much the same way (they do have the dhcpcd package installed too).

Yes, I have a DHCP server in my LAN, but the older Gentoo systems are OK.

What can I try?

2)

At first the interface has only one static IP address, but after just a few seconds (DHCP?) this shows up:

Code:
# ip a s lan
6: lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:17:31:83:79:7c brd ff:ff:ff:ff:ff:ff
    inet 10.215.145.240/16 brd 10.215.255.255 scope global lan
       valid_lft forever preferred_lft forever
    inet 10.215.144.163/16 brd 10.215.255.255 scope global secondary noprefixroute lan
       valid_lft forever preferred_lft forever


My DHCP server (an older Gentoo system) has this lease:
Code:
lease 10.215.144.163 {
  starts 5 2020/01/10 12:19:43;
  ends 6 2020/01/11 12:19:43;
  cltt 5 2020/01/10 12:19:43;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 00:17:31:83:79:7c;
  uid "\3771\203y|\000\004 \306\356\221\234z\332\021\217\036\000\0271\203y|";
  set vendor-class-identifier = "dhcpcd-7.2.3:Linux-4.19.86-gentoo-x86_64:x86_64:AuthenticAMD";
  client-hostname "gw2";
}


The new system doesn't seem to be starting dhcpcd explicitly:
Code:
# rc-update show
               binfmt | boot
             bootmisc | boot
                devfs |                                 sysinit
                dmesg |                                 sysinit
                 fsck | boot
             hostname | boot
              hwclock | boot
              keymaps | boot
            killprocs |                        shutdown
    kmod-static-nodes |                                 sysinit
                local |      default nonetwork
           localmount | boot
             loopback | boot
                mdadm | boot
              modules | boot
             mount-ro |                        shutdown
                 mtab | boot
             netmount |      default
               procfs | boot
                 root | boot
            savecache |                        shutdown
                 swap | boot
               sysctl | boot
                sysfs |                                 sysinit
            syslog-ng |      default
         termencoding | boot
                 udev |                                 sysinit
         udev-trigger |                                 sysinit
              urandom | boot


Code:
# grep dhcpc /etc/init.d/*
/etc/init.d/dhcpcd:command=/sbin/dhcpcd
/etc/init.d/dhcpcd:pidfile=/var/run/dhcpcd.pid

# /etc/init.d/dhcpcd status
 * status: started


Why has dhcpcd been started?

Vieri


Last edited by Vieri on Fri Jan 10, 2020 5:52 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ionen
l33t
l33t


Joined: 06 Dec 2018
Posts: 691

PostPosted: Fri Jan 10, 2020 1:57 pm    Post subject: Reply with quote

netifrc has a million hooks that go in/out and left and right, and not where I need it having me dig through scripts to find a solution, loops through modules and stuff, that I don't really know anymore. Personally I've just accepted USE=newnet on openrc (it's essentially just a small single-script wrapper to use ip or ifconfig, nothing fancy), uninstalled dhcpcd and netifrc, and have my own resolv.conf that's not auto-generated :|

I still run a dhcp server for my VMs though (a fine side-job for that tiny dnsmasq).

If dhcpcd is needed, I feel it's more suitable standalone with its own config file rather than clash with in-between scripts (you can send it commands, set static ips, bring specific interface up/down, etc.. essentially what netifrc tries to do on top of what it already does, at most netifrc is useful if you need integration with other boot scripts, but even then I'd rather just make personalized boot scripts than use it at this point /rant).
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 632

PostPosted: Fri Jan 10, 2020 2:32 pm    Post subject: Reply with quote

Do you believe it's a bug in netifrc?

Not sure because I'm running net-misc/netifrc-0.5.1::gentoo on both the new and the old gentoo systems.

I also tried adding the following in vain:

Code:
modules="!dhcpcd !dhcp"
modules_lan="!dhcpcd !dhcp"


This may require a bug report, I guess.
Back to top
View user's profile Send private message
Ionen
l33t
l33t


Joined: 06 Dec 2018
Posts: 691

PostPosted: Fri Jan 10, 2020 2:39 pm    Post subject: Reply with quote

I'm not sure, I just wouldn't be surprised :) Edit: It may just be some openrc dependency on something that ends up requesting it even if it's not in the runlevel (not that I see anything strange in your runlevels...)

If you don't need it, why keep dhcpcd installed though? I don't recall it's set as a hard dependency.
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 632

PostPosted: Fri Jan 10, 2020 4:27 pm    Post subject: Reply with quote

I might need a dhcp client on another interface.
Back to top
View user's profile Send private message
Ionen
l33t
l33t


Joined: 06 Dec 2018
Posts: 691

PostPosted: Fri Jan 10, 2020 5:11 pm    Post subject: Reply with quote

Vieri wrote:
I might need a dhcp client on another interface.
In that case you'll have to decide which handles resolv.conf so they don't race each others to overwrite/reset it, either by making dhcpcd start with "-C resolv.conf" (or "nohook resolv.conf" in /etc/dhcpcd.conf, I think that works anyway), or by letting it do it and adding your static entries to resolv.conf.head/tail that dhcpcd will merge.

You could also remove netifrc entirely, and have dhcpcd assign your static address as well (can be done in /etc/dhcpcd.conf).

Meanwhile you could always move out dhcpcd's init script to be sure it doesn't start I guess (it may also give an explanation as to why it's being started if there's some error/warning), assuming nothing is starting it directly. If it worked before, it's likely because the boot order was favorable (dhcpcd first, then netifrc overwriting it -- but dhcpcd could decide to overwrite later on without -C so that setup is risky :), still not sure why it's being started at all here though)
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 632

PostPosted: Fri Jan 10, 2020 5:51 pm    Post subject: Reply with quote

Thanks, Ionen.

The devs have explained to me that OpenRC "needs" an init script in the default runlevel that "provides net". I guess this is new, and that would explain why my older systems didn't have this issue.
If OpenRC does not find one, it launches dhcpcd.

I was starting/restarting/stopping my network interfaces manually or from a custom script (as in my older systems). So OpenRC insisted upon calling dhcpcd.

So my options are to either change the way I boot the machine by placing at least net.lan in the default runlevel, or install a custom init script that "provides net" but does nothing (so I can then initialize my NICs as I've always had, manually or via custom script).

Thanks again.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum