public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Systemd and static network
@ 2013-07-25 10:46 Michael Hampicke
  2013-07-25 12:18 ` Douglas J Hunley
  2013-07-25 15:42 ` Canek Peláez Valdés
  0 siblings, 2 replies; 12+ messages in thread
From: Michael Hampicke @ 2013-07-25 10:46 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 590 bytes --]

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?

Have a nice day,
Mike


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  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 15:05   ` Michael Hampicke
  2013-07-25 15:42 ` Canek Peláez Valdés
  1 sibling, 2 replies; 12+ messages in thread
From: Douglas J Hunley @ 2013-07-25 12:18 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

On Thu, Jul 25, 2013 at 6:46 AM, Michael Hampicke <mh@hadt.biz> wrote:

> What do you use - and what are the benefits of your method?


Why not continue to use DHCP and simply set a static assignment based on
the MAC inside the DHCP server? Then it doesn't matter how the system is
setup, it just works...


-- 
Douglas J Hunley (doug.hunley@gmail.com)
Twitter: @hunleyd                                               Web:
douglasjhunley.com
G+: http://goo.gl/sajR3

[-- Attachment #2: Type: text/html, Size: 988 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  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 15:05   ` Michael Hampicke
  1 sibling, 1 reply; 12+ messages in thread
From: Pavel Volkov @ 2013-07-25 13:23 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

On Thursday 25 July 2013 08:18:00 Douglas J Hunley wrote:




On Thu, Jul 25, 2013 at 6:46 AM, Michael Hampicke <mh@hadt.biz[1]> 
wrote:


What do you use - and what are the benefits of your method?


Systemd will not read /etc/conf.d/net like /etc/init.d/net.* scripts do. You 
need some service that will prepare the network.
I personally prefer netctl, it is KISS enough. It was me who asked the devs 
to add it to the tree :)
I tried NM too, it does not work out of the box with systemd, there are 
several issues.


--------
[1] mailto:mh@hadt.biz

[-- Attachment #2: Type: text/html, Size: 2428 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-25 13:23   ` Pavel Volkov
@ 2013-07-25 13:26     ` Pavel Volkov
  2013-07-25 13:28       ` Pavel Volkov
  0 siblings, 1 reply; 12+ messages in thread
From: Pavel Volkov @ 2013-07-25 13:26 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

On Thursday 25 July 2013 17:23:56 I wrote:


Systemd will not read /etc/conf.d/net like /etc/init.d/net.* 
scripts do. You need some service that will prepare the 
network.
I personally prefer netctl, it is KISS enough. It was me who 
asked the devs to add it to the tree :)
I tried NM too, it does not work out of the box with systemd, 
there are several issues.




