0

i start my VPN client (softEther) with SystemD a OS startup and i have trouble to assignate a static IP to the local interface of vpn client network interface.

There is my SystemD config :

    [Unit]
    Description=SoftEther VPN Client
    After=network.target auditd.service
    ConditionPathExists=!/usr/local/vpnclient/vpnclient/do_not_run

    [Service]
    Type=forking
    EnvironmentFile=-/usr/local/vpnclient/vpnclient
    ExecStart=/usr/local/vpnclient/vpnclient start
    ExecStop=/usr/local/vpnclient/vpnclient stop
    KillMode=process
    Restart=on-failure

    # Hardening
    PrivateTmp=yes
    ProtectHome=yes
    ProtectSystem=full
    ReadOnlyDirectories=/
    ReadWriteDirectories=-/usr/local/vpnclient/vpnclient
    CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID

    [Install]
    WantedBy=multi-user.target

When i start the service, local interface appear but without the static IP that i configure.

    vpn_softether: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet6 fe80::2ac:e9ff:fe7e:289e prefixlen 64 scopeid 0x20<link>
    ether 00:ac:e9:7e:28:9e txqueuelen 1000 (Ethernet)
    RX packets 12 bytes 864 (864.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 20 bytes 1632 (1.5 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

There is my /etc/sysconfig/network-scripts/ifcfg-vpn_softether :

DEVICE="vpn_softether"
HWADDR="00:ac:e9:7e:28:9e"
ONBOOT="yes"
BOOTPROTO=static
NM_CONTROLLED="no"
IPADDR="10.38.0.50"
NETMASK="255.255.255.0"

I need to execute an :

    ifdown vpn_softether && ifup vpn_softether

to be able to have my static IP on the interface :

    vpn_softether: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 10.38.0.50 netmask 255.255.255.0 broadcast 10.38.0.255
    inet6 fe80::2ac:e9ff:fe7e:289e prefixlen 64 scopeid 0x20<link>
    ether 00:ac:e9:7e:28:9e txqueuelen 1000 (Ethernet)
    RX packets 33 bytes 2506 (2.4 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 69 bytes 12308 (12.0 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I will appreciate some tips :)

  • Put the commands in a script and reference the script in ExecStart – Raman Sailopal Nov 17 '17 at 11:38
  • good idea ! can i add execstart directive on my systemD vpnclient service ? Or i need to create a new one ? – piellick Nov 17 '17 at 12:06
  • Add /usr/local/vpnclient/vpnclient start and ifdown vpn_softether && ifup vpn_softether to a script and then reference that created script on the ExecStart line in your systemd service file – Raman Sailopal Nov 17 '17 at 12:17
0

Add:

/usr/local/vpnclient/vpnclient start
ifdown vpn_softether && ifup vpn_softethe

to a script and then reference that created script on the ExecStart line in your systemd service file

0

Thanks Raman !

It could help someone, there is the tricks.

Modified systemD service :

    [Unit]
    Description=SoftEther VPN Client
    After=network.target auditd.service
    ConditionPathExists=!/usr/local/vpnclient/vpnclient/do_not_run

    [Service]
    Type=forking
    EnvironmentFile=-/usr/local/vpnclient/vpnclient
    ExecStart=/usr/local/vpnclient/restart_vpn_eth.sh
    ExecStop=/usr/local/vpnclient/vpnclient stop
    KillMode=process
    Restart=on-failure

    # Hardening
    PrivateTmp=yes
    ProtectHome=yes
    ProtectSystem=full
    ReadOnlyDirectories=/
    ReadWriteDirectories=-/usr/local/vpnclient/vpnclient
    CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID

    [Install]
    WantedBy=multi-user.target

and the script :

    #!/bin/sh

    /usr/local/vpnclient/vpnclient start
    sleep 5
    ifdown vpn_cent
    sleep 5
    ifup vpn_cent

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.