You are not logged in.

#1 2012-09-06 14:40:06

daidai67
Member
Registered: 2012-09-06
Posts: 5

starting ssh tunnel after dhclient/dhcpcd initialisation with systemd

Hi,

I've written a small systemd service file which simply start a socks5 tunneling proxy with ssh. Everything is working fine when I launch the service "by hand" with a "systemctl start".

However, when I install the service, ssh fail to start because net-auto-wired/wireless didn't have the time to completely launch dhcpcd (no binding yet), even after having added an "After=net-auto-wired.service".

Has someone a clue of what I should do to achieve my goal ?


Thanks

Offline

#2 2012-09-06 14:55:49

jjacky
Member
Registered: 2011-11-09
Posts: 347
Website

Re: starting ssh tunnel after dhclient/dhcpcd initialisation with systemd

Maybe After=network.target ?

Offline

#3 2012-09-06 15:05:14

daidai67
Member
Registered: 2012-09-06
Posts: 5

Re: starting ssh tunnel after dhclient/dhcpcd initialisation with systemd

unfortunately no, it is not enough... BTW, I have the same problem with nmdb.service which is failing because it starts too early. For the tunnel stuff maybe I can use netcfg quirks, but it looks like kind of hack...

Offline

#4 2012-09-06 17:06:43

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: starting ssh tunnel after dhclient/dhcpcd initialisation with systemd

Maybe After=nss-lookup.target? Also, make sure that net-auto-wireless/wired is delaying the start of network.target.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#5 2012-09-07 14:04:09

daidai67
Member
Registered: 2012-09-06
Posts: 5

Re: starting ssh tunnel after dhclient/dhcpcd initialisation with systemd

I have already tried, "nss-lookup.target" and "nss-user-lookup.target" but nothing changed, ssh is still started long before dhclient finish its job of acauiring an ip adress/dns. I have an ipv6 network, but it shouldn't change anything. BTW how can I delay network.target (as it is precisely what should be done) until I get a correct ip ? Let's hope google will help..

Anyway, thanks fro the answer ;-)

Offline

#6 2012-09-09 00:41:40

johni
Member
Registered: 2012-02-03
Posts: 102

Re: starting ssh tunnel after dhclient/dhcpcd initialisation with systemd

Maybe change your ssh tunnel service to call a script that will monitor for an ip on the interface, and when found then starts the ssh tunnel:

You can get the IP address on the interface like this:

ip addr show eth0 | grep inet | awk '{print $2}' | head -1

Just wrap that in a loop that waits for an ip, and then starts the ssh tunnel:

while [ -z "$(ip addr show eth0 | grep inet | awk '{print $2}' | head -1)" ]
do
   sleep 5
done
ssh blah blah blah

Of course replace "eth0" with whatever your interface name is.

Offline

#7 2012-09-10 15:17:26

daidai67
Member
Registered: 2012-09-06
Posts: 5

Re: starting ssh tunnel after dhclient/dhcpcd initialisation with systemd

Yes it basically works now.

Thanks

Offline

Board footer

Powered by FluxBB