I am using Ubuntu Server 18.04.1 LTS (Bionic Beaver). I run OpenVPN with redirect-gateway disabled because I don't want traffic to use it by default, only one specific application. This is the command i use:
sudo openvpn --config /etc/openvpn/CA\ Montreal.ovpn --pull-filter ignore redirect-gateway --daemon
And then if I use the following command:
curl http://ipinfo.io/ip --interface tun0
I get my real external IP address, not my VPN address. But if I run the command:
sudo curl http://ipinfo.io/ip --interface tun0
I then get my VPN IP address. I am experiencing this issue in other programs too, such as traceroute.
$ traceroute 1.1.1.1 -i tun0
traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets
setsockopt SO_BINDTODEVICE: Operation not permitted
$ sudo traceroute 1.1.1.1 -i tun0
traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets
1 10.21.10.1 (10.21.10.1) 73.600 ms 74.061 ms 74.045 ms
2 199.229.249.253 (199.229.249.253) 74.041 ms 199.229.249.254 (199.229.249.254) 74.193 ms 199.229.249.253 (199.229.249.253) 73.995 ms
3 199.229.249.6 (199.229.249.6) 73.991 ms 74.143 ms 199.229.249.2 (199.229.249.2) 74.021 ms
4 ae7-67.cr0-mtl1.ip4.gtt.net (98.124.173.249) 74.065 ms ae7-103.cr0-mtl1.ip4.gtt.net (98.124.173.101) 74.113 ms 74.162 ms
5 cloudflare-gw.cr0-mtl1.ip4.gtt.net (69.174.23.50) 74.210 ms 74.157 ms 74.384 ms
6 one.one.one.one (1.1.1.1) 74.052 ms 73.802 ms 73.843 ms
How do I fix it so a program doesn't need root to go through the VPN?