Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
  • 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

3 Answers 3

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

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'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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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