[-- Attachment #2: Type: text/html, Size: 1607 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-25 13:26     ` Pavel Volkov
@ 2013-07-25 13:28       ` Pavel Volkov
  0 siblings, 0 replies; 12+ messages in thread
From: Pavel Volkov @ 2013-07-25 13:28 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 119 bytes --]

KMail is messing with my 
emails here, quotations in 
sent letters are not the way 
they used to look in edit mode 
:)

[-- Attachment #2: Type: text/html, Size: 578 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-25 12:18 ` Douglas J Hunley
  2013-07-25 13:23   ` Pavel Volkov
@ 2013-07-25 15:05   ` Michael Hampicke
  1 sibling, 0 replies; 12+ messages in thread
From: Michael Hampicke @ 2013-07-25 15:05 UTC (permalink / raw
  To: gentoo-user

Am 2013-07-25 14:18, schrieb Douglas J Hunley:
> On Thu, Jul 25, 2013 at 6:46 AM, Michael Hampicke <mh@hadt.biz> wrote:
> 
>> What do you use - and what are the benefits of your method?
> 
> Why not continue to use DHCP and simply set a static assignment based
> on the MAC inside the DHCP server? Then it doesn't matter how the
> system is setup, it just works...
> 

There's no DHCP in this particular offsite data center :-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-25 10:46 [gentoo-user] Systemd and static network Michael Hampicke
  2013-07-25 12:18 ` Douglas J Hunley
@ 2013-07-25 15:42 ` Canek Peláez Valdés
       [not found]   ` <51F1D5D2.6030200@gentoo.org>
                     ` (2 more replies)
  1 sibling, 3 replies; 12+ messages in thread
From: Canek Peláez Valdés @ 2013-07-25 15:42 UTC (permalink / raw
  To: gentoo-user

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [gentoo-user] Re: Systemd and static network
       [not found]   ` <51F1D5D2.6030200@gentoo.org>
@ 2013-07-26  2:13     ` Canek Peláez Valdés
  0 siblings, 0 replies; 12+ messages in thread
From: Canek Peláez Valdés @ 2013-07-26  2:13 UTC (permalink / raw
  To: Jonathan Callen; +Cc: gentoo-user

On Thu, Jul 25, 2013 at 8:50 PM, Jonathan Callen <jcallen@gentoo.org> wrote:
> On 07/25/2013 11:42 AM, Canek Peláez Valdés wrote:
>> On Thu, Jul 25, 2013 at 5:46 AM, Michael Hampicke <mh@hadt.biz>
>> wrote:
>>> 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>
>> #
> -------------------------------------------------------------------------------------------
>>
>
> I would recommend replacing those two commands with:
>
> ExecStart=/bin/ip addr add <IP>/<CIDR> dev <DEVICE>
> ExecStart=/bin/ip route add default via <GW> dev <DEVICE>
>
> This uses the newer iproute2 infrastructure, which is supposed to
> replace the deprecated net-tools package (last official release was in
> 2001).
>
> Note also that this uses the CIDR notation for IP addresses.  If you
> were previously using "ifconfig eth0 192.168.1.5 broadcast
> 192.168.1.255 netmask 255.255.255.0", you can simply say "ip addr add
> 192.168.1.5/24 dev eth0" which calculates both netmask and broadcast
> from the "/24" (which means the upper 24 bits are used).

Thanks for the heads up.

Regards.
-- 
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-25 15:42 ` Canek Peláez Valdés
       [not found]   ` <51F1D5D2.6030200@gentoo.org>
@ 2013-07-26  4:46   ` Michael Hampicke
  2013-07-26  5:34     ` Keith Dart
  2013-07-26  9:26   ` Stefan G. Weichinger
  2 siblings, 1 reply; 12+ messages in thread
From: Michael Hampicke @ 2013-07-26  4:46 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 2294 bytes --]

Am 25.07.2013 17:42, schrieb Canek Peláez Valdés:
> 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.
> 

Tanks. I will give netctl a try in a VM. For now, on real machines, I am
going with the unit you suggested.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-26  4:46   ` [gentoo-user] " Michael Hampicke
@ 2013-07-26  5:34     ` Keith Dart
  0 siblings, 0 replies; 12+ messages in thread
From: Keith Dart @ 2013-07-26  5:34 UTC (permalink / raw
  To: gentoo-user; +Cc: mh

Re
CADPrc803kq_c76b1oqp3PksvDgyP5MD+zqLGqcsxk=eCT2iYRA@mail.gmail.comCADPrc803kq_c76b1oqp3PksvDgyP5MD+zqLGqcsxk=eCT2iYRA@mail.gmail.com51F10221.1080807@hadt.biz,
Michael Hampicke said:
> Tanks. I will give netctl a try in a VM. For now, on real machines, I
> am going with the unit you suggested.


I'm using netctl on one VM now. I'm... ok with it. for now... it did
seem to break during one update, so I think it's still in flux. And the
configuration is a bit confusing. 


-- Keith


-- 

-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Keith Dart <keith@dartworks.biz>
   public key: ID: 19017044
   <http://www.dartworks.biz/>
   =====================================================================


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-25 15:42 ` Canek Peláez Valdés
       [not found]   ` <51F1D5D2.6030200@gentoo.org>
  2013-07-26  4:46   ` [gentoo-user] " Michael Hampicke
@ 2013-07-26  9:26   ` Stefan G. Weichinger
  2013-07-26 11:35     ` Michael Hampicke
  2 siblings, 1 reply; 12+ messages in thread
From: Stefan G. Weichinger @ 2013-07-26  9:26 UTC (permalink / raw
  To: gentoo-user

Am 25.07.2013 17:42, schrieb Canek Peláez Valdés:

>> What do you use - and what are the benefits of your method?
> 
> I use the following unit in one of my servers:
> 
> # -------------------------------------------------------------------------------------------
> [Unit]


My current version, using "ip" :

# cat network.service
[Unit]
Description=Network Connectivity

[Service]
Type=oneshot
RemainAfterExit=yes

EnvironmentFile=/etc/conf.d/network_systemd
ExecStart=/bin/ip link set dev ${interface} up
ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast}
dev ${interface}
ExecStart=/bin/ip route add default via ${gateway}

ExecStop=/bin/ip addr flush dev ${interface}	
ExecStop=/bin/ip link set dev ${interface} down

[Install]
WantedBy=network.target

----- so that unitfile does not have to be touched again and you only
edit /etc/conf.d/network_systemd ->

# cat /etc/conf.d/network_systemd
PATH=/sbin:/usr/sbin
interface=p4p1
address=192.x.y.z
netmask=255.255.255.0
broadcast=192.x.y.zz
gateway=192.x.y.zzz

-----

I have a second unitfile with a more complicated setup for bridging
(with KVM).

Stefan



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [gentoo-user] Systemd and static network
  2013-07-26  9:26   ` Stefan G. Weichinger
@ 2013-07-26 11:35     ` Michael Hampicke
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Hampicke @ 2013-07-26 11:35 UTC (permalink / raw
  To: gentoo-user

Am 2013-07-26 11:26, schrieb Stefan G. Weichinger:
> Am 25.07.2013 17:42, schrieb Canek Peláez Valdés:
> 
>>> What do you use - and what are the benefits of your method?
>> 
>> I use the following unit in one of my servers:
>> 
>> # 
>> -------------------------------------------------------------------------------------------
>> [Unit]
> 
> 
> My current version, using "ip" :
> 
> # cat network.service
> [Unit]
> Description=Network Connectivity
> 
> [Service]
> Type=oneshot
> RemainAfterExit=yes
> 
> EnvironmentFile=/etc/conf.d/network_systemd
> ExecStart=/bin/ip link set dev ${interface} up
> ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast}
> dev ${interface}
> ExecStart=/bin/ip route add default via ${gateway}
> 
> ExecStop=/bin/ip addr flush dev ${interface}
> ExecStop=/bin/ip link set dev ${interface} down
> 
> [Install]
> WantedBy=network.target
> 
> ----- so that unitfile does not have to be touched again and you only
> edit /etc/conf.d/network_systemd ->
> 
> # cat /etc/conf.d/network_systemd
> PATH=/sbin:/usr/sbin
> interface=p4p1
> address=192.x.y.z
> netmask=255.255.255.0
> broadcast=192.x.y.zz
> gateway=192.x.y.zzz
> 
> -----
> 
> I have a second unitfile with a more complicated setup for bridging
> (with KVM).
> 
> Stefan

Good idea, I already had forgotten that you could parse variables from 
another file in a systemd unit.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-07-26 11:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
     [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox