You are not logged in.

#1 2012-06-02 15:26:00

PaulBx1
Member
Registered: 2008-10-18
Posts: 142

[SOLVED] static ethernet setup under systemd?

With sysv bootup I did not install netcfg or networkmanager, just used the lines in rc.conf for my static ethernet. Life was simple, everything worked.

Now with systemd I'm getting the impression rc.conf is not run at all during boot, correct? So I'm trying to figure out how to set up my network under it. The documentation is pretty thin.

The wiki says, "For static, wireless or advanced network configuration like bridging you can use netcfg or NetworkManager which both provide systemd service files." Well, I don't want to install these packages. They just add more complication, more things I have to keep straight. They depart from the "arch way".

Well, I tried installing netcfg anyway just to get at whatever special files it included in the package for systemd, but I can't figure that out either. The netcfg wiki page says,

systemd support

Since version 2.8.2 netcfg provides systemd unit files. The service files net-auto-wireless.service and net-auto-wired.service correspond to the initscripts daemons /etc/rc.d/net-auto-wireless and /etc/rc.d/net-auto-wired. To connect to multiple profiles at boot you can use netcfg.service which is equivalent to /etc/rc.d/net-profiles and starts all profiles specified in the NETWORKS array in /etc/conf.d/netcfg. These service files can be enabled and started with systemctl as usual.

Alternatively you can use the template service file netcfg@.service that allows you to connect to a single profile on boot without having to specify it in /etc/conf.d/netcfg. To specify the desired profile, create a corresponding symlink to /etc/systemd/system/multi-user.target.wants:

# ln -s /usr/lib/systemd/system/netcfg@.service /etc/systemd/system/multi-user.target.wants/netcfg@<profile-name>.service

I can't figure it out.

What do I do to get static ethernet working without netcfg or networkmanager?

Last edited by PaulBx1 (2012-06-02 16:32:05)

Offline

#2 2012-06-02 15:30:37

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: [SOLVED] static ethernet setup under systemd?

Looks like someone edited the wiki removing this info... You need two files:

$ cat /etc/conf.d/network
interface=eth0
address=192.168.1.201
netmask=255.255.255.0
broadcast=192.168.1.255
gateway=192.168.1.1
$ cat /etc/systemd/system/network.service 
[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target
 
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down

[Install]
WantedBy=multi-user.target

Last edited by graysky (2012-06-02 15:31:07)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2012-06-02 15:36:03

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

Re: [SOLVED] static ethernet setup under systemd?

there was a custom file for this on the systemd wiki page:
see https://wiki.archlinux.org/index.php?ti … did=201219

but I don't really see the point. netcfg doesn't pull in any additional dependencies when you just use a static ethernet configuration, and creating a custom service file instead imho does "add more complication" than using a simple netcfg profile. Anyway, I think we could add this custom file to the Systemd/Services wiki page, I will have a look into it.

There also is a network.service in systemd-arch-units which basically emulates the old /etc/rc.d/network .

Offline

#4 2012-06-02 16:22:19

PaulBx1
Member
Registered: 2008-10-18
Posts: 142

Re: [SOLVED] static ethernet setup under systemd?

Thanks graysky, that worked, although I needed 65kid's link to the old text to get the systemctl commands.

In my opinion this method is preferable to depending on netcfg. For one thing, it presents a simple mindless recipe for people to get their networking running. It localizes the control in two simple files, one of them already familiar. And it gives a path to added competence in the systemd regime.

Going the netcfg route on the other hand requires one to become familiar with a particular networking package, which will not please people who didn't use any package (like me) or those who prefer something different. It also moves away from the "arch way". And "a simple netcfg profile" is only simpler than the custom service file if one is already familiar with netcfg; otherwise more effort has to be expended learning how netcfg works. I'd rather spend my time learning how systemd works. Finally it makes the documentation a mess, at least from the point of view of the user (e.g. how does one separate what is needed in netcfg under the sysv regime from that in the systemd regime?).

Last edited by PaulBx1 (2012-06-02 16:27:45)

Offline

#5 2012-06-02 16:33:40

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

Re: [SOLVED] static ethernet setup under systemd?

fair enough, I added the service file to the Systemd/Services page and added a link on the systemd wiki.

Offline

#6 2012-06-02 17:24:38

PaulBx1
Member
Registered: 2008-10-18
Posts: 142

Re: [SOLVED] static ethernet setup under systemd?

Thanks for the quick response to my issue, guys!

Offline

Board footer

Powered by FluxBB