1

I want to make my raspberry pi server public, I have successfully used it locally and "it works". There are a lot of tutorials on this but they all say that you have to do some port forwarding in your router, now here is the problem. I am using my raspberry pi itself as a wifi router or wifi hotspot (connected to the internet via lan cable), I did this by following the instruction given at http://elinux.org/RPI-Wireless-Hotspot.Whenever I call the local rpi ip 192.168.42.1 from my laptop (ip=192.168.42.7) connected to the internet via the rpi hotspot "it works" page appears, but not when I call the global ip (103.37.xxx.xx) which I got from http://www.whatismyip.com/ it says "This webpage is not available" in chrome. Please help me with port forwarding in raspberry pi router. Thanks

1
  • Where does the lan cable lead to?
    – user236012
    Commented Feb 13, 2015 at 14:10

3 Answers 3

2

The fact that you have an IP does not mean that this is your public IP that actually can be accessed from "internet" side. Your global IP might be only a router IP. You have to contact your ISP to find your if your IP is public or behind NAT

1

Assuming your pi is directly connected to the internet (no intervening router -- verify this by checking that "sudo ifconfig eth0" shows your 103.37.x.x address), you will need iptables rules to accept incoming connections on port 80.

I don't have a config were I can test this specific scenario, but you will want something like this:

sudo iptables -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A INPUT --protocol tcp -i eth0 --dport 80 -j ACCEPT

This will bypass the handoff of those requests to the NAT logic on the FORWARD chain. (If you have existing rules on the INPUT chain, you may want -I to insert these new rules at the beginning rather than -A to append them at the end).

Before you do this you should be sure you have physical access to the pi in case you lock out remote access. Don't save the iptables config until you're sure it works the way you want it to.

You should also be aware that allowing direct access from the internet can be risky. You should be prepared to update your system regularly (perhaps even daily) to apply new security fixes; you should also make sure your web server config doesn't have any unnecessary modules loaded or allow any unintended access.

My final advice would be to make a backup of the working system, and be prepared to trash the running copy if it is compromised in some way.

1

One thing that I noticed for my internet is that when I port forwarded my webserver and I tried to connect to it using my public ip it would say that it was not available, but when I connect to it on my phone or on my schools network I am able to connect to it, also one thing you could try to do is go to google and type in "IP" into the search bar, copy the ip it gives you and then go to google translate and paste in your ip, and then click on the blue ip address in the right window, and that should show you if you successfully portforward your web server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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