Question

I have a linux DHCP server which I need to redirect all web traffic to a landing page which will have instructions on how to register their computer on the network.

No matter what URL a user types in, the user needs to be redirected to a webpage (on the DHCP server).

ie: user types google.com they are immediately redirected to 192.168.10.1. This DHCP server will never be used to access the web. Once the user acquires the instructions to register their computer from the landing page, they will be blacklisted on this particular DHCP server and forced to request an IP from the main DHCP server.

How can I create such a redirect?

Was it helpful?

Solution

You appear to be trying to set up what's known as a captive portal.

There are several components to this, one of which is indeed a DHCP server, but that's hardly the most critical one.

A short overview

Your network will have at the very least the following components:

  • DHCP server
  • DNS server
  • Gateway
  • A login system

Clients will get an IP address from the DHCP server and will be told to use your DNS server and gateway.

Solution 1: DNS based redirection

Until users are logged in your DNS server replies with the IP address of the login web server. Take care to set a very low TTL on the DNS replies. You want to make sure the clients browser re-resolves the IP address after the login.

This will quite likely cause problems for any application other than web browsing on port 80.

Solution 2: TCP interception

This is a slightly harder solution, but is likely to work better. The DNS server always returns the correct IP address for whatever web site the client is trying to reach. The gateway will redirect the TCP sessions on port 80 to the login server. All other packets should get an ICMP error reply (network unreachable for example).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top