2
  • I have a server 192.168.0.3 (SERVER). Running Ubuntu Server + DHCP server + Apache;
  • The router 192.168.0.1 (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 192.168.0.0/16;

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 192.168.0.3 ?

3 Answers 3

1

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

1

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.

1
  • 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, 2012 at 22:27
0

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 :)

You must log in to answer this question.

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