Published
- 2 min read
Opening Ports on Oracle Cloud
Oracle Cloud or OCI is a cloud service infrastructure similar to AWS or Azure, that allows for developers to create cloud servers. OCI is known for two things, having a free tier, and being horribly unreliable. I don’t think any sane company is paying for OCI, thus the only people using it are the ones using the free tier. With OCI having no support for users of the free tier, its hard to get support on niche topics. One topic that isn’t so niche is opening ports. If you’re hosting anything on the OCI servers, you’re going to want to make something accessible to the entire internet. Unfortunately, and this is only for Ubuntu servers, OCI disables and actually recommends you don’t use UFW
as it messes with their ssh system (??).
In this article we’re going to talk about how to use iptables
to do this instead.
Let’s open up and ssh into our Ubuntu OCI machine.
After we’ve done that, we’re going to want to determine which ports we want to open, and by which protocol (TCP/UDP).
For this example, let’s use port 80
, and 443
as standard web server ports.
The way we modify iptables is by editing an actual file located at /etc/iptables/rules.v4
sudo vim /etc/iptables/rules.v4
Now under the line that reads -A INPUT -p tcp -m state —state NEW -m tcp —dport 22 -j ACCEPT we’re going to put:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
Great! We’ve opened a port on our system, to flush out iptables simply close the document and write:
sudo iptables-restore < /etc/iptables/rules.v4
Now you may need to restart some docker services that rely on this technology. Once you’ve done that, go to your oracle cloud subnet and open the ports there! That is a lot easier then doing it on the computer, but is also required.
I wish you all the best in your OCI adventures!