Skip to content

Commit

Permalink
Make vpn port fully configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
janole committed Jun 9, 2024
1 parent ef2f063 commit e856347
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rules.v4
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i eth0 -p udp -m state --state NEW,ESTABLISHED -m udp --dport 1194 -j ACCEPT
-A INPUT -i eth0 -p udp -m state --state NEW,ESTABLISHED -m udp --dport ${VPN_PORT} -j ACCEPT
-A INPUT -i tun0 -j ACCEPT
-A FORWARD -i tun0 -j ACCEPT
-A FORWARD -s 10.8.0.0/24 -i tun0 -o eth0 -j ACCEPT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -o eth0 -p udp -m state --state ESTABLISHED -m udp --sport 1194 -j ACCEPT
-A OUTPUT -o eth0 -p udp -m state --state ESTABLISHED -m udp --sport ${VPN_PORT} -j ACCEPT
-A OUTPUT -o tun0 -j ACCEPT
COMMIT
# Generated by iptables-save v1.8.9 (nf_tables)
Expand Down
8 changes: 5 additions & 3 deletions scripts/start-vpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ set -e

openssl verify -verbose -CAfile ${VPNCAFILE} ${VPNCERTFILE}

iptables-restore < /etc/iptables/rules.v4
CONF="${SERVERCONF:-$TCPCONF}"

echo "Starting with config ${SERVERCONF:-$TCPCONF} ..."
VPN_PORT=`grep "^port " $CONF | sed -e "s/[^0-9]*//g"`
envsubst < /etc/iptables/rules.v4 | iptables-restore

exec openvpn --config ${SERVERCONF:-$TCPCONF}
echo "Starting with config ${CONF} ..."
exec openvpn --config ${CONF}

0 comments on commit e856347

Please sign in to comment.