Open ports and save iptables rules
Viewing all iptables rules in Linux
iptables -S
iptables --list
iptables -L
iptables -S TABLE_NAME
iptables --table NameHere --list
iptables -t NameHere -L -n -v --line-numbers
How to list rules for given tables
Type the following command as root user:
iptables -L INPUT
iptables -L FORWARD
iptables -L OUTPUT
iptables -L
Allow TCP and UDP ipv4
iptables -I INPUT -p tcp --dport xxxx -j ACCEPT
iptables -I INPUT -p udp --dport xxxx -j ACCEPT
Allow TCP and UDP ipv6
ip6tables -I INPUT -p tcp --dport xxxx -j ACCEPT
ip6tables -I INPUT -p udp --dport xxxx -j ACCEPT
Allow TPC and UDP ipv4
iptables -A OUTPUT -p tcp --dport xxxx -j ACCEPT
iptables -A OUTPUT -p udp --dport xxxx -j ACCEPT
Allow TCP and UDP ipv6
ip6tables -I OUTPUT -p tcp --dport xxxx -j ACCEPT
ip6tables -I OUTPUT -p udp --dport xxxx -j ACCEPT
Allow Multiple Ports
iptables -A INPUT -p tcp -m multiport --dports 22,80,443 -j ACCEPT
iptables -A OUTPUT -p tcp -m multiport --sports 22,80,443 -j ACCEPT
iptables -A OUTPUT -p tcp -dport xxxx -j DROP
iptables-save -f /etc/iptables/iptables.rules
If you edit the iptables configuration file manually
iptables-restore /etc/iptables/iptables.rules
For more info, man iptables
----------
Home
Linux
Notes
MicroLog
----------
© DarknessCode