mirror of
https://github.com/MarkusMcNugen/docker-qBittorrentvpn
synced 2024-11-25 20:14:58 +00:00
Update iptables.sh
This commit is contained in:
parent
75b8b0d10d
commit
cdc7fefb16
@ -63,26 +63,26 @@ if [[ $iptable_mangle_exit_code == 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# identify docker bridge interface name (probably eth0)
|
# identify docker bridge interface name (probably eth0)
|
||||||
# docker_interface=$(netstat -ie | grep -vE "lo|tun|tap" | sed -n '1!p' | grep -P -o -m 1 '^[^:]+')
|
docker_interface=$(netstat -ie | grep -vE "lo|tun|tap" | sed -n '1!p' | grep -P -o -m 1 '^[\w]+')
|
||||||
# if [[ "${DEBUG}" == "true" ]]; then
|
if [[ "${DEBUG}" == "true" ]]; then
|
||||||
# echo "[debug] Docker interface defined as ${docker_interface}"
|
echo "[debug] Docker interface defined as ${docker_interface}"
|
||||||
# fi
|
fi
|
||||||
|
|
||||||
# identify ip for docker bridge interface
|
# identify ip for docker bridge interface
|
||||||
# docker_ip=$(ifconfig "${docker_interface}" | grep -P -o -m 1 '(?<=inet\s)[^\s]+')
|
docker_ip=$(ifconfig "${docker_interface}" | grep -P -o -m 1 '(?<=inet\saddr:)[^\s]+')
|
||||||
# if [[ "${DEBUG}" == "true" ]]; then
|
if [[ "${DEBUG}" == "true" ]]; then
|
||||||
# echo "[debug] Docker IP defined as ${docker_ip}"
|
echo "[debug] Docker IP defined as ${docker_ip}"
|
||||||
# fi
|
fi
|
||||||
|
|
||||||
# identify netmask for docker bridge interface
|
# identify netmask for docker bridge interface
|
||||||
# docker_mask=$(ifconfig "${docker_interface}" | grep -P -o -m 1 '(?<=netmask\s)[^\s]+')
|
docker_mask=$(ifconfig "${docker_interface}" | grep -P -o -m 1 '(?<=Mask:)[^\s]+')
|
||||||
# if [[ "${DEBUG}" == "true" ]]; then
|
if [[ "${DEBUG}" == "true" ]]; then
|
||||||
# echo "[debug] Docker netmask defined as ${docker_mask}"
|
echo "[debug] Docker netmask defined as ${docker_mask}"
|
||||||
# fi
|
fi
|
||||||
|
|
||||||
# convert netmask into cidr format
|
# convert netmask into cidr format
|
||||||
# docker_network_cidr=$(ipcalc "${docker_ip}" "${docker_mask}" | grep -P -o -m 1 "(?<=Network:)\s+[^\s]+")
|
docker_network_cidr=$(ipcalc "${docker_ip}" "${docker_mask}" | grep -P -o -m 1 "(?<=Network:)\s+[^\s]+" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~')
|
||||||
# echo "[info] Docker network defined as ${docker_network_cidr}" | ts '%Y-%m-%d %H:%M:%.S'
|
echo "[info] Docker network defined as ${docker_network_cidr}" | ts '%Y-%m-%d %H:%M:%.S'
|
||||||
|
|
||||||
# input iptable rules
|
# input iptable rules
|
||||||
###
|
###
|
||||||
@ -97,7 +97,7 @@ ip6tables -P INPUT DROP 1>&- 2>&-
|
|||||||
iptables -A INPUT -i "${VPN_DEVICE_TYPE}" -j ACCEPT
|
iptables -A INPUT -i "${VPN_DEVICE_TYPE}" -j ACCEPT
|
||||||
|
|
||||||
# accept input to/from docker containers (172.x range is internal dhcp)
|
# accept input to/from docker containers (172.x range is internal dhcp)
|
||||||
# iptables -A INPUT -s "${docker_network_cidr}" -d "${docker_network_cidr}" -j ACCEPT
|
iptables -A INPUT -s "${docker_network_cidr}" -d "${docker_network_cidr}" -j ACCEPT
|
||||||
|
|
||||||
# accept input to vpn gateway
|
# accept input to vpn gateway
|
||||||
iptables -A INPUT -i eth0 -p $VPN_PROTOCOL --sport $VPN_PORT -j ACCEPT
|
iptables -A INPUT -i eth0 -p $VPN_PROTOCOL --sport $VPN_PORT -j ACCEPT
|
||||||
@ -136,7 +136,7 @@ ip6tables -P OUTPUT DROP 1>&- 2>&-
|
|||||||
iptables -A OUTPUT -o "${VPN_DEVICE_TYPE}" -j ACCEPT
|
iptables -A OUTPUT -o "${VPN_DEVICE_TYPE}" -j ACCEPT
|
||||||
|
|
||||||
# accept output to/from docker containers (172.x range is internal dhcp)
|
# accept output to/from docker containers (172.x range is internal dhcp)
|
||||||
# iptables -A OUTPUT -s "${docker_network_cidr}" -d "${docker_network_cidr}" -j ACCEPT
|
iptables -A OUTPUT -s "${docker_network_cidr}" -d "${docker_network_cidr}" -j ACCEPT
|
||||||
|
|
||||||
# accept output from vpn gateway
|
# accept output from vpn gateway
|
||||||
iptables -A OUTPUT -o eth0 -p $VPN_PROTOCOL --dport $VPN_PORT -j ACCEPT
|
iptables -A OUTPUT -o eth0 -p $VPN_PROTOCOL --dport $VPN_PORT -j ACCEPT
|
||||||
|
Loading…
Reference in New Issue
Block a user