public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Canek Peláez Valdés" <caneko@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Systemd and static network
Date: Thu, 25 Jul 2013 10:42:55 -0500	[thread overview]
Message-ID: <CADPrc803kq_c76b1oqp3PksvDgyP5MD+zqLGqcsxk=eCT2iYRA@mail.gmail.com> (raw)
In-Reply-To: <51F10221.1080807@hadt.biz>

On Thu, Jul 25, 2013 at 5:46 AM, Michael Hampicke <mh@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


  parent reply	other threads:[~2013-07-25 15:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-25 10:46 [gentoo-user] Systemd and static network Michael Hampicke
2013-07-25 12:18 ` Douglas J Hunley
2013-07-25 13:23   ` Pavel Volkov
2013-07-25 13:26     ` Pavel Volkov
2013-07-25 13:28       ` Pavel Volkov
2013-07-25 15:05   ` Michael Hampicke
2013-07-25 15:42 ` Canek Peláez Valdés [this message]
     [not found]   ` <51F1D5D2.6030200@gentoo.org>
2013-07-26  2:13     ` [gentoo-user] " Canek Peláez Valdés
2013-07-26  4:46   ` [gentoo-user] " Michael Hampicke
2013-07-26  5:34     ` Keith Dart
2013-07-26  9:26   ` Stefan G. Weichinger
2013-07-26 11:35     ` Michael Hampicke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADPrc803kq_c76b1oqp3PksvDgyP5MD+zqLGqcsxk=eCT2iYRA@mail.gmail.com' \
    --to=caneko@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox