After the iptables -F and iptables -save , ssh access was lost. Ubuntu 16.04.5 server axis Ubuntu 16.04.5 server .
How to restore iptables to the previous form? and return access?
After the iptables -F and iptables -save , ssh access was lost. Ubuntu 16.04.5 server axis Ubuntu 16.04.5 server .
How to restore iptables to the previous form? and return access?
Designed in the form of a script, you can add your own ports.
Please note that these rules will work until the next reboot. Make sure that you do not have any third-party firewall that loads or resets the iptables settings
#!/usr/bin/env bash set -e [ "$(id -u)" = "0" ] || { echo "Run as root. Exit."; exit 1; } PORT_ALLOW=( 21 22 80 443 ) allow_ipv4_port() { local port="$1" iptables -A INPUT -p tcp -m tcp --dport "${port}" -j ACCEPT iptables -A INPUT -p udp -m udp --dport "${port}" -j ACCEPT } main() { for p in ${PORT_ALLOW[@]}; do allow_ip4_port "$p" done } main "$@" # End of script Links
{% for rule in firewall_additional_rules %} could not explain how this works. Well, I mean, why and for what use curly brackets I (probably) represent. And this is how it works in combination with a percent sign, and a cycle divided into such blocks ... Thanks in advance. PS If necessary, I can issue a question. - Andreyjinja2 format. - HellseherSource: https://ru.stackoverflow.com/questions/865110/
All Articles