<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;'>It will be super cool if ip/netmask functionality will be addressed by wgconf<br>Currently we testing this systemd units for wireguard ppa:<br>: wireguard.service<br># This service is actually a systemd target,<br># but we are using a service since targets cannot be reloaded.<br><br>[Unit]<br>Description=WireGuard service<br>After=network.target<br><br>[Service]<br>Type=oneshot<br>RemainAfterExit=yes<br>ExecStart=/bin/true<br>ExecReload=/bin/true<br><br>[Install]<br>WantedBy=multi-user.target<br><br>:wireguard@.service<br>[Unit]<br>Description=WireGuard connection to %i<br>PartOf=wireguard.service<br>ReloadPropagatedFrom=wireguard.service<br>Before=systemd-user-sessions.service<br><br>[Service]<br>Type=oneshot<br>EnvironmentFile=-/etc/default/wireguard<br><br># %i is your connection name created from .conf files in /etc/wireguard<br># For ex.: Use systemctl enable wireguard@server.service to enable server example setup<br># You can store unlimited amount of various connections in /etc/wireguard<br><br>ExecStart=/bin/ip link add dev wg%i type wireguard<br>ExecStartPre=/bin/sh -c "/bin/systemctl set-environment ip=$(/usr/bin/head -1 /etc/wireguard/%i.conf | awk '{print $2}')"<br>ExecStart=/bin/ip address add ${ip} dev wg%i<br>ExecStart=/usr/bin/wg setconf wg%i /etc/wireguard/%i.conf<br>ExecStart=/bin/ip link set up dev wg%i<br><br># We can't predict routing in your environment, but we can make it easier to setup in /etc/default/wireguard<br>#ExecStart=/bin/ip route add $0_1 dev wg%i<br>#ExecStart=/bin/ip route add $128_1 dev wg%i<br>#ExecStart=/bin/ip add $demo via $common_router dev eth0<br>#ExecStart=/bin/ip route add <br>#ExecStart=/bin/ip route add <br>#ExecStart=/bin/ip route add <br>#ExecStart=/bin/ip route add <br><br>ExecReload=/bin/ip link del dev wg%i<br><br>[Install]<br>WantedBy=multi-user.target<br>:/etc/default/wireguard<br># Common values could help you setup routing faster<br># You can set routing rules in /lib/systemd/wireguard@.service file<br><br>0_1="0.0.0.0/1"<br>128_1="128.0.0.0/1"<br># demo.wireguard.io<br>demo="163.172.161.0/32"<br>common_router="192.168.1.1"<br><br>And test files:<br>: server.conf<br># 192.168.177.1/24<br># Since you need to set ip address manually with ip or ifconfig we use workaround and read ip/netmask from first line of every config file<br>[Interface]<br>    # You can generate own public and private keys with: wg genkey | tee privatekey | wg pubkey > publickey<br>    # Its strongly recomended for you to generate own keys!<br>    PrivateKey = qFstR3l2HG5WQJ0qoQG0G87c039kXR5zN7vV+bUKb0Q=<br>    ListenPort = 41414<br><br>[Peer]<br>    PublicKey = 40UuwEq4H1gaY1rpmwuW0hUyOnGvXuoQIMctOyOrEAs=<br>    # Outside world access blocked in example setup<br>    AllowedIPs = 127.0.0.1/32<br>    #AllowedIPs = 0.0.0.0/0<br>:client.conf<br># 192.168.4.5/24<br># Since you need to set ip address manually with ip or ifconfig we use workaround and read ip/netmask from first line of every config file<br>[Interface]<br>    # You can generate own public and private keys with: wg genkey | tee privatekey | wg pubkey > publickey<br>    PrivateKey = WEAuaVuhdyscyTCXVfBDJR6nf9zxD75jmJzrfhkyE3Y=<br><br>[Peer]<br>    PublicKey = Uha1fHzOY6hPhq54fcrElVdNF/XQDzQ90rDT7+IqIgA=<br>    Endpoint = demo.wireguard.io:12912<br>    AllowedIPs = 0.0.0.0/0<br>    PersistentKeepalive = 25<br><br>After some talking with  <span title="Egbert Verhage <egbert@eggiecode.org>">Egbert, I think to move routing to separate unit, but still read routing configuration from conf files. I just like ovpn way, when for user is just enough to copy single configuration file.<br>If ip/netmask and routing will be done with wgconf, and will be located inside single config file, this will be huge success for all users.<br></span><br></div></body></html>