Oracle Linux open port in firewall

I have 2 micro instances running in Oracle Cloud, both under the same subnet with some port forwarding enabled, namely

Oracle Linux open port in firewall

On the first instance I enabled also these ports in firewalld and I'm able to reach them from outside.

ubuntu@instance:~$ sudo firewall-cmd --list-all
public
  target: default
  icmp-block-inversion: no
  interfaces:
  sources:
  services: dhcpv6-client ssh
  ports: 80/tcp 443/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
user@iMac:~$ telnet instance_ip 443
Trying ...
Connected to instance_ip.

I did exactly the same thing on the second instance, which means that sudo firewall-cmd --list-all returns the same ouput. A quick check with sudo iptables -S also shows the same result. As both instances are connected to the same subnet I would expect the port forwarding to work in the same way. However, I can only connect to port 22 on the second instance. Any attempt to ping other ports results in a Connection refused.

What am I forgetting?

P.S. I'm aware of question Can't access Oracle Cloud Always Free Compute http port. Obviously I already followed every suggestion in that question, but that helped in setting up only the first instance.

In this article will be covering details regarding iptables and firewalld which helps in Linux firewall management. We will also be looking at how to enable specific ports (1521 for Oracle) inside iptables.

  • Linux Firewall Status

  • Linux Disable Firewall

  • Linux Enable Firewall

  • Enable Ports in Linux

Read more about Linux iptables vs Linux firewall

Linux Firewall status

The Linux firewalld command will let you check Linux firewall status. It will show you the current status Active in case firewall is running

systemctl status firewalld

Linux Disable Firewall

For practicing Oracle on Linux, you might need to stop the Linux firewall so that you can connect applications to database listener. Below commands will permanently disable Linux firewall

service firewalld stop
systemctl disable firewalld

Linux Enable Firewall

Just in case you would like to enable Linux firewall after disabling it, use below commands

service firewalld start
systemctl enable firewalld

Enable Ports in Linux

On some servers, port 1521 will not be enabled by default because of security reasons. You can enable this specific port inside linux using below commands.

Enable 1521 Port in Linux

If you are working on Oracle Linux 5 or 6 version, use Linux iptables command to enable specific ports as root user

iptables -I INPUT -p tcp --dport 1521 -j ACCEPT

If you would like to open any specific port in Linux, just replace the port number (1521) with new port number.

Enable Port Range in Linux

To open multiple port ranges in Linux, use below command

iptables -A INPUT -p tcp -m multiport --dports 7101:7200,4889:4898,1159,4899:4908,7788:7809,3872,1830:1849 -j ACCEPT

Enable Port in Oracle Linux 7

In some Linux versions, below command works fine

firewall-cmd  --permanent --add-port=1521/tcp

How do I open a port in Oracle Linux?

In order to use Oracle VM Manager on a system with iptables enabled you can either open all the ports used by Oracle VM Manager, or open all ports by disabling iptables. The ports required for the web browser connection to Oracle VM Manager are: 7001, 7002 and 15901.

How do I allow a port through a firewall in Linux?

Ubuntu and Debian.
Issue the following command to open port 1191 for TCP traffic. sudo ufw allow 1191/tcp..
Issue the following command to open a range of ports. sudo ufw allow 60000:61000/tcp..
Issue the following command to stop and start Uncomplicated Firewall (UFW). sudo ufw disable sudo ufw enable..

How do I open port 1521?

Open a Firewall Port for Oracle.
Oracle Database 18c, often simply called Oracle for short, is one of the three most popular enterprise-class DBMS packages. ... .
Launch Windows Control Pane, the full version. ... .
Choose Windows Defender Firewall. ... .
Click on Inbound Rules. ... .
Choose Port and click Next..
Enter 1521 and click Next..

How do I check if port 1521 is open Linux?

Type the command "netstat -an" to obtain a list of all the open ports.