简体   繁体   中英

Java Socket with VPN connection

I have a Java Socket server listening on a machine given a 192.168.* address. I have a client Java solution connecting to the Socket server and sending a command using BufferedOutputStream and capturing the response on BufferedInputStream.

This all works fine when I am on the local network.

When I VPN in, I get a 10* IPA and the solution does not work. I heard that 10 Net needs to be routed, but won't the VPN server do all this for me?

I can access all the 192.168* resources with my 10 Net VPN connection, so I do not see how this can be a routing issue.

Any ideas why a Java Socket solution from a 10 Net VPN cannot get send commands or receive responses?

Thanks in advance.

Though you got the problem solved, i still felt some misconception in your answer and thought of adding to make sure.

You have a 192.... machine on which your server is listening on some port (say 4055). Now you want a client outside this network to reach this server and exchange data.

In case your client is on the same network you don't need any routing, all you need is your server to allow incoming connections on port 4055 . Generally incoming connections (except from local host) are blocked by firewalls such as iptables on Linux and you have to add a rule in firewall config for that.

But in case your client is on a different subnet and needs to be routed, you need a rule on the router ie your router needs to be told every packet received from ip x (of client) on router port (y) should be forwarded to your server port 4055. THis is called port forwarding.

Even if your router is capable of forwarding some ports, it has to be explicitly told what traffic from which ip / port needs to be forwarded to which ip listening at what port

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM