Ubuntu 18.04 and 20.04 Server - Using as VPN gateway - IP tables Issue :(

smurf786

New Member
Joined
Sep 7, 2021
Messages
1
Reaction score
0
Credits
15
Hi Guys,

I have setup a Hyper-V VM of ubuntu server, i've tried both the latest 20.04 and 18.04 too. I am really new to linux so sorry if this is going to be something simple.

Basically i am following this video guide:

I want to use Ubuntu server for openvpn with purevpn. I will then select the ubuntu server as the gateway for the individual devices to push traffic across the vpn.

I have managed to get the VM installed but everytime i run iptables i lose connection to the internet... I cannot ping google.com or even 8.8.8.8

Could someone check my iptables file and see what could be causing this?

Code:
#!/bin/bash
# Flush
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
# Block All
iptables -P OUTPUT DROP
iptables -P INPUT DROP
iptables -P FORWARD DROP
# allow Localhost
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Make sure you can communicate with any DHCPserver
iptables -A OUTPUT -d 255.255.255.255 -j ACCEPT
iptables -A INPUT -s 255.255.255.255 -j ACCEPT
# Make sure that you can communicate within your ownnetwork
iptables -A INPUT -s 192.168.233.0/24 -d 192.168.233.0/24 -jACCEPT
iptables -A OUTPUT -s 192.168.233.0/24 -d 192.168.233.0/24 -j ACCEPT
# Allow established sessions to receivetraffic:
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow TUN
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
iptables -A FORWARD -o tun+ -j ACCEPT
iptables -t nat -A POSTROUTING -o tun+ -j MASQUERADE
iptables -A OUTPUT -o tun+ -j ACCEPT
# allow VPN connection
iptables -I OUTPUT 1 -p udp --destination-port 1194 -m comment --comment"Allow VPN connection" -j ACCEPT
# Block All
iptables -A OUTPUT -j DROP
iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP
# Log all dropped packages, debug only.
iptables -N logging
iptables -A INPUT -j logging
iptables -A OUTPUT -j logging
iptables -A logging -m limit --limit 2/min -j LOG --log-prefix "IPTablesgeneral: " --log-level 7
iptables -A logging -j DROP
echo "saving"
iptables-save > /etc/iptables.rules
echo "done"
#echo 'openVPN - Rules successfully applied, we start "watch" toverify IPtables in realtime (you can cancel it as usual CTRL + c)'
#sleep 3
#watch -n 0 "sudo iptables -nvL"

Thank you
 

Members online


Latest posts

Top