First, this issue becomes a problem only on CentOS8, while it works well on CentOS7. This is the version:
# cat /etc/redhat-release
CentOS Linux release 8.3.2011
I tried to make a service to execute bash commands to change route.
Here is the executable bash /root/route_degrade.sh
:
#!/bin/bash
# ensure router role
echo "1" > /proc/sys/net/ipv4/ip_forward
systemctl start firewalld
firewall-cmd --add-masquerade
#firewall-cmd --add-port=1194/udp
firewall-cmd --add-service=openvpn
# degrade original default router to LAN only router
cloudroute=$(ip route | grep default | cut -d " " -f 3)
if [[ $cloudroute == 10.* ]]; then
ip route add 10.0.0.0/8 via $cloudroute
ip route del default
fi
exit 0
This executable is absolutely OK since I did execute it alone in root directory by ./route_degrade.sh
.
and here is the autoinit.service
in /usr/lib/systemd/system
:
[Unit]
Description=Changes Default route to Route within cloud Permanently
After=firewalld.service
#Before=openvpn@Client_d.service
[Service]
Type=notify
ExecStart=/root/route_degrade.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
But it keeps on failing, even after I reload the service files by systemctl daemon-reload
and restart it, here is the status by systemd
:
● autoinit.service - Changes Default route to Route within cloud Permanently
Loaded: loaded (/usr/lib/systemd/system/autoinit.service; disabled; vendor preset: disabled)
Active: failed (Result: protocol) since Sat 2022-03-26 17:03:18 CST; 17s ago
Process: 6924 ExecStart=/root/route_degrade.sh (code=exited, status=0/SUCCESS)
Main PID: 6924 (code=exited, status=0/SUCCESS)
Mar 26 17:03:17 10-13-107-213 systemd[1]: Starting Changes Default route to Route within cloud Permanently...
Mar 26 17:03:17 10-13-107-213 route_degrade.sh[6924]: Warning: ALREADY_ENABLED: masquerade already enabled in 'public'
Mar 26 17:03:17 10-13-107-213 route_degrade.sh[6924]: success
Mar 26 17:03:18 10-13-107-213 route_degrade.sh[6924]: Warning: ALREADY_ENABLED: 'openvpn' already in 'public'
Mar 26 17:03:18 10-13-107-213 route_degrade.sh[6924]: success
Mar 26 17:03:18 10-13-107-213 systemd[1]: autoinit.service: Failed with result 'protocol'.
Mar 26 17:03:18 10-13-107-213 systemd[1]: Failed to start Changes Default route to Route within cloud Permanently.
I don't know where is wrong, obviously it did execute the bash script and the firewall-cmd
commands threw out success
and it captures the exit code 0. So what does the Failed with result 'protocol'
mean?