You are not logged in.

#1 2013-05-30 14:01:04

NuMPTy
Member
From: Canada
Registered: 2011-06-04
Posts: 35

[SOLVED] ifconfig up specific interfaces at boot

Hi everyone,

Having just moved back from Gentoo after a few years I feel a little lost...

Long story short, I have two interfaces; enp16s0f0 and enp16s0f1. All I need to do is 'ifconfig up' them at boot, however I don't see an easy way of doing this (no rc.local...). I don't require any IP addresses or anything like that so I don't think netctl is what I'm looking for (could be wrong...)

I tried using an rc-local.service, but didn't seem to have any success with that during boot.

Anyone have any suggestions?

Last edited by NuMPTy (2013-05-30 15:39:38)

Offline

#2 2013-05-30 14:51:25

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,095
Website

Re: [SOLVED] ifconfig up specific interfaces at boot

`ifconfig` has been deprecated, you should use `ip`. Anyway, if all you want to do is bring the interface up at boot, you could write a small systemd service file to do this and enable it. Having said that, why is it you want to bring up the interfaces but not associate them with a network? This seems like it might involve some XYProblem.

All the best,

-HG

Last edited by HalosGhost (2013-05-30 14:51:41)

Offline

#3 2013-05-30 14:54:45

NuMPTy
Member
From: Canada
Registered: 2011-06-04
Posts: 35

Re: [SOLVED] ifconfig up specific interfaces at boot

Haha, no, not an XYProblem, but thank you smile

