Housten, I have a problem …
At work I have to use a VPN connection. Currently there is set up a (so called) SSH jump-host, that only accepts connections from outside the internal/VPN network.
Problem with that: If the VPN connection is up it’s not possible to SSH to the jump-host anymore, because my local machine (with the VPN connection) has an internal IP address and is not allowed to connect to the jump-host.
Solution
I created a udev rule for the VPN interface tun0
.
That rules worke like this: Create a new route (to the jump-host) over my default network interface if the VPN connection is up and delete that rule if tun0
wents down.
And here are this udev rules for you – and myself … 🙂
- Create the file with/for both udev rules as
root
(you can freely name the file as you want):/etc/udev/rules.d/99-tun0.rules
- Insert the following two lines/rules, replace
2.2.2.2
with the jump-host IP1.1.1.1
your local gateway IPdefault_interface
with your local/default network interface (for me it’swlp2s0
; you can useip addr
to see all interfaces)
- Restart (as
root
) the udev service:systemctl status udev
KERNEL=="tun0", ACTION=="add", RUN+="/sbin/ip route add 2.2.2.2 via 1.1.1.1 dev default_interface"
KERNEL=="tun0", ACTION=="remove", RUN+="/sbin/ip route delete 2.2.2.2 via 1.1.1.1 dev default_interface"
Housten, the problem is fixed …
Thanks (for hints and inspiration) to
- https://www.cyberciti.biz/faq/ip-route-add-network-command-for-linux-explained/
- https://askubuntu.com/a/546812
- https://askubuntu.com/a/797298
- 0
- 0
- 0
- 0