-2

i am trying to establish a TCP connection over the internet. I use my IPv4 address as the server address and it works when I connect to it using a machine on the local network.

However when I try to connect to it using a machine that it is not on my local network, it fails.

Does the problem occur because I use an IPv4 address or is it something else?

  • Is the IP you're trying to connect to in one of the [Private IPv4 address spaces](https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces)? – grooveplex Mar 21 '18 at 14:45
  • @grooveplex i am not sure how to check that. The IP i use for server (so the one that everyone tries to connect to) is the one i see marked as IPv4 when i write at command promt: ipconfig /all – Alex Kalfoglou Mar 21 '18 at 14:49

1 Answers1

0

Not exactly. You NEED to use an IP address. IPv4 or v6 or both. But in your case you are using an IPv4 which can't be an issue here.

You issue is lying in two things: NATing and Routing. Can be both or any one of them.

Normally you are using a Private IP address. To check this issue a ifconfig or ipconfig (on Windows) and see what IP you have. If it is in the Private IP range (10.0.0.1 going to 10.0.0.254 or 172.16.0.1 going to 172.31.255.254 or 192.168.0.1 going to 192.168.255.254) then you need what we call NAT. Those addresses are not routable on the internet. So your router should automatically NAT this to a public IP you are either paid for directly or given by your ISP. If this is not done you can't "go out".

On the routing part, you need to check you default gateway. If you issue a ipconfig /all on your Window machine, you should see the IP address of your Router (ISP one) or your cloud provider etc.

mr4kino
  • 411
  • 4
  • 15
  • Hello and thanks for your answer. Indeed my IPv4 is in the ranger [192.168.0.1, 192.168.255.254]. I checked my default gateway number and it is also in that range, which i do not know what it means. When i search "what is my ip" on google it shows me something else (looks like IPv6) and it says that this is my public ip. Should i use that as my socket IPAddress ? – Alex Kalfoglou Mar 21 '18 at 16:47
  • Good, so now it seems you don't have any issue routing the traffic to the default gateway. You don't have a public IP neither. What is your default gateway, what brand or model? Can you connect to it via console or webgui? – mr4kino Mar 21 '18 at 17:17
  • Yeah i can connect to the console – Alex Kalfoglou Mar 21 '18 at 18:23
  • Your information has helped me a lot thanks. Searching through the internet about this problem and what is NAT, i assume that NAT should probably be the issue. However that creates some other questions about punch-through: Is Master-Server a vital thing to have in order to do punch-through or can my pc somehow take the role of Master-Server, for example by assigning to it a public ip? – Alex Kalfoglou Mar 22 '18 at 12:19
  • You are welcome. I'm just not sure what is Master-Server and what is punch-through so can't really help with this – mr4kino Mar 22 '18 at 12:52
  • punch-through is technique to solver the "NAT" problem. In a nutshell what it suggests, is to have a server (the master-server) with a public ip. After that, the two clients try to connect with the server and so make their router assign a "public" port for their private IP to "speak" with the internet. Now that "NAT" is solved, server can transfer data between them or (if i have understand right) establish a connection between them, like peer to peer. This paper explains it very well: http://www.brynosaurus.com/pub/net/p2pnat/ – Alex Kalfoglou Mar 22 '18 at 15:55
  • Ok now for such a device as a Netgear it should be something simple. Did you check this? https://kb.netgear.com/23020/Opening-ports-for-internet-games-and-applications-on-NETGEAR-routers Probably your netgear is blocking some port or ip translation – mr4kino Mar 22 '18 at 16:04
  • Haven't seen it before but it seems like it will do the job. If i have understand it right what i should check is the port-forwarding feature and what i want to do is to tell my router to assign a port to my PC-Server right? After that people will be able to find me through my IPv4 address? Thanks again for the help, really appreciated – Alex Kalfoglou Mar 22 '18 at 17:27
  • More about NAT I would say. It's normal to block incoming connection (I'm insisting on a non-established connection from the inside). First thing you will need a public IP. If you don't have anything public with https://www.whatismyip.com/ you should contact your ISP. NAT or portforwarding won't do anything useful here if you don't have a public IP in the first place. – mr4kino Mar 23 '18 at 17:01
  • whatismyip.com confirms that i have a public IPv6 ip. – Alex Kalfoglou Mar 24 '18 at 10:38
  • I would advise contacting your ISP and ask them about an ipv4 address. Ipv6 would too much of a hassle at the moment. Seems like Netgear supports it but still either there will be 6to4 converting or you will have to run Ipv6 across your whole internal network – mr4kino Mar 25 '18 at 15:54