Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
systemd & network [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
axl
Guru
Guru


Joined: 11 Oct 2002
Posts: 537
Location: Romania

PostPosted: Tue Mar 22, 2016 5:57 am    Post subject: systemd & network [solved] Reply with quote

hi. i think in this community it's important to say who you are first. hi. i use gentoo since like 96. i'm ok with systemd. and am usually pretty handy with things like these.

i'm in an unusual situation. i know my system runs very well. systemd speeds things up. but a bit too much.

my problem is related to network. the machine in question is running a router type setup. but is also responsible for it's own dns.

problem is that services like dhcpd4 or apache2 or nfs-server start before bind. and before net@eth0/eth1/br0.

i run a weird setup, and most of my services are binded to a br0 adress. part of that br0 is eth1. that's where most of the internet services are binded to that address. only to that address. and most services wait their turn and bind to the right address.

it is weird, only because i bridge my cell or laptop or other random pc-s on the net for random gaming purposes into my lan. using that bridge. but it's just a bridge.

Code:

[root@magdalina:~]# cat /etc/conf.d/net
config_eth0="x.y.z.t/24 brd x.y.z.255"
routes_eth0="default gw x.y.z.1"
config_eth1="null"
config_br0="192.168.0.64 brd 192.168.0.95 brd 192.168.0.95
and some other routable network i wont mention
"

bridge_br0="eth1"
brctl_br0="setfd 0
sethello 0
stp off"


i tried editing services files in /usr/lib/systemd/system/*.service. then targets. /usr/lib/systemd/system/*.target. it seems to have a mind of it's own.

with wants and needs and afters, with editing or just making special directories with ".wants" doesn't help.

maybe i just needs sleepz.


am sure it's something simple and obvious.

what was the question?

why does dhcpd4/apache2/ntpdate/proftpd/nfs-server sometimes need manual restart because systemd started them before all odd network things were started? ya. that is the question.


Last edited by axl on Sun Apr 24, 2016 2:01 am; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7130
Location: almost Mile High in the USA

PostPosted: Tue Mar 22, 2016 6:44 am    Post subject: Reply with quote

A bit confused... Normally when you configure network for systemd you'd want to use Systemd-networkd or NetworkManager ... The /etc/conf.d/net configuration is meant for OpenRC. Supposedly if you configure the network in systemd, the services should run after your network is configured, and automatically restart for you if necessary - if you have to manually restart them, something is wrong...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
axl
Guru
Guru


Joined: 11 Oct 2002
Posts: 537
Location: Romania

PostPosted: Tue Mar 22, 2016 5:26 pm    Post subject: Reply with quote

net@.service is part of systemd and should work fine.
Back to top
View user's profile Send private message
Syl20
Guru
Guru


Joined: 04 Aug 2005
Posts: 564
Location: France

PostPosted: Wed Mar 23, 2016 4:03 pm    Post subject: Re: systemd & network Reply with quote

axl wrote:
i tried editing services files in /usr/lib/systemd/system/*.service. then targets.

Do not. All the files in /usr/lib/systemd will be erased on the next systemd update. Prefer the "systemctl edit" command, which writes your specific conditions into files in /etc/systemd/system/*.wants/.

I don't use systemd on Gentoo (and I would not use it at all, if I had the choice), but I think it should work like on CentOS. And so, you need to play with the "Before"/"After" _and_ (I insist, AND) the "Require"/"Wants" directives (the fact is "After" do not imply "Require"... :roll: ).

Maybe you can solve easily the problem juste by adding a "Before=network.target" directive to the bind unit (that also depends on your bind configuration), but systemd works in mysterious ways... At least, OpenRC gives the choice to activate or not the "impossible-to-debug-services-start-parallelization-to-gain-or-not-one-or-two-seconds" feature.

Of course, do not forget to run "systemctl daemon-reload" after your changes.
Back to top
View user's profile Send private message
axl
Guru
Guru


Joined: 11 Oct 2002
Posts: 537
Location: Romania

PostPosted: Wed Mar 23, 2016 5:14 pm    Post subject: Re: systemd & network Reply with quote

CneGroumF wrote:
axl wrote:
i tried editing services files in /usr/lib/systemd/system/*.service. then targets.

Do not. All the files in /usr/lib/systemd will be erased on the next systemd update. Prefer the "systemctl edit" command, which writes your specific conditions into files in /etc/systemd/system/*.wants/.

I don't use systemd on Gentoo (and I would not use it at all, if I had the choice), but I think it should work like on CentOS. And so, you need to play with the "Before"/"After" _and_ (I insist, AND) the "Require"/"Wants" directives (the fact is "After" do not imply "Require"... :roll: ).

Maybe you can solve easily the problem juste by adding a "Before=network.target" directive to the bind unit (that also depends on your bind configuration), but systemd works in mysterious ways... At least, OpenRC gives the choice to activate or not the "impossible-to-debug-services-start-parallelization-to-gain-or-not-one-or-two-seconds" feature.

Of course, do not forget to run "systemctl daemon-reload" after your changes.


i figured it out after all. u're right.

i used systemctl itself to add a dependency, which created a service.want directory in etc.

but seems to be unreliable. sometimes it works, sometimes it doesn't.

i ended up using a local.d script to restart services that failed.

it's a hack and i dont especially like it. didn't have problems with systemd before.
Back to top
View user's profile Send private message
axl
Guru
Guru


Joined: 11 Oct 2002
Posts: 537
Location: Romania

PostPosted: Fri Mar 25, 2016 2:42 am    Post subject: Reply with quote

then again, i think it would be easier to send a man on the freaking moon than figure out systemd. to be clear, i am not against it, and am sure it's too late to be. am just trying to cope.

the iron hammer worked for dhcp. i hate the solution. should have worked out of the box. but whatever. at least it works.

if you look in nfs-server.service ... the horror. the wrong indentation and so many rows and columns of wants and requires and afters. have no idea which are just cosmetic and which systemd internal calls actually follows. and this service i can't get to work on it's own after reboot. fact that logs come with weird timestamps, and that are truncated to syslog... can't exactly figure out the timing of the entire boot process.

the weird thing is that only by modifying network stuff (dns/dhcp/net@.service - just those i swear :) ) all of a sudden gpm started starting before kernel even finish booting. and ofc fails. it tries to start it even before udev. wtf is wrong with you systemd?

it was easier to install hackintosh... after moving windows linux and harddrive in gpt, boot in uefi mode, then just figure out this damn boot sequence. and the tools to debug sux. why and how did it decide to start gpm all of a sudden just after mount root?!
Back to top
View user's profile Send private message
axl
Guru
Guru


Joined: 11 Oct 2002
Posts: 537
Location: Romania

PostPosted: Sun Apr 24, 2016 2:21 am    Post subject: Reply with quote

ima mark this as solved. i think i figured it out. i've always tried to use openrc workaround in systemd by using net@interface. in my case, most of my systems use a bridge interface. and that takes a few seconds to initialize, and the openrc wrapper doesn't look in the logs to signal to systemd that network is connected or online or whatever... like networkmanager or wicd do.

sometimes my nfs-server fails randomly. sometimes dhcpd4. sometimes apache. most of the time logs suggest network wasn't initialized when demons tried to start. it's because i used this net@.service that doesn't work perfectly. and as far as i understand it's an openrc wrapper.

with networkmanager, network and online seem to work properly in systemd. slow but properly. i will try wicd next. but that's another story.


before using the 1337 method of net@.service i had a network.service that looked like a slackware net.init. a messy get bridge up, tunnels... and then there is a gap, until all things sync... systemd doesn't know how to read kernel output without the help of a proper network manager. simple ifconfig blabla wont do.

i have networkmanager on some of my systems, because they have gnome, but on the others seems ridiculous.

i see the list of dependencies for wicd is smaller. dont know if wait-online will work with wicd like network manager.

but i am pretty sure if you just create a network.service like:

ifconfig eth0 up
brctl addbr br0
brctl addif br0 eth0
dhclient br0


script ends, systemd thinks has network, but it's a long way for kernel until it actually has network. it's annoying. especially on my machines with raspberry pi. most of them have an even more complicated layout. first they have to put up an usb connection, then a tun connection, then add that to a bridge (that had before the eth0 device but no connection - again have to consult kernel). for my pi devices it's a fluid situation what network access you have. you could have an eth0 cable inserted. or not. you could have a wireless usb stick. or not. and MY wireless network or another. known or not. or a 3g/4g stick or not. and when system is not in it's own environment it brings up a tunnel with a server. tries to mentain up through that tunnel. i use vtun. i love it.

it would still be awesum to know how i could manipulate systemd into submission. ima thinking that target-online is a magical thing. i want a semaphore to signal systemd when it's actually online. i should have marked it as solved. i should have marked it as "more curious".

as in net@.service tells systemd somehow that network IS online. i want to run a sh script that actually confirms that. that should be the initial question. i will leave post like this, maybe someone can help.

again, question is: how can i hold off systemd to assume it's online, until a sh script actually tells systemd that it is online. a semaphore.

maybe just an exec start that just wait(s) until it's happy? i have to try that :)

PS: am sick of checking them manually after restart.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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