What's new

How to redirect a client to a certain host within LAN

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

aht961

Occasional Visitor
What is the simplest way to accomplish the following scenario (RT-N66U, running the most recent Merlin firmware)?

The client with a static IP (e.g. 192.168.0.10) should be directed to a certain host within the same a LAN (e.g. 192.168.0.15) hosting a web server (at http port 80 and https port 443) every time when this client (192.168.0.10) tries to connect to a domain named "www.somedomain.com". The DNS server is the router with Ip 192.168.0.99

ps: I have very little (or none) experience with setting the Dnsmasq. I understood from looking at the forums that this could be done by creating a dnsmasq.conf.add under /jffs/configure, however, I do not now what to include in that.

Could anybody give me some hints or guide in the right direction?
 
you can do this with a hosts file and asuswrt-merlin. enable jffs via Administration > System, then copy the existing hosts file from /etc/hosts to /jffs/configs/hosts and add a line like thus at the end;

192.168.0.15 whatever.com

[edit/] forgot to add, this technically isn't a redirect, instead whatever.com will just show up as 192.168.0.15 and will be whatever.com in the browser address bar
 
Last edited:
you can do this with a hosts file and asuswrt-merlin. enable jffs via Administration > System, then copy the existing hosts file from /etc/hosts to /jffs/configs/hosts and add a line like thus at the end;

192.168.0.15 whatever.com

[edit/] forgot to add, this technically isn't a redirect, instead whatever.com will just show up as 192.168.0.15 and will be whatever.com in the browser address bar

Thank you for the quick reply. I will try that. However, in that situation for ANY client, the 192.168.0.5 will be considered as whatever.com. What if if I wanted this only for a particular client (192.168.0.10)? In other words, for all other clients the whatever.com is indeed "whatever.com" on the WAN side, but for 192.168.0.10 it is 192.168.0.15.
 
ah, you're right, sorry. i *think* this would work... you'll need to ping the domain or something to get the IP and replace dnsip below; add this to /jffs/scripts/nat-start

iptables -t nat -A PREROUTING -s 192.168.1.10 -p tcp -d dnsip --dport 80 -j DNAT --to-destination 192.168.1.15:80

should redirect for client .10 traffic destined for dnsip to .15

[edit/] changed it, sorry, think this will work
 
Last edited:
ah, you're right, sorry. i *think* this would work... you'll need to ping the domain or something to get the IP and replace dnsip below; add this to /jffs/scripts/nat-start

iptables -t nat -A PREROUTING -s 192.168.1.10 -p tcp -d dnsip --dport 80 -j DNAT --to-destination 192.168.1.15:80

should redirect for client .10 traffic destined for dnsip to .15

[edit/] changed it, sorry, think this will work

This is excellent, thanks a lot. As a side note, if I want also to add the 443 port, should I repeat the same line but with 443 instead of 80?
 
awesome, glad to hear it. and to answer your question; yep
 

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top