How do I use iptables to disable my instance's firewall?

By default, Lambda GPU Cloud reserved instances allow incoming connections only to TCP port 22, which is typically used for ssh access.

To allow incoming connections to ports other than TCP port 22, the instance’s default firewall rules need to be modified.

iptables can be used to modify the firewall rules or disable the firewall entirely.

To entirely disable the firewall on the instance, run the following commands:

sudo iptables -P INPUT ACCEPT   # accept all incoming traffic by default
sudo iptables -P OUTPUT ACCEPT  # accept all outgoing traffic by default
sudo iptables -P FORWARD ACCEPT # accept all forwarded traffic by default
sudo iptables -F                # delete all rules in the filter table
sudo iptables -t nat -F         # delete all rules in the nat table
sudo iptables -t mangle -F      # delete all rules in the mangle table
sudo iptables -X                # delete all non-built-in chains

To keep the firewall disabled after rebooting, run:

sudo iptables-save | sudo tee /etc/iptables/rules.v4 > /dev/null

Last modified February 11, 2023: Use more popular name (8ae4ab5)