Fair warning, I'm not expert with netfilter (iptables).
Any respectable Linux server distro should have netfilter installed and enabled in it's kernel. Netfilter allows you to route, block, and otherwise manipulate packets entering and leaving your system. Try running this as root on the server machine:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 1521
You may have to change eth0 to the correct device name for the server's LAN adapter. This should cause any packets coming in on port 80 to be received by Oracle DBMS listening on port 1521.
I went ahead and looked up what these options do (because I'm not super familiar with managing netfilter by hand). Leme break it down:
-t nat -A PREROUTING
This selects the NAT table and appends (-A
) the new rule to the PREROUTING chain of the NAT table. Generally, when you're redirecting from one port to another, that belongs in the NAT table. The PREROUTING chain happens very early when in Netfilter's processing of incoming packets. It's the very first chain for incoming packets, typically.
-i eth0 -p tcp -dport 80
These are the filter portion of the rule. We are telling it what interface (-i
) and protocol (-p
) you want this rule to affect packets on. In this example, we are creating a rule for tcp traffic on interface eth0
. We are also telling it what destination port (-dport
) to look for in the packets... in this case packets with a destination port of 80 (tcp).
When you try to connect to tcp port 80 on the server with the Oracle DBMS the tcp packets your machine sends will have a destination port of 80 in their headers.
--j REDIRECT --to-ports 1521
This is the meat of the rule. Here you are telling it that packets that match the filters above are to be redirected (--j REDIRECT
) to port 1521 (--to-ports 1521
). When the netfilter is on the same system as the application you want to redirect traffic to you use REDIRECT
. When the application is on another server you would use DNAT
instead (and specify both IP and port).
Please let me know if this works.
These settings are not persistent; to make them persistent, I would suggest that you look into installing iptables-persistent
. You can find more information here on StackOverflow.
You should be able to do this out of the box with netfilter (iptables). But I'm not familiar with the exact command. – Cliff Armstrong – 2018-06-20T03:44:01.307