Port forwarding and IPv6
Andrew Henderson
I have a basic small server that I run on my own computer, which I can access like this:
localhost:3000However I would also like to access the server from outside my home, for example using my phone browser. On another forum, someone said I could use one of these options:
- With IPv6: yes, if you open the port in your firewall
- With IPv4 you can do it with a port forward
but I don't really know how to do either one. It seems like IPv6 would be the better option, but I don't know if I am even using a firewall. In Windows settings, I have firewall turned off. Can someone advise on how I can access this server from another network?
31 Answer
There are four parts to making your network service accessible from the Internet:
- Make sure the service is accessible over the network. This involves:
Making sure it isn't bound to the loopback address (127.0.0.1 or ::1) which is only reachable on the computer itself. How this is done depends on the application providing the service and on the operating system of the computer.
Making sure it isn't blocked by the host firewall, either (dangerous) by turning the host firewall off or (better) by explicitly allowing incoming connections to the service in the host firewall. How to do this depends on the operating system and the host firewall in use.
- Provide a public IP address for the service. This is where the essential difference exists between IPv4 and IPv6:
With IPv6, you make sure your computer itself has a public address. In most typical settings you don't have to do anything for that beyond enabling IPv6 on your router. Your router gets a public IPv6 prefix from your provider and assigns public IPv6 addresses from that block to the devices on your network without further ado.
With IPv4, because of the global address shortage you'll typically get only a single public address from your provider which your router itself will occupy. Machines on the Internet can only connect to that public address. To work around that, you'll have to set up TCP port forwarding on your router to pass incoming connections arriving at your router and destined for your service on to your computer. The exact steps for doing this differ between router models of different manufacturers and sometimes even between different models of the same manufacturer.
Making that public address known to the client system from which you want to connect to the service. The direct approach would be to read the address from the computer itself (IPv6) or from your router (IPv4) and type it into your client. However most home Internet connections get only dynamic addresses which means the public address changes regularly, making this approach impractical. The way around that is to subscribe to a DynDNS service. That service provides a DNS name which is automatically updated to whatever IP address your service is currently reachable at. There are several DynDNS offers to choose from, both paid and free. Details of setting it up depend on which one you choose.
Allow incoming connections for the service in your router's firewall. For IPv4 most routers do this automatically when you set up the port forwarding (step 2). For IPv6 you'll have to configure it manually. Again, details vary wildly between router models.
Each of those steps can and should be tested individually before proceeding to the next one.
6