The interfaces are being used for bridging virtualized guests. The interfaces just have to be in an 'up' state, and it takes care of the rest (doesn't have to be a bond/bridge/tap whatever). It works perfectly fine if I do it manually...it's just annoying to have to run a script every time after I log in...

Care to show me how to write this as a system file? I tried that already (see rc-local.service) without success.

Thanks,

Offline

#4 2013-05-30 15:00:16

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,095
Website

Re: [SOLVED] ifconfig up specific interfaces at boot

NuMPTy wrote:

The interfaces are being used for bridging virtualized guests. The interfaces just have to be in an 'up' state, and it takes care of the rest (doesn't have to be a bond/bridge/tap whatever).

Cool! Then yeah, a systemd service file should do the trick.

Care to show me how to write this as a system file? I tried that already (see rc-local.service) without success.

Why don't you go ahead and post what you tried and we'll see if we can't figure out a good solution?

All the best,

-HG

Offline

#5 2013-05-30 15:02:34

NuMPTy
Member
From: Canada
Registered: 2011-06-04
Posts: 35

Re: [SOLVED] ifconfig up specific interfaces at boot

Sure - I grabbed this from superuser:

/etc/systemd/system/rc-local.service:

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Added this to rc.local w/ appropriate permissions (+x):

ifconfig enp16s0f0 up
ifconfig enp16s0f1 up

Enabled it via

systemctl enable rc-local.service

Last edited by NuMPTy (2013-05-30 15:29:43)

Offline

#6 2013-05-30 15:07:28

NuMPTy
Member
From: Canada
Registered: 2011-06-04
Posts: 35

Re: [SOLVED] ifconfig up specific interfaces at boot

Trying that again, looking at journal-xn...

# systemctl start rc-local.service 
Job for rc-local.service failed. See 'systemctl status rc-local.service' and 'journalctl -xn' for details.

-- Unit rc-local.service has begun starting up.
May 30 11:06:05 NiXToP systemd[2427]: Failed at step EXEC spawning /etc/rc.local: Exec format error
-- Subject: Process /etc/rc.local could not be executed
-- Defined-By: systemd
-- Support: [url]http://lists.freedesktop.org/mailman/listinfo/systemd-devel[/url]
-- Documentation: [url]http://www.freedesktop.org/wiki/Software/systemd/catalog/641257651c1b4ec9a8624d7a40a9e1e7[/url]
-- 
-- The process /etc/rc.local could not be executed and failed.
-- 
-- The error number returned while executing this process is 8.
May 30 11:06:05 NiXToP systemd[1]: rc-local.service: control process exited, code=exited status=203
May 30 11:06:05 NiXToP systemd[1]: Failed to start /etc/rc.local Compatibility.
-- Subject: Unit rc-local.service has failed
-- Defined-By: systemd
-- Support: [url]http://lists.freedesktop.org/mailman/listinfo/systemd-devel[/url]
-- Documentation: [url]http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d[/url]
-- 
-- Unit rc-local.service has failed.
-- 
-- The result is failed.

Last edited by NuMPTy (2013-05-30 15:29:11)

Offline

#7 2013-05-30 15:09:26

NuMPTy
Member
From: Canada
Registered: 2011-06-04
Posts: 35

Re: [SOLVED] ifconfig up specific interfaces at boot

Removing the 'compatability' tag I get something slightly different:

-- Unit rc-local.service has begun starting up.
May 30 11:08:25 NiXToP systemd[2484]: Failed at step EXEC spawning /etc/rc.local: Exec format error
-- Subject: Process /etc/rc.local could not be executed
-- Defined-By: systemd
-- Support: [url]http://lists.freedesktop.org/mailman/listinfo/systemd-devel[/url]
-- Documentation: [url]http://www.freedesktop.org/wiki/Software/systemd/catalog/641257651c1b4ec9a8624d7a40a9e1e7[/url]
-- 
-- The process /etc/rc.local could not be executed and failed.
-- 
-- The error number returned while executing this process is 8.
May 30 11:08:25 NiXToP systemd[1]: rc-local.service: control process exited, code=exited status=203
May 30 11:08:25 NiXToP systemd[1]: Failed to start /etc/rc.local.
-- Subject: Unit rc-local.service has failed
-- Defined-By: systemd
-- Support: [url]http://lists.freedesktop.org/mailman/listinfo/systemd-devel[/url]
-- Documentation: [url]http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d[/url]
-- 
-- Unit rc-local.service has failed.
-- 
-- The result is failed.
May 30 11:08:25 NiXToP systemd[1]: Unit rc-local.service entered failed state.

Last edited by NuMPTy (2013-05-30 15:28:55)

Offline

#8 2013-05-30 15:22:43

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] ifconfig up specific interfaces at boot

please use [ code ] tags.

Something like this should work. It may not be the most elegant solution, but it beats using crappy old rc.local.

(this is untested wink )

# /etc/systemd/system/interface-up@.service
[Unit]
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=oneshot
ExecStart=/usr/sbin/ip link set %i up

[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl enable interface-up@enp16s0f0 interface-up@enp16s0f1

Last edited by 65kid (2013-05-30 15:31:41)

Offline

#9 2013-05-30 15:28:05

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,095
Website

Re: [SOLVED] ifconfig up specific interfaces at boot

65kid wrote:

please use [ code ] tags.

Definitely this. On a related note, if you're just adding more relevant information, the edit function on your post is probably better than posting multiple times.

Something like this should work. It may not be the most elegant solution, but it beats using crappy old rc.local

[...]

This is pretty much what I would recommend. I've seen several people make rc-local compatibility services, but I've never liked that idea (systemd should manage your services--that's its purpose--it shouldn't start something else to do so, imho).

All the best,

-HG

P.S., 65kid's solution would be enabled using something like the following:

# systemctl enable interface-up@<interfacename>.service

Done for each interface you wish to be brought up on-boot.

Last edited by HalosGhost (2013-05-30 15:29:51)

Offline

#10 2013-05-30 15:31:08

NuMPTy
Member
From: Canada
Registered: 2011-06-04
Posts: 35

Re: [SOLVED] ifconfig up specific interfaces at boot

I just assumed there weren't any code tags since I didn't see a button, my bad (fixed!).

Will update this post (and not make a new one...) when I try this out.

Thanks again for all of the help!

Edit: It worked perfectly, thank you again!

Last edited by NuMPTy (2013-05-30 15:39:25)

Offline

#11 2013-12-21 23:10:27

GSF1200S
Member
Registered: 2008-12-24
Posts: 474

Re: [SOLVED] ifconfig up specific interfaces at boot

65kid wrote:

please use [ code ] tags.

Something like this should work. It may not be the most elegant solution, but it beats using crappy old rc.local.

(this is untested wink )

# /etc/systemd/system/interface-up@.service
[Unit]
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=oneshot
ExecStart=/usr/sbin/ip link set %i up

[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl enable interface-up@enp16s0f0 interface-up@enp16s0f1

Sort of pushing whether this is a necro thread, but ill try.

Im relatively new to dealing with systemd services. I am attempting to put a network interface down at bootup. This is a laptop and the ethernet card sucks 5 watts of juice and I dont even use it. If i do:

sudo ip link set enp0s25 down

the device shuts down, and immediately I can watch my power consumption drop in powertop.

At first, I tried the rc.local compatibility route, but it didnt work. I have checked the Arch wiki and noted its explanation of how to start services with systemd, and I have ended up here via google. I did the above quoted, only i changed the name, commented portion at top, and ip commands to "down" instead of up. I then used:

sudo systemctl enable interface-down@enp0s25.service

and note that it ln's as usual. However, the device still starts at boot. Again, I can immediately put it down by manually entering the ip command.

I can follow the process of systemd by reading your replies, but admittedly I have no idea what %i designates. I am hoping someone can tell me what I am obviously missing, because im at the point of just adding a single command exception to sudo and executing the command with xinit/openbox autostart when I startx. Trying to do it the right way though..

I have checked the systemd log, and the only thing I can find relating to the device is that systemd renames it from eth0 to enp0s25 during the boot process. I even tried creating a systemd service for eth0 figuring maybe systemd attempts to run my enp0s25 service BEFORE its actually labeled that (as systemd hasnt renamed it from eth0 yet), but that didnt work either. Any ideas on what I might be missing?

Last edited by GSF1200S (2013-12-21 23:11:43)

Offline

Board footer

Powered by FluxBB