I've correctly installed and configured Softether on my Ubuntu 14 x64 VPS in local bridge mode with a virtual TAP interface.
What I have now is a fully functioning L2TP/IPSEC server with two network interfaces which I'd like to further secure using ufw
.
Having scoured the internet I hacked together a solution as per below that does work, but I'm not sure how secure/correct it is and was hoping someone here could guide me in the right direction.
Starting with my (shortened) ifconfig
:
eth0 Link encap:Ethernet HWaddr XX
inet addr:XXX.XXX.XXX.XXX Bcast:XXX.XXX.XXX.255 Mask:255.255.255.0
inet6 addr: XX Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
tap_soft Link encap:Ethernet HWaddr XX
inet addr:192.168.7.1 Bcast:192.168.7.255 Mask:255.255.255.0
inet6 addr: XX Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
1 - In /etc/ufw/before.rules
I've inserted a POSTROUTING
rule before the *filter
line:
# Rules for NAT Table of iptables
*nat
:POSTROUTING ACCEPT [0:0]
# Forward traffic from Softether through eth0.
-A POSTROUTING -s 192.168.7.0/24 -o eth0 -j MASQUERADE
# tell ufw to process the lines
COMMIT
2 - In /etc/default/ufw
I've enabled forwarding and set DEFAULT_FORWARD_POLICY="ACCEPT"
3 - Appended net.ipv4.ip_forward = 1
to /etc/sysctl.conf
- and reloaded sysctl of course.
4 - Because I'm running in Local Bridge mode, tap_soft
requires a DHCP server.
So my dnsmasq.conf
file looks like this:
interface=tap_soft
dhcp-range=tap_soft,192.168.7.50,192.168.7.60,12h
dhcp-option=tap_soft,3,192.168.7.1
5 - ufw
verbose status:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), allow (routed)
To Action From
-- ------ ----
67 on tap_soft ALLOW IN Anywhere
53 on tap_soft ALLOW IN Anywhere
1701 ALLOW IN Anywhere
4500/udp ALLOW IN Anywhere
500/udp ALLOW IN Anywhere
The steps above mean I have a fully functioning VPN server with a firewall - but is my firewall configuration still secure/correct/recommended?
The only other way I found to get it working correctly is to
iptables -t nat -A POSTROUTING -s 192.168.7.0/24 -j SNAT --to-source MYPUBLICIPADDRESS
and only open ports 67
and 53
in ufw
.
Not being well versed in iptables
, I'm not 100% sure what this does or why it works.