Access to a network server without port forwarding

Solution 1:

How I can access PC2 without port forwarding on the router?

Assuming a NAT router (which is almost certain given a 192.168.0.0/24 internal network), you can't do this without port-forwarding at the router. Or something very similar.

For example if you can SSH to the router and then to the server you could use SSH tunelling (which is a form of port-forwarding).

You could also have PC2 SSH to a public server and make available a tunelled endpoint there. (you might need something like netcat or socat to assist with this)

In general, port-forwarding at the router is the way to go.


Protocols for NAT traversal

There are ways to enable this sort of communication without manual configuration of port-forwarding but they usually rely on router support and/or an external connection broker.

General

  • UDP Hole punching - very clear explanation
  • Hole Punching
  • NAT Traversal

Specific

  • IGDP.
  • STUN
  • ICE
  • NAT-PMP
  • PCP
  • UPnP

I would like to have a reference in any programming language of this case

If you are writing the software at both ends there are probably many examples you can follow.

For example, see