0

How can I restrict my network connections to a only my web-server?

EG, a user would connect to my network (WIFI/LAN) when they open a web browser and enter 127.0.0.1 it will load my app. But if they enter any other web address it would redirect back to 127.0.0.1?

Thanks everyone!

afro360
  • 101
  • 1
    That's more of a network/infrastructure question than a programming question, i.e. off topic here. – deceze May 15 '12 at 07:16
  • 4
    `127.0.0.1` will **never** load your app on any machine that is not the one where your app is running. It is the loopback device which will never send anything over the wire. – ThiefMaster May 15 '12 at 07:18
  • 2
    This kind of setup is generally known as "captive portal". There are both open source (e.g. CoovaAP) and commercial solutions available to accomplish this. – jhonkola May 15 '12 at 07:24
  • Thanks, thats why Im asking the questions because I have NO idea were to start or what to look for. Ill try find more info on "captive portal". –  May 15 '12 at 07:27

1 Answers1

0

You can setup a firewall using iptables (or whichever firewall you prefer) and create a rule that will redirect other traffic to your desired IP address. You will need to put the firewall between the LAN and the router/internet source. An iptables rule for this action would look like this: -A PREROUTING -d 127.0.0.1 -j REDIRECT --to-ports 80-80 127.0.0.1 being the IP address that you want to redirect traffic to. 80-80 is the port range of the rule. In this case only the HTTP traffic is being redirected. To redirect HTTPS traffic as well you would create another rule just like this but change 80-80 to 443-443.

Tristan Hall
  • 139
  • 1
  • 8