Hi!
I am newby here, it is my first skill in router settings.
I have got router (ASUS RT-AX53U) with openwrt (5.15.134) as VPN OpenConnect server.
I want that on VPN connection (interface vpns0 creation) from client several routes were added.
What I did:
# cd /etc/hotplug.d/iface
# ls -l
-rw-r--r-- 1 root root 155 Oct 10 2023 00-netstate
-rw-r--r-- 1 root root 498 Oct 10 2023 20-firewall
I've created 20-vpns0-route (vi 20-vpns0-route)
# cat 20-vpns0-route
#!/bin/sh
[ "$ACTION" = "ifup" ] && [ "$INTERFACE" = "vpns0" ] && {
logger -t vpns0-route "Adding routes to 192.168.51.0/24 and 192.168.50.0/24 through 192.168.93.0/24"
ip route add 192.168.51.0/24 via 192.168.93.220
ip route add 192.168.50.0/24 via 192.168.93.1
}
[ "$ACTION" = "ifdown" ] && [ "$INTERFACE" = "vpns0" ] && {
logger -t vpns0-route "Removing routes to 192.168.51.0/24 and 192.168.50.0/24 through 192.168.93.0/24"
ip route del 192.168.51.0/24 via 192.168.93.220
ip route del 192.168.50.0/24 via 192.168.93.1
}
then reboot. and it does not work.
# ls -l /etc/hotplug.d/iface
-rw-r--r-- 1 root root 155 Oct 10 2023 00-netstate
-rw-r--r-- 1 root root 498 Oct 10 2023 20-firewall
-rw-r--r-- 1 root root 631 Oct 7 17:26 20-vpns0-route
logread shows nothing
# logread | grep vpns
#
As far as I understand, here attribute 'executable' is not necessary. I tried both on and off with the same result. Moreover, "default" scripts in this folder have no 'executable' attribute. At least, 20-firewall does something and writes to log.
May be some package or service(s) not installed? Which ones should be?
I received this router "as is" and did not install any packages and/or services.
So, please help me to solve this simpliest for you issue.
Thank for your response but did I write about OpenVPN? (It was OpenConnect)
All info at your link related to OpenVPN but I do not use this service/server/package(s) and did not install ones.
No, as netifd's function call_hotplug is the one that invokes /sbin/hotplug-call. However, I don't know how his interface is being brought up or down, and its relationship with netifd.
Also note that nothing prevents other programs or scripts from invoking /sbin/hotplug-call, thus providing hotplug support by themselves.
it seems, neighbouring to my one script (20-firewall) does. at least, after reboot I can see:
# logread | grep firewall
Fri Oct 11 16:30:11 2024 user.notice ucitrack: Setting up /etc/config/luci-splash reload dependency on /etc/config/firewall
Fri Oct 11 16:30:11 2024 user.notice ucitrack: Setting up /etc/config/qos reload dependency on /etc/config/firewall
Fri Oct 11 16:30:11 2024 user.notice ucitrack: Setting up /etc/config/miniupnpd reload dependency on /etc/config/firewall
Fri Oct 11 16:30:12 2024 user.notice firewall: Reloading firewall due to ifup of lan (br-lan)
Fri Oct 11 16:30:15 2024 user.notice firewall: Reloading firewall due to ifup of wan (wan)
If you insist on using a hotplug script, you should use the network-related events (/etc/hotplug.d/net/). Just change the action from ifup/ifdown to add/remove.
Here are the logged events when an OpenConnect client connects/disconnects to the server.
Thank for your offer! I'll try.
By the way, what should I use $DEVICE or $INTERFACE?
I am just newby, it is only manner I've found. If there is/are other(s) one(s) which normally using by professionals please give me link(s). I will study.
In the network events, the variable name is DEVICENAME. You can use either $INTERFACE or $DEVICENAME, the value is the same (vpns0)
I was under the impression that @trendy provided you with a link with information on how to solve your problem another way (I haven't read the content).