Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a local wireless network running. It is not connected to the internet and it has a webserver (lighttpd) running on 192.168.0.1

This webserver has a website running on it.

I want to know how can I redirect the user to "192.168.0.1" whenever he / she tries to access any other IP on this wireless network.

I have "dnsmasq" as my DNS Server.

To summarise:

"http://192.168.0.1" ==> Allowed to access

"http://193.168.0.1" ==> Makes no sense in this local wireless network, so want to redirect the user by default to "http://192.168.0.1"

Thanks, Mahendra.

share|improve this question

3 Answers 3

You can try to add this row into you dnsmasq.conf:

address=/#/192.168.0.1

From man page: ... with the additional facility that /#/ matches any domain. Thus --address=/#/1.2.3.4 will always return 1.2.3.4 for any query not answered from /etc/hosts or DHCP...

share|improve this answer
    
Hello @lg, I tried adding this to dnsmasq.conf.. However when I tried to browse "mydummyhostname.com"; it gave " Server not found " Do you have any idea? –  Mahendra Mar 23 '11 at 10:15
    
I suppose you restarted dnsmasq server. Are you sure your client is using dnsmasq as dns server? Try to add address=/mydummyhostname.com/192.168.0.1 in dnsmasq.conf. I edited my response. –  lg. Mar 23 '11 at 10:22
    
I tried adding "address=/mydummyhostname.com/192.168.0.1" to dnsmasq.conf and it still shows "Server not found" do you have any idea what could be wrong? Am i missing something? –  Mahendra Mar 23 '11 at 10:45
    
Check you client DNS configuration. Which S.O. are you using as client? –  lg. Mar 23 '11 at 11:30

You can use iptables to redirect 80 port to yours ip

iptables -t nat -D PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.0.1

updated

share|improve this answer
    
this command does not work on my linux machine... I am using linux 2.6.32 and its on embedded device. –  Mahendra Mar 23 '11 at 10:52
    
try againe. there were some mistakes with - and -- parameters; check /sbin/iptables for command –  MealstroM Mar 23 '11 at 11:35
up vote 0 down vote accepted

Okay, I solved the problem. Posting the solution here back with hope that it helps somebody in the future...

I solved this by modifying the lighttpd.conf file. I added the following inside my lighttpd.conf file:

$HTTP["host"] !~ "mydesiredhostname\.com" {
        url.redirect = (
                                "" => "http://192.168.0.1/"
                        )
}

I even had to add the following to my dnsmasq.conf file: (thanks to the answer below)

address=/#/192.168.0.1

Thank you everybody for your time. Cheers!

share|improve this answer

Your Answer

 
discard

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.