# [solved] systemd, dhclient and wpa_supplicant

## elmar283

For the fun of it I'm checking out wether I like sytemd or not. So I set up an working Gentoo Linux Box with systemd.

This machine has been a router in the past. Basicly it sets up a static ip-adres on the ethernet enp2s0 and a wireless connection with wpa_supplicant en dhclient (part of dhcp) with wlp3s0.

The static part is covert. I have made my own script so it sets this up.

Now for the wireless part I first wanted to know if systemd could use this card with wpa_supplicant and dhclient at all. So I installed xfce4, nm_applet and networkmanager. Result: works perfect!  :Very Happy: .

But this is not what I want. I do not want to use networkmanager. 

I used the have net.wlp3s0 and a config at /etc/conf.d/net like this:

```

config_wlp3s0="dhcp"

iwconfig_wlp3s0="mode managed"

modules_wlp3s0="wpa_supplicant dhclient"

wpa_supplicant_wlp3s0="-Dwext -c /etc/wpa_supplicant/wpa_supplicant.conf"

wpa_timeout_wlp3s0=60

associate_timeout_wlp3s0=60

dhcp_wlp3s0="release"

config_enp2s0="10.0.0.1 netmask 255.255.255.0 brd 10.0.0.255 promisc"

associate_timeout_enp2s0=60

dns_servers="194.109.6.66 8.8.8.8"

associate_timeout_enp2s0=60

```

I read the information on ArchWiki (https://wiki.archlinux.org/index.php/WPA_supplicant#Enabling_with_systemd), but that is much to technical and not practical. By googleing I didn't find the answer ether.

Can someone help me with this? And maybe it is a good idea to add this to the installation handbook?

To help what I would like is a scrip on /etc/systemd/system/wlp3s0.service or something like that. Or another way to first activate wpa_supplicant true wpa_supplicant@.service and then get an ip-addres with a script that trigers 'dhclient wlp3s0'Last edited by elmar283 on Sun Jul 20, 2014 3:31 pm; edited 1 time in total

----------

## elmar283

I have found a part of the sollution. 

This is my config now:

```

/etc/systemd/system $ cat syslog.service 

[Unit]

Description=System Logger Daemon

Documentation=man:syslog-ng(8)

[Service]

Sockets=syslog.socket

ExecStart=/usr/sbin/syslog-ng -F

ExecReload=/bin/kill -HUP $MAINPID

StandardOutput=null

Restart=on-failure

[Install]

WantedBy=multi-user.target

Alias=syslog.service

elmarotter@zaphodbeeblebrox /etc/systemd/system $ cat wlp3s0.service 

[Unit] 

Description=Dhclient connection with wpa_supplicant

After=local-fs.target 

Documentation=man:ifconfig(8) 

Documentation=man:route(8) 

[Service] 

Type=oneshot 

RemainAfterExit=yes 

ExecStart=/usr/sbin/wpa_supplicant -D wext -B -i wlp3s0 -c /etc/wpa_supplicant/wpa_supplicant.conf

#ExecStart=/sbin/dhclient -e PEER_DNS=no -e IF_METRIC=10 -q -1 -pf /var/run/dhclient-wlp3s0.pid wlp3s0

ExecStart=/sbin/dhclient -e IF_METRIC=10 -q -pf /var/run/dhclient-wlp3s0.pid wlp3s0

[Install] 

WantedBy=multi-user.target 

```

```

 /etc/systemd/system $ cat static-network.service 

[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 enp2s0 10.0.0.1 broadcast 10.0.0.255 netmask 255.255.255.0 up 

ExecStart=/bin/route add default gw 10.0.0.1 enp2s0 

[Install] 

WantedBy=multi-user.target 

```

Now I'm going to check wether stopping the services stops the interfaces. 

My guess is that it will not. I will let it know as soon as I know.

----------

## elmar283

Okey, All works fine:

```

/etc/systemd/system $ cat static-network.service 

[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 enp2s0 10.0.0.1 broadcast 10.0.0.255 netmask 255.255.0.0 promisc up  

#ExecStart=/bin/route add default gw 10.0.0.1 enp2s0 

ExecStop=/bin/ifconfig enp2s0 down

[Install] 

WantedBy=multi-user.target 

```

```

etc/systemd/system $ cat wlp3s0.service 

[Unit] 

Description=Dhclient connection with wpa_supplicant

After=local-fs.target 

Documentation=man:ifconfig(8) 

Documentation=man:route(8) 

[Service] 

Type=oneshot 

RemainAfterExit=yes 

ExecStart=/usr/sbin/wpa_supplicant -D wext -B -i wlp3s0 -c /etc/wpa_supplicant/wpa_supplicant.conf

#ExecStart=/sbin/dhclient -e PEER_DNS=no -e IF_METRIC=10 -q -1 -pf /var/run/dhclient-wlp3s0.pid wlp3s0

ExecStart=/sbin/dhclient -e IF_METRIC=10 -q -pf /var/run/dhclient-wlp3s0.pid wlp3s0

ExecStop=/bin/ifconfig wlp3s0 down

[Install] 

WantedBy=multi-user.target 

```

----------

## EmaRsk

Nice  :Smile: 

Maybe you could put this on the wiki.

----------

