Hi
In my previous post I was trying to get wireguard working on my local network, I managed to do this using iptables commands:
to set the table entries:
iptables -A FORWARD -s 172.30.0.0/24 -d 192.168.0.0/24 -i wg0 -o wg0 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -d 172.30.0.0/24 -i wg0 -o wg0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 172.30.0.0/24 -o enp3s0 -j MASQUERADE
this allow me to access the local network from a wireguard device
To clear the table entries I used:
iptables -D FORWARD -i wg0 -j ACCEPT
iptables -D FORWARD -o wg0 -j ACCEPT
iptables -t nat -D POSTROUTING -o enp3s0 -j MASQUERADE
Everything works ok, so I tried adding these entries to wg0.conf. I created a template:
/etc/e-smith/templates-custom/etc/wireguard/wg0.conf
with the following in:
PostUp = iptables -A FORWARD -s 172.30.0.0/24 -d 192.168.0.0/24 -i %i -o %i -j ACCEPT
PostUp = iptables -A FORWARD -s 192.168.0.0/24 -d 172.30.0.0/24 -i %i -o %i -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -s 172.30.0.0/24 -o enp3s0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT
PostDown = iptables -D FORWARD -o %i -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o enp3s0 -j MASQUERADE
then executed
expand-template /etc/wireguard/wg0.conf
But systemctl -l start wg-quick@wg0.service
returns
Job for wg-quick@wg0.service failed because the control process exited with error code. See "systemctl status wg-quick@wg0.service" and "journalctl -xe" for details.
systemctl -l status wg-quick@wg0.service
returns
wg-quick@wg0.service - WireGuard via wg-quick(

for wg0
Loaded: loaded (/usr/lib/systemd/system/wg-quick@.service; enabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/wg-quick@wg0.service.d
└─51koozali.conf
Active: failed (Result: exit-code) since Tue 2023-05-23 17:28:39 BST; 48s ago
Docs: man:wg-quick(

man:wg(
https://www.wireguard.com/ https://www.wireguard.com/quickstart/ https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8 https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8 Process: 1264 ExecStop=/usr/bin/wg-quick down %i (code=exited, status=0/SUCCESS)
Process: 3274 ExecStart=/usr/bin/wg-quick up %i (code=exited, status=1/FAILURE)
Main PID: 3274 (code=exited, status=1/FAILURE)
May 23 17:28:39 server.kjctechnik.com systemd[1]: Starting WireGuard via wg-quick(

for wg0...
May 23 17:28:39 server.kjctechnik.com wg-quick[3274]:
- ip link add wg0 type wireguard
May 23 17:28:39 server.kjctechnik.com wg-quick[3274]:
- wg setconf wg0 /dev/fd/63
May 23 17:28:39 server.kjctechnik.com wg-quick[3274]: Line unrecognized: `PostUp=iptables-AFORWARD-s172.30.0.0/24-d192.168.0.0/24-i%i-o%i-jACCEPT'
May 23 17:28:39 server.kjctechnik.com wg-quick[3274]: Configuration parsing error
May 23 17:28:39 server.kjctechnik.com wg-quick[3274]:
May 23 17:28:39 server.kjctechnik.com systemd[1]: wg-quick@wg0.service: main process exited, code=exited, status=1/FAILURE
May 23 17:28:39 server.kjctechnik.com systemd[1]: Failed to start WireGuard via wg-quick(

for wg0.
May 23 17:28:39 server.kjctechnik.com systemd[1]: Unit wg-quick@wg0.service entered failed state.
May 23 17:28:39 server.kjctechnik.com systemd[1]: wg-quick@wg0.service failed.
var/log/messages :
May 23 17:24:20 server wg-quick:
- ip link add wg0 type wireguard
May 23 17:24:20 server wg-quick:
- wg setconf wg0 /dev/fd/63
May 23 17:24:20 server wg-quick: Line unrecognized: `PostUp=iptables-AFORWARD-s172.30.0.0/24-d192.168.0.0/24-i%i-o%i-jACCEPT'
May 23 17:24:20 server wg-quick: Configuration parsing error
May 23 17:24:20 server wg-quick:
May 23 17:28:39 server wg-quick:
- ip link add wg0 type wireguard
May 23 17:28:39 server wg-quick:
- wg setconf wg0 /dev/fd/63
May 23 17:28:39 server wg-quick: Line unrecognized: `PostUp=iptables-AFORWARD-s172.30.0.0/24-d192.168.0.0/24-i%i-o%i-jACCEPT'
May 23 17:28:39 server wg-quick: Configuration parsing error
May 23 17:28:39 server wg-quick:
it loks like the spaces in the command are being removed, I've checked etc/e-smith/templates-custom/etc/wireguard/wg0.conf
there are no odd characters in the file, i..e the spaces are spaces.
/etc/wireguard/wg0.conf attached