Thomas' Tech Tips

How to manage iptables firewall rules on Ubuntu in Oracle Cloud Infrastructure

31 May 2023 - Thomas Damgaard

I recently had to deploy some apps on Oracle Cloud Infrastructure (OCI).

It seems OCI instances with Ubuntu use iptables-save. Firewall rules are stored in /etc/iptables/rules.v4 and /etc/iptables/rules.v6 for IPv4 and IPv6 respectively.

Adding or modifying firewall rules is fairly straight forward - simply edit the file and add the ipables commands you need.

However, actually applying the newly added rules seemed non-obvious to me at first.

Loading rules are done with the following command:

iptables-restore < /etc/iptables/rules.v4

Or for IPv6:

ip6tables-restore < /etc/iptables/rules.v6

Rules added directly via iptables command are saved with the commands:

iptables-save > /etc/iptables/rules.v4

and

ip6tables-save > /etc/iptables/rules.v6

for IPv4 and IPv6 respectively.

Note: You may have to make corresponding changes to your network security group.

Filed under: firewall, howto, iptables, linux, network, oci, oracle, tips, ubuntu

Back to article list