On Thu, Jul 25, 2013 at 5:46 AM, Michael Hampicke <m...@hadt.biz> wrote: > Howdy folks, > > currently I am migrating some servers to systemd, and I am wondering > what's the best way to set up static networking. Until now, I always > used dhcp + networkmanager (workstations, laptops). > > Some suggested creating your own network unit and manually start > ifconfig/route or ip via ExecStart, some suggested Arch's netctl which > seems to support static addresses and brings a systemd unit file. > > At the moment, following the KISS principle, I tend to a customized unit > file. > > What do you use - and what are the benefits of your method?
I use the following unit in one of my servers: # ------------------------------------------------------------------------------------------- [Unit] Description=Static network service After=local-fs.target Documentation=man:ifconfig(8) Documentation=man:route(8) [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/ifconfig <DEVICE> <IP> broadcast <BCAST> netmask <NETMASK> up ExecStart=/bin/route add default gw <GW> <DEVICE> # ------------------------------------------------------------------------------------------- Obviously, change the necessary parameters. The benefit is that it doesn't get any more simple, I believe. If DHCP is available and I don't want to use NetworkManager, I use the following unit: # ------------------------------------------------------------------------------------------- [Unit] Description=DHCP on %I After=basic.target [Service] ExecStartPre=/bin/ifconfig %I up ExecStart=/sbin/dhcpcd -B %I [Install] WantedBy=multi-user.target # ------------------------------------------------------------------------------------------- You can then enable the unit with: systemctl enable dhcpcd@DEV.service where DEV is enp0s0, or whatever funny name udev gives to your network card. I think I got the unit from Arch, or maybe I wrote; I honestly don't remember. Regards. -- Canek Peláez Valdés Posgrado en Ciencia e Ingeniería de la Computación Universidad Nacional Autónoma de México