Since this morning, my ssh session was getting freezed when I run .ovpn
file.
The problem is that the default gateway gets changed by OpenVPN, and that breaks my current SSH connection unless I set up appropriate routes.
I found a solution here. The solution is;
sudo ip rule add from $(ip route get 1 | grep -Po '(?<=src )(\S+)') table 128
sudo 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+)')
sudo ip route add table 128 default via $(ip -4 route ls | grep default | grep -Po '(?<=via )(\S+)')
This created another problem for me. I can connect to .ovpn and have tun0 without freeze problem but when I try to wget a file I get unable to resolve host address
. When I ping nothing comes back, seems like the solution caused me lose internet connection.
Here is the screenshot from route -n
;
What I do?
I setup the server with this script:
Basically I let the script set it up for me. After I have the .ovpn
file, I try to use it on another cloud instance and I get freeze problem. If I use the solution, no freeze but this time internet connection is gone.