# openRC:net dependency and unavaible nics:Service don't start

## AnarKEY

Hi there,

I have an issue with init scripts and net dependendy.

I've got two ethernet devices (wired enp12s0 and wireless wlp6s0) and therefore two symlinks in /etc/init.d/) with symlinks net.enp12s0 -> net.lo and the same with net.enp12s0)

Additionally I run some services which depends on net like shorewall & tor, see /etc/init.d/tor for example:

```
depend() {

  need net 

}

```

Now I get the problem that when I boot my machine without the network cable plugged in, net.enp12s0 couldn't be started and therefore tor isn't started as well. Also when I start tor manually (/etc/init.d/tor start) without the cable plugged in, starting tor fails:

```
localhost markus # /etc/init.d/tor start

 * Bringing up interface enp12s0

 *   config_enp12s0 not specified; defaulting to DHCP

 *   dhcp ...

 *     Running dhcpcd ...

dhcpcd[8009]: version 6.6.7 starting

dhcpcd[8009]: enp12s0: waiting for carrier

dhcpcd[8009]: timed out

dhcpcd[8009]: exited                                                                                                                                                                                                        [ !! ]

 * ERROR: net.enp12s0 failed to start

 * ERROR: cannot start tor as net.enp12s0 would not start

```

Have I configured sth. wrong? When I've no ethernet available, I use to remove the symlink net.enp12s0 temporary to get the services started, but I would really appreciaty an automatic solution.

Many thanks for any assistance.

MarkusLast edited by AnarKEY on Fri Feb 13, 2015 1:53 pm; edited 2 times in total

----------

## khayyam

AnarKEY ... that looks like you pressed 'submit' before your question, or sentence, was complete ... anyhow, your looking to change what service is providing 'net', or the net.*(s) which should be activated in order to satisfy that dependency? ... or some other question?

edit: ok, I see you've since completed it.

best ... khayLast edited by khayyam on Fri Feb 13, 2015 1:52 pm; edited 1 time in total

----------

## AnarKEY

 *khayyam wrote:*   

> AnarKEY ... that looks like you pressed 'submit' before your question, or sentence, was complete ... anyhow, your looking to change what service is providing 'net', or the net.*(s) which should be activated in order to satisfy that dependency? ... or some other question?
> 
> best ... khay

 

Thanks for your answer and sorry, wanted to press preview instead of submit. Here's my whole question now.

----------

## khayyam

 *AnarKEY wrote:*   

>  *khayyam wrote:*   AnarKEY ... that looks like you pressed 'submit' before your question, or sentence, was complete ... anyhow, your looking to change what service is providing 'net', or the net.*(s) which should be activated in order to satisfy that dependency? ... or some other question? 
> 
> Thanks for your answer and sorry, wanted to press preview instead of submit. Here's my whole question now.

 

AnarKEY ... ok, no problem. Well, your probably looking for something like sys-apps/ifplugd ... and so have the interfaces started based on being plugged.

There are various other mechanisms like 'runlevels', or 'rc_*_need' that could be used to stipulate what services are started and their dependency for 'net' ... but that doesn't look to be what you're after ... clarify if I'm wrong.

best ... khay

----------

## AnarKEY

 *khayyam wrote:*   

>  *AnarKEY wrote:*    *khayyam wrote:*   AnarKEY ... that looks like you pressed 'submit' before your question, or sentence, was complete ... anyhow, your looking to change what service is providing 'net', or the net.*(s) which should be activated in order to satisfy that dependency? ... or some other question? 
> 
> Thanks for your answer and sorry, wanted to press preview instead of submit. Here's my whole question now. 
> 
> AnarKEY ... ok, no problem. Well, your probably looking for something like sys-apps/ifplugd ... and so have the interfaces started based on being plugged.
> ...

 

Thanks for your quick reply.

I'm not sure whether ifplugd will resolve that issue (but it's a good hint though) because I'll shorewall and tor to start even when no net.* is or could be started. Therefore I could remove the dependency of that service in the shorewall init script, but I'm unsure about side effects and init script updates, etc.

What I want is:

* Shorewall can be started even when any net.* device could not

* Start shorewall alongside as a dependency of any net.* script

Ultimately I want to exclude that case, that any net-device is started without shorewall & tor on the one hand and on the other hand I can (re-)start that services even when not all net.* scripts could be started. So maybe the other hint of you leads to the right direction .. 

I hope I could make clear my issue.

----------

## charles17

 *AnarKEY wrote:*   

> Have I configured sth. wrong? When I've no ethernet available, I use to remove the symlink net.enp12s0 temporary to get the services started, but I would really appreciaty an automatic solution.

 Doing that with netifrc gets complicated but with DHCPCD works very well, some manual works required. 

See also this topic

 *AnarKEY wrote:*   

> Ultimately I want to exclude that case, that any net-device is started without shorewall & tor on the one hand and on the other hand I can (re-)start that services even when not all net.* scripts could be started. So maybe the other hint of you leads to the right direction .. 

 So then you'd need dhcpcd start after shorewall and tor.

----------

## khayyam

 *AnarKEY wrote:*   

> What I want is:
> 
> * Shorewall can be started even when any net.* device could not
> 
> * Start shorewall alongside as a dependency of any net.* script

 

AnarKEY ... ok, those two are basically incompatible requirements in a dependency based system. However it should suffice to do the following:

/etc/rc.conf

```
rc_shorewall_need="!net"

rc_shorewall_before="net"
```

 *AnarKEY wrote:*   

> Ultimately I want to exclude that case, that any net-device is started without shorewall & tor on the one hand and on the other hand I can (re-)start that services even when not all net.* scripts could be started. So maybe the other hint of you leads to the right direction.

 

This sounds as though you're starting both net.${IFACE} which you really shouldn't ... if you want to be able to have these both active, or rather activated, then you should really use ifplugd (which can bring down one, and start the other based on a cable being connected/disconnected).

As for tor ... it does 'need net', so having it start without net seems somewhat pointless. If its just a question of starting it as the network becomes available then really this is more and issue with your expecting you can add everything to the default runlevel and everything will somehow work out. You should be using either a runlevel for this, or hooks from netifrc/dhcpcd/ifplugd to start it at the time when net is available.

 *charles17 wrote:*   

> Doing that with netifrc gets complicated but with DHCPCD works very well

 

@charles ... no more complicated than dhcpcd, really ... its also more configurable as you have net.iface.runlevel and similar type mechanisms for fine tuning.

best ... khay

----------

## AnarKEY

Thanks khayyam,

sorry for the late reply. I added rc_neet="!net" and rc_before="net" to /etc/conf.d/shorewall and it works fine now.

I'll also try out ifplugd to set up a more sophisticated network configuration instead trying to start everything at once and hoping in the end everything will be running.

Thanks again, I also learned a lot about openRC and will hopefully do also about ifplugd.

M

----------

