Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  • I have a server (SERVER). Running Ubuntu Server + DHCP server + Apache;
  • The router (ROUTER) (I haven't access to it);
  • I have a web-application on SERVER for registration users in the network by applying specific configuration (in DHCP server) for them;
  • Users are in the subnet;

I can config DHCP server to give unregistered machines my SERVER as default gateway.
So how can i redirect all incoming http requests from unregistered machines to my local web-app ?

share|improve this question
up vote 0 down vote accepted

echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A PREROUTING -p tcp -dport 80 -j DNAT –to-destination iptables -t nat -A POSTROUTING -j MASQUERADE

share|improve this answer

You'll have to setup a specal DNS server that responds all DNS queries with your server's IP and setup Apache's virtual server to accept request for any host (i.e. *:80 + *:443).

The trick is, after login, the DNS server must start providing correct DNS results as opposed fake ones. You cannot simply change the settings again in DHCP because the default lease time will be too long and/or users have to disconnect to pickup the new settings.

Many Wi-Fi log-in system uses this architecture, so you may be able to find an open source solution.

share|improve this answer
yes, this method is bad because of the thing, that users will have fake addresses cashed and won't be able to browse sites for some time after registration – Temak Sep 27 '12 at 22:27

I have found one another way.

  1. Give unregistered machines SERVER as default gateway.
  2. redirect port 80 to the web-server using iptables

But i don't know exactly how to do it :)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .