I
I
isapioff2014-07-12 14:44:46
linux
isapioff, 2014-07-12 14:44:46

How to connect to "internal" port using external ip?

Friends,
There is a server, it has a permanent pppt connection. It turns out that it has 2 IP addresses: internal 192.168.0.200 (issued by the router) and "external" 10.0.0.160 (issued by the VPN server).
There is a third-party application on the server, which is available on port 48900 if you connect via the internal IP, but is not available if you connect via the "external".
At the same time, if I run a regular apache or tomcat, they are perfectly accessible on both IPs.
Here are the details:

$ netstat -lnt 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 192.168.0.200:48900         0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN

It can be seen that the third party application uses Local Address 192.168.0.200:48900 and I can only connect to port 48900 through the internal IP. But on port 8080 it turns out to connect using the external 10.0.0.160:8080.
What should I do so that I can connect to port 48900 using 10.0.0.160:48900 ?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2014-07-12
@isapioff

What should I do so that I can connect to port 48900 using 10.0.0.160:48900

Fix the application where it calls bind on the socket, replacing the address with 0.0.0.0 (INADDR_ANY).
If that luxury is not available, redirect from 10.0.0.160 to 192.168.0.200 using iptables (DNAT), ssh tunnel or whatever.

I
isapioff, 2014-07-12
@isapioff

Executed
iptables -t nat -A PREROUTING -p tcp -d 10.0.0.160 --dport 48900 -j DNAT --to-destination 192.168.0.200:48900
earned!!! Thanks!!!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question