Last active
February 16, 2021 09:49
-
-
Save scmanjarrez/adb44492a63ca2116d589bc7121af187 to your computer and use it in GitHub Desktop.
fix routing (ssh) when connected to openvpn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://serverfault.com/questions/659955/allowing-ssh-on-a-server-with-an-active-openvpn-client | |
# https://serverfault.com/a/660106 | |
ip rule add from x.x.x.x table 128 | |
ip route add table 128 to y.y.y.y/y dev ethX | |
ip route add table 128 default via z.z.z.z | |
# Where x.x.x.x is your public IP, y.y.y.y/y should be the subnet | |
# of your public IP address, ethX should be your public Ethernet | |
# interface, and z.z.z.z should be the default gateway. | |
# Note that this hasn't worked for me (using Debian and PrivateInternetAccess) | |
# but may help you out. | |
# https://serverfault.com/a/918441 | |
ip rule add from $(ip route get 1 | grep -Po '(?<=src )(\S+)') table 128 | |
ip route add table 128 to $(ip route get 1 | grep -Po '(?<=src )(\S+)')/32 dev $(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)') | |
ip route add table 128 default via $(ip -4 route ls | grep default | grep -Po '(?<=via )(\S+)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment