My Linux network firewall commands

These are my top two Linux firewall commands that I've used frequently.

Open a TCP Port Permanently in Linux

Most Linux servers provisioned in the cloud have their local Linux firewall on be default, which has a lot of the non-standard ports blocked by default as well. This commands permanently opens up a port.

firewall-cmd --permanent --zone=public --add-port=5000/tcp

firewall-cmd --reload

Perform a Port Mapping

This command maps an external port 443 to an internal port 4443.

iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443

/sbin/iptables-save