I'm not understanding something. I am trying to build a server on a Raspberry Pi with Apache. I can access it from my own network, but not outside. I already got the port forwarding and all that setup. I think I may have the answer to my problem but I am not understanding it.

So, I gave a friend my Internal IP Address to see if he could load my webpage, he could not. Then I realized that the Internal IP is for use within a personal network only. For someone outside to gain access to your server, they need an External IP, right? But what I don't understand is that my Raspberry Pi's External IP is the same as my Mac's External IP! That doesn't make sense!

Now I theorize that maybe the External IP applies to your own network. A request bound for the Pi Server is addressed to the External IP. The router receives the request and forwards the request to the appropriate IP and port #. Am I getting my facts straight? Is that how it works or no? Can somebody explain this simply and clearly to me?

  • This question really has nothing to do with Raspberry Pi and has been answered here and other places many times. Did you try searching for an existing answer? Try superuser.com too. – Brick Dec 10 '17 at 18:02
  • Possible duplicate of Port forwarding raspberry pi – Brick Dec 10 '17 at 18:04
  • @Brick Yes I did searching, I either did not get an answer or didn't find a clear one. – Nathanael Carper Dec 10 '17 at 18:15
  • @Brick Your possible duplicate does not answer my question. It doesn't tell me why my Public IP is the same on my Pi and my Mac. It also talks about ports, that's not my issue. I'm asking about IP addresses. – Nathanael Carper Dec 10 '17 at 18:18
  • ALL the devices on your home LAN will have the IP address that is given to the cable/adsl-modem & router device. If you are providing a "service" to the outside world it is like to be listening on a well-known port (e.g. 80 for an HTTP (web) server) and you will have to arrange for incoming requests to be forwarded by the modem/route to the particular local machine (i.e. your RPi) to handle it... – SlySven Dec 18 '17 at 10:45

That's pretty much it. Http requests for example will normally come in on port 80 so if you want the Pi to serve web pages externally you'd forward port 80 on the router to port 80 on the Pi. The Pi also needs configuring to accept external requests on that port (usually using a UFW rule)

  • Ah, thanks, that answers it. I wasn't completely sure whether my theory was correct, but you answered that! Thanks. So...how do I configure the Pi to accept external requests? – Nathanael Carper Dec 10 '17 at 18:21
  • Regarding UFW it's a simple as allowing all incoming to port 80 using the command below at a terminal prompt on the pi :- sudo ufw allow 80 – Bra1n Dec 10 '17 at 18:54
  • You can check how UFW is currently set using :- sudo ufw status or sudo ufw status verbose – Bra1n Dec 10 '17 at 18:58
  • Terminal is complaining to me that UFW command could not be found. I looked it up online and it appears UFW is something I need to install. Is that correct? – Nathanael Carper Dec 10 '17 at 20:09
  • Sorry I thought it was installed as standard so yes you need to install it, it's just a front end for iptables. There's plenty of info online about how to install and set it up. – Bra1n Dec 11 '17 at 8:31

This question is not Raspberry Pi related. I guess you are talking about IPv4, right?

Thus what you are looking for is likely DNAT https://en.wikipedia.org/wiki/Network_address_translation

Nowadays it can not be taken for granted that your Network does even have an unique IPv4 address at all. The term in this case would be Carrier-grade NAT https://en.wikipedia.org/wiki/Carrier-grade_NAT

Not the answer you're looking for? Browse other questions tagged or ask your own question.