connect to oracle db server remotely I have Oracle 9i installed on machine connected to the internet behind NAT, and the Oracle DB server is listening on default port 1521, when I connect over the LAN IP to the database server it works perfectly, and I did  port forwarding on port 1521 to the private IP address in tp-link router to make the Oracle client machine connect to Oracle DB server over public IP, for example: 1521-192.168.0.108 forwarding port and its successful on canyouseeme.org but when I use this command:

SQL&gt;connect username/password@GLOBAL_IP/service_name 
Error: ORA_12170: TNS : Connect timeout occurred 


*note: when I try to connect to the Oracle database server using Teamviewer vpn, it also  works and connected so how to deal with this ?
What is probably happening is that you have a router that doesn't support NAT loopback or the router configuration isn't properly set up.

You can connect from the outside as proven by the fact that canyouseeme.org sees you, and you can VPN into it because TeamViewer connections come from TeamViewer servers (hence the outside), and you can also connect to the internal IP.

If you want transparent connections from the inside and the outside you would need to either set up DNS, so that in your internal LAN the hostname.yourdomain.org points to the internal IP and make sure that from the outside the same hostname points to your external IP or get a router that supports NAT loopback.

There is plenty to find if you google 'nat loopback connect to external ip from lan' or you might find this post on serverfault interesting: Loopback to forwarded Public IP address from local network - Hairpin NAT