I was experimenting with this free OpenVPN config: https://www.freeopenvpn.org/en/cf/russia.php
By itself, without further configuration, this VPN works fine and changes my IP address.
I searched the Internet for solutions and have already tried three different aproaches.
First approach with "openvpn" group. This one actually doesn't account for local subnet, but let's let that slide for now.
First, change iptables rules:
Code: Select all
# add system group
sudo groupadd -r openvpn
# flush tables
sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT DROP
sudo iptables -F
# let vpn talk to internet
sudo iptables -A OUTPUT -j ACCEPT -m owner --gid-owner openvpn
# allow loopback
sudo iptables -A OUTPUT -j ACCEPT -o lo
sudo iptables -A OUTPUT -j ACCEPT -o tun+
# permit established connections
sudo iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED
# refuse all by default
sudo iptables -P OUTPUT DROP
sudo iptables -P INPUT DROP
Code: Select all
write UDP: Operation not permitted (code=1)
Second approach using iptables rules, hardcoding VPN's IP address:
Code: Select all
sudo iptables --flush
sudo iptables --delete-chain
sudo iptables -t nat --flush
sudo iptables -t nat --delete-chain
sudo iptables -P OUTPUT DROP
sudo iptables -A INPUT -j ACCEPT -i lo
sudo iptables -A OUTPUT -j ACCEPT -o lo
sudo iptables -A INPUT --src 192.168.0.0/24 -j ACCEPT -i eth0
sudo iptables -A OUTPUT -d 192.168.0.0/24 -j ACCEPT -o eth0
sudo iptables -A OUTPUT -j ACCEPT -d 46.48.181.129 -o eth0 -p udp -m udp --dport 1195
sudo iptables -A INPUT -j ACCEPT -s 46.48.181.129 -i eth0 -p udp -m udp --sport 1195
sudo iptables -A INPUT -j ACCEPT -i tun0
sudo iptables -A OUTPUT -j ACCEPT -o tun0
The error doesn't appear, openvpn's output looks successful, but even then Internet or simple "ping" to google.com don't work at all (I replaced MAC address in the log with <snip>):
Code: Select all
Thu Jul 4 17:10:38 2019 OpenVPN 2.4.0 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Oct 14 2018
Thu Jul 4 17:10:38 2019 library versions: OpenSSL 1.0.2s 28 May 2019, LZO 2.08
Thu Jul 4 17:10:38 2019 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
Thu Jul 4 17:10:38 2019 TCP/UDP: Preserving recently used remote address: [AF_INET]46.48.181.129:1195
Thu Jul 4 17:10:38 2019 Socket Buffers: R=[212992->212992] S=[212992->212992]
Thu Jul 4 17:10:38 2019 UDP link local: (not bound)
Thu Jul 4 17:10:38 2019 UDP link remote: [AF_INET]46.48.181.129:1195
Thu Jul 4 17:10:38 2019 TLS: Initial packet from [AF_INET]46.48.181.129:1195, sid=90935a47 cc10d71f
Thu Jul 4 17:10:39 2019 VERIFY OK: depth=2, C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Certification Authority
Thu Jul 4 17:10:39 2019 VERIFY OK: depth=1, C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Domain Validation Secure Server CA
Thu Jul 4 17:10:39 2019 VERIFY OK: depth=0, OU=Domain Control Validated, OU=PositiveSSL Wildcard, CN=*.opengw.net
Thu Jul 4 17:10:39 2019 Control Channel: TLSv1.2, cipher TLSv1/SSLv3 ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Thu Jul 4 17:10:39 2019 [*.opengw.net] Peer Connection Initiated with [AF_INET]46.48.181.129:1195
Thu Jul 4 17:10:40 2019 SENT CONTROL [*.opengw.net]: 'PUSH_REQUEST' (status=1)
Thu Jul 4 17:10:41 2019 PUSH: Received control message: 'PUSH_REPLY,ping 3,ping-restart 10,ifconfig 10.211.1.97 10.211.1.98,dhcp-option DNS 10.211.254.254,dhcp-option DNS 8.8.8.8,route-gateway 10.211.1.98,redirect-gateway def1'
Thu Jul 4 17:10:41 2019 OPTIONS IMPORT: timers and/or timeouts modified
Thu Jul 4 17:10:41 2019 OPTIONS IMPORT: --ifconfig/up options modified
Thu Jul 4 17:10:41 2019 OPTIONS IMPORT: route options modified
Thu Jul 4 17:10:41 2019 OPTIONS IMPORT: route-related options modified
Thu Jul 4 17:10:41 2019 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Thu Jul 4 17:10:41 2019 Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Thu Jul 4 17:10:41 2019 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jul 4 17:10:41 2019 Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Thu Jul 4 17:10:41 2019 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jul 4 17:10:41 2019 ROUTE_GATEWAY 192.168.0.1/255.255.255.0 IFACE=eth0 HWADDR=<snip>
Thu Jul 4 17:10:41 2019 TUN/TAP device tun0 opened
Thu Jul 4 17:10:41 2019 TUN/TAP TX queue length set to 100
Thu Jul 4 17:10:41 2019 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Thu Jul 4 17:10:41 2019 /sbin/ip link set dev tun0 up mtu 1500
Thu Jul 4 17:10:41 2019 /sbin/ip addr add dev tun0 local 10.211.1.97 peer 10.211.1.98
Thu Jul 4 17:10:41 2019 /sbin/ip route add 46.48.181.129/32 via 192.168.0.1
Thu Jul 4 17:10:41 2019 /sbin/ip route add 0.0.0.0/1 via 10.211.1.98
Thu Jul 4 17:10:41 2019 /sbin/ip route add 128.0.0.0/1 via 10.211.1.98
Thu Jul 4 17:10:41 2019 Initialization Sequence Completed
Code: Select all
sudo ufw --force reset
sudo ufw default deny incoming
sudo ufw default deny outgoing
sudo ufw allow in on tun0
sudo ufw allow out on tun0
sudo ufw allow in on eth0 from 192.168.0.0/24
sudo ufw allow out on eth0 to 192.168.0.0/24
sudo ufw allow out on eth0 to 46.48.181.129 port 1195 proto udp
sudo ufw allow in on eth0 from 46.48.181.129 port 1195 proto udp
sudo ufw enable
What am I doing wrong?