Skip to content

Commit a11730f

Browse files
author
Sheng Yang
committed
CLOUDSTACK-5297: Fix ACL rules on VPN for VPC
Insert a new iptables chain for FORWARD chain, in order to let following ACL rules being executed as well.
1 parent b72285f commit a11730f

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

‎systemvm/patches/debian/vpn/opt/cloud/bin/vpn_l2tp.sh‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,41 @@ get_intf_ip() {
3535
iptables_() {
3636
local op=$1
3737
local public_ip=$2
38+
local is_vpc=false
39+
local forward_action="ACCEPT"
40+
if grep "vpcrouter" /var/cache/cloud/cmdline &> /dev/null
41+
then
42+
is_vpc=true
43+
fi
3844

3945
sudo iptables $op INPUT -i $dev --dst $public_ip -p udp -m udp --dport 500 -j ACCEPT
4046
sudo iptables $op INPUT -i $dev --dst $public_ip -p udp -m udp --dport 4500 -j ACCEPT
4147
sudo iptables $op INPUT -i $dev --dst $public_ip -p udp -m udp --dport 1701 -j ACCEPT
4248
sudo iptables $op INPUT -i $dev -p ah -j ACCEPT
4349
sudo iptables $op INPUT -i $dev -p esp -j ACCEPT
44-
sudo iptables $op FORWARD -i ppp+ -d $cidr -j ACCEPT
45-
sudo iptables $op FORWARD -s $cidr -o ppp+ -j ACCEPT
46-
sudo iptables $op FORWARD -i ppp+ -o ppp+ -j ACCEPT
50+
if $is_vpc
51+
then
52+
# Need to apply the following ACL rules as well.
53+
if sudo iptables -N VPN_FORWARD &> /dev/null
54+
then
55+
sudo iptables -I FORWARD -i ppp+ -j VPN_FORWARD
56+
sudo iptables -I FORWARD -o ppp+ -j VPN_FORWARD
57+
sudo iptables -A VPN_FORWARD -j DROP
58+
fi
59+
sudo iptables $op VPN_FORWARD -i ppp+ -o ppp+ -j RETURN
60+
sudo iptables $op VPN_FORWARD -i ppp+ -d $cidr -j RETURN
61+
sudo iptables $op VPN_FORWARD -s $cidr -o ppp+ -j RETURN
62+
else
63+
sudo iptables $op FORWARD -i ppp+ -d $cidr -j ACCEPT
64+
sudo iptables $op FORWARD -s $cidr -o ppp+ -j ACCEPT
65+
sudo iptables $op FORWARD -i ppp+ -o ppp+ -j ACCEPT
66+
fi
4767
sudo iptables $op INPUT -i ppp+ -m udp -p udp --dport 53 -j ACCEPT
4868
sudo iptables $op INPUT -i ppp+ -m tcp -p tcp --dport 53 -j ACCEPT
4969
sudo iptables -t nat $op PREROUTING -i ppp+ -p tcp -m tcp --dport 53 -j DNAT --to-destination $local_ip
5070
sudo iptables -t nat $op PREROUTING -i ppp+ -p udp -m udp --dport 53 -j DNAT --to-destination $local_ip
5171

52-
if grep "vpcrouter" /var/cache/cloud/cmdline &> /dev/null
72+
if $is_vpc
5373
then
5474
return
5575
fi

0 commit comments

Comments
 (0)