OCI Firewall Fix
Oracle VPS has weird iptable rules that block all ports except SSH and also render UFW non-functional. The only way to port forward is by using iptables or firewalld, and both of them are not very user-friendly. So here’s a quick way to fix that.
WARNING
YOU MIGHT COMPLETELY LOSE ACCESS TO YOUR VPS IF SOMETHING GOES WRONG.
Here’s how you might be able to recover if that happens but no guarantees ¯\_(ツ)_/¯
Ok now let’s continue!
First make a backup of all existing iptable rules in case you need to revert them
sudo iptables-save > ~/iptables-rules
Now to clear all rules
sudo iptables --flush
To ensure that these rules don’t revert after reboot
sudo mv /etc/iptables/rules.v4 /etc/iptables/rules.v4.bak
sudo mv /etc/iptables/rules.v6 /etc/iptables/rules.v6.bak
sudo reboot
All the ports should be wide open now. You can now install UFW if you want
sudo apt install ufw
sudo ufw allow ssh
sudo ufw enable