Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] dhcpd and dnsmasq shut down when wan gets restarted
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Aug 03, 2017 1:56 pm    Post subject: [SOLVED] dhcpd and dnsmasq shut down when wan gets restarted Reply with quote

I'm running gentoo as a home router, and there is one annoying quirk that I'd like to get straightened out:
Wherever I manually restart my wan connection, dnsmasq and dhcpd also restart, leaving lan connections unresponsive.
Code:

$ sudo rc-config restart net.enp3s0
Restarting init script
 * Unmounting network filesystems ...                                                   [ ok ]
 * Stopping dnsmasq ...                                                                 [ ok ]
 * Stopping dhcpd ...                                                                   [ ok ]
 * Bringing down interface enp3s0
 *   Stopping dhcpcd on enp3s0 ...
sending signal TERM to pid 9919
waiting for pid 9919 to exit                                                            [ ok ]
RTNETLINK answers: No such file or directory
Error talking to the kernel
 * Bringing up interface enp3s0
 *   dhcp ...
 *     Running dhcpcd ...
enp3s0: waiting for carrier
enp3s0: carrier acquired
enp3s0: adding address fe80::d01c:592b:2472:8ed9
DUID
enp3s0: IAID d3:64:c9:a0
enp3s0: soliciting an IPv6 router
enp3s0: rebinding lease of x.x.x.x
enp3s0: probing for an IPv4LL address
enp3s0: DHCP lease expired
enp3s0: soliciting a DHCP lease
enp3s0: offered x.x.x.x from x.x.x.x
enp3s0: probing address x.x.x.x/18
enp3s0: using IPv4LL address 169.254.59.151
enp3s0: adding route to 169.254.0.0/16
enp3s0: adding default route
forked to background, child pid 10650                                                   [ ok ]
 *     received address 169.254.59.151/16                                               [ ok ]
 * Starting dnsmasq ...                                                  [ ok ]
 * Mounting network filesystems ...                                                     [ ok ]
 * Starting dhcpd ...                                                                   [ ok ]

Even more problematic is that if wan interface is not plugged anywhere - service for iface does not start back up after "waiting for carrier", leaving both dnsmasq and dhcpd (ans also netmount) down, making the box unreachable for new connections until reboot.

Is this problem with service dependencies? Removing need net from init.d scripts did not seem to help.
Code:

