#cat /usr/lib/systemd/system/vpn-restore.service
Description=Template Settings Service
#After=network.target
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/sbin/vpn-service
[Install]
WantedBy=multi-user.target
#cat /usr/local/sbin/vpn-service
#!/usr/bin/env bash
/usr/bin/nmcli connection up id myvpn
/usr/sbin/iptables -t nat -A POSTROUTING -s 192.168.17.0/24 -j MASQUERADE
Если сделать на запущенной системе:
systemctl start vpn-restore.service
То все прекрасно запускается.
А вот при рестарте системы - нет.
systemctl status vpn-restore.service
○ ipt-restore.service - Template Settings Service
Loaded: loaded (/usr/lib/systemd/system/vpn-restore.service; enabled; preset: disabled)
Active: inactive (dead) since Wed 2023-11-08 14:27:21 MSK; 36s ago
Duration: 424ms
Process: 1156 ExecStart=/usr/local/sbin/vpn-service (code=exited, status=0/SUCCESS)
Main PID: 1156 (code=exited, status=0/SUCCESS)
CPU: 31ms
ноя 08 14:27:21 dragonfly systemd[1]: Started ipt-restore.service - Template Settings Service.
ноя 08 14:27:21 dragonfly vpn-service[1158]: Ошибка: сбой активации подключения: The base device for the VPN connection was not active.
ноя 08 14:27:21 dragonfly systemd[1]: ipt-restore.service: Deactivated successfully.