linux firewall
iptables
Allow port 80 through the firewall: sudo iptables -A INPUT -ptcp --dport 80-j ACCEPT
Check whether the firewall rules take effect:sudo iptables -L -n | grep 80
firewalld
- firewalld basic commands
to start the firewall:sudo systemctl start firewalld
Check firewall status:sudo systemctl status firewalld
Stop Firewall:sudo systemctl disable firewalld
Disable Firewall:sudo systemctl stop firewalld
- firewalld-cmd
View Version:sudo firewall-cmd --version
View help:sudo firewall-cmd --help
display status:sudo firewall-cmd --state
View all open ports:sudo firewall-cmd --zone=public --list-ports
updating the firewall rules:sudo firewall-cmd --reload
viewing area information:sudofirewall-cmd --get-active-zones
View the specified interface belongs:sudo firewall-cmd --get-zone-of-interface=eth0
to reject all packages:sudofi rewall-cmd --panic-on
unblock status:sudo firewall-cmd --panic-off
Check whether to reject:sudo firewall-cmd --query-panic
- Firewall port handling
Add:sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
(-permanent permanent, this argument does not fail after the restart)
reload:sudo firewall-cmd --reload
View:sudo firewall-cmd --zone= public --query-port=80/tcp
Delete:sudo firewall-cmd --zone= public --remove-port=80/tcp --permanent