$ rc-status
Runlevel: default
 lm_sensors                                                                      [  started  ]
 sysklogd                                                                        [  started  ]
 net.lo                                                                          [  started  ]
 iptables                                                                        [  started  ]
 net.br0                                                                         [  started  ]
 net.enp3s0                                                                      [  started  ]
 dnsmasq                                                                         [  started  ]
 sshd                                                                            [  started  ]
 dhcpd                                                                           [  started  ]
 cronie                                                                          [  started  ]
 netmount                                                                        [  started  ]
 local                                                                           [  started  ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
 modules-load                                                                    [  started  ]
Dynamic Runlevel: manual

enp3s0 is wan connection, br0 - is bridge over few NICs for lan.
Code:

config_enp3s0="dhcp"

# bridge_br0="enp2s0 enp2s1 enp4s0 enp5s0"
bridge_br0="enp2s0 enp2s1 enp4s0"
config_br0="192.168.100.1 netmask 255.255.255.0"
routes_br0="192.168.0.0/16 via 192.168.100.254"


Last edited by Kresp on Wed Aug 16, 2017 1:11 pm; edited 2 times in total
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 2583

PostPosted: Thu Aug 03, 2017 2:44 pm    Post subject: Re: dhcpd and dnsmasq shut down when wan gets restarted. Reply with quote

Kresp wrote:
Is this problem with service dependencies? Removing need net from init.d scripts did not seem to help.
Code:

$ rc-status
Runlevel: default
...
 dnsmasq                                                                         [  started  ]
 sshd                                                                            [  started  ]
 dhcpd                                                                           [  started  ]
 ...

Are you sure you want (or need) to run both dnsmasq and dhcpd together?
https://wiki.gentoo.org/wiki/Home_Router#DHCP_server
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Aug 03, 2017 10:15 pm    Post subject: Re: dhcpd and dnsmasq shut down when wan gets restarted. Reply with quote

charles17 wrote:

Are you sure you want (or need) to run both dnsmasq and dhcpd together?
https://wiki.gentoo.org/wiki/Home_Router#DHCP_server

Well, I'm trying to get rid of dnsmasq. For now it only serves as nameserver, but I'm going to replace it with bind.
The problem was present even when dnsmasq was doing both name resolution and serving DHCP, without dhcpd.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13495

PostPosted: Fri Aug 04, 2017 1:38 am    Post subject: Reply with quote

Is there anything interesting in the output of /etc/init.d/dhcpd ineed or /etc/init.d/dhcpd iuse?
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Fri Aug 04, 2017 9:35 am    Post subject: Reply with quote

Hu wrote:
Is there anything interesting in the output of /etc/init.d/dhcpd ineed or /etc/init.d/dhcpd iuse?

Yep, both dhcpd and dnsmasq need both interfaces (br0 and enp3s0):
Code:

$ /etc/init.d/dhcpd ineed
sysfs fsck localmount net.br0 net.enp3s0
$ /etc/init.d/dhcpd iuse
sysklogd dnsmasq
$ /etc/init.d/dnsmasq ineed
fsck localmount sysfs net.br0 net.enp3s0
$ /etc/init.d/dnsmasq iuse
sysklogd

I don't quite get it - net.lo, net.br0 and net.enp3s0 all should provide net service that dhcpd needs, correct?
However, it displays that it only needs two - br0 and enp3s0. But also he needs them at the same time.
Code:

$ ls -lah /etc/init.d/net.*
lrwxrwxrwx 1 root root  18 Apr 21 12:47 /etc/init.d/net.br0 -> /etc/init.d/net.lo
lrwxrwxrwx 1 root root  18 May  8 10:17 /etc/init.d/net.enp3s0 -> /etc/init.d/net.lo
-rwxr-xr-x 1 root root 19K Apr 13 15:32 /etc/init.d/net.lo
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 2583

PostPosted: Fri Aug 04, 2017 9:38 am    Post subject: Re: dhcpd and dnsmasq shut down when wan gets restarted. Reply with quote

And even more confusing, netifrc is stopping dhcpd and then * Stopping dhcpcd on enp3s0 ...
Kresp wrote:
Code:

$ sudo rc-config restart net.enp3s0
...
 * Stopping dhcpd ...                                                                   [ ok ]
 * Bringing down interface enp3s0
 *   Stopping dhcpcd on enp3s0 ...
sending signal TERM to pid 9919
waiting for pid 9919 to exit                                                            [ ok ]
RTNETLINK answers: No such file or directory
Error talking to the kernel
...

Are you using dhcpd and dhcpcd both or is it a feature of netifrc?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 42563
Location: 56N 3W

PostPosted: Fri Aug 04, 2017 9:46 am    Post subject: Reply with quote

Kresp,

Its related to the way the network service is defined in /etc/rc.conf

Do you need all interfaces to be up to consider the network service up or just one of them?
If you need them all, then things that depend on the network service will stop or restart when any interface goes down/restarts.

See the comments in /etc/rc.conf.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
chiefbag
Guru
Guru


Joined: 01 Oct 2010
Posts: 542
Location: The Kingdom

PostPosted: Tue Aug 08, 2017 11:33 am    Post subject: Reply with quote

Restart the interface using --nodeps flag

Code:
/etc/init.d/net.enp3s0 restart --nodeps
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Tue Aug 08, 2017 11:53 am    Post subject: Reply with quote

chiefbag wrote:
Restart the interface using --nodeps flag

That sounds like a very helpful argument to know.




NeddySeagoon wrote:
Kresp,

Its related to the way the network service is defined in /etc/rc.conf

Do you need all interfaces to be up to consider the network service up or just one of them?
If you need them all, then things that depend on the network service will stop or restart when any interface goes down/restarts.

See the comments in /etc/rc.conf.

Thanks, exactly what I need.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security 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