+###check whether access to public network is granted
+check_access_enabled_to_public_network() {
+ #Check whether public interface exists
+ echo "${blue}Checking whether public interface ${public_interface} exists${reset}"
+ if ! ip link show ${public_interface}; then
+ echo "${red}Public interface ${public_interface} does not exists!${reset}"
+ exit 1
+ else
+ echo "${green}OK!${reset}"
+ fi
+
+ #Check whether public interface ${public_interface} is UP
+ check_interface ${public_interface}
+
+ echo "${blue}Checking whether access is granted to public network through interface ${public_interface}${reset}"
+ if ! sudo iptables -t nat -L POSTROUTING -v | grep "MASQUERADE.*${public_interface}.*anywhere.*anywhere"; then
+ echo "${blue}Enable access to public network through interface ${public_interface}${reset}"
+ iptables -t nat -A POSTROUTING -o ${public_interface} -j MASQUERADE
+ else
+ echo "${green}OK!${reset}"
+ fi
+}