Using dnsmasq/iptables to redirect DNS/HTTP traffic on Tomato

If i forward trailers.apple.com on my routers DNS to the IP of my plex server, for some strange reason it pings fine but the AppleTV still goes to the real apple trailers stuff. Any idea how that is possible?

I dont change any ports btw, all is the default.

Possibly the DNS cache need flushing or syntax error.

It pings to the correct ip everywhere.

I've added the address= line to my DNSMASQ in Tomato (and saved the change) but am still able to access trailers.apple.com. Do I need to reset the router for this change to take effect?

*push*

what do we have to update after apple updated the trailers.app with the certification stuff?

my Dnsmasq right now:

address=/trailers.apple.com/192.168.1.1
address=/atv.plexconnect/192.168.1.1

my scripts right now:

iptables -t nat -A PREROUTING -s 192.168.1.12 -d 192.168.1.1 -p tcp -m multiport --dports 80,443 -j DNAT --to-destination 192.168.1.50:80

something is missing, because its working with DNS from PlexConnect. so its a error in the dnsmasq way on the tomato router. any ideas?

Hmm, I'm not sure. I haven't tried after SSL became required. When I get time I'll update here. 

I do see one issue with the iptables redirect, though. It's redirecting to port 80 on your PlexConnect box (192.168.1.50). Try to separate lines like this:

 
iptables -t nat -A PREROUTING -s 192.168.1.12 -d 192.168.1.1 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.50:80
iptables -t nat -A PREROUTING -s 192.168.1.12 -d 192.168.1.1 -p tcp --dport 443 -j DNAT --to-destination 192.168.1.50:443

Would love to find out how to get this working with the new SSL requirement.

I'm using these settings in my firewall script with plexconnect running on port 81 for www and port 82 for SSL.

iptables -t nat -A PREROUTING -i br0 -p tcp --syn -s 10.10.10.121 -d 10.10.10.1 --dport 80 -j DNAT --to-destination 10.10.10.116:81
iptables -t nat -A PREROUTING -i br0 -p tcp --syn -s 10.10.10.121 -d 10.10.10.1 --dport 443 -j DNAT --to-destination 10.10.10.116:82
 
10.10.10.121 is my appletv, 10.10.10.1 is my router and 10.10.10.116 is my synology/plex/plexconnect. I changed the Settings.cfg to run ssl on 82 and www on 81 so I can continue to run my other webservices on 443 and 80 with no disruption.
 
I do have dnsmasq to set the router as the address for trailers.apple.com and atv.plexconnect to 10.10.10.1.
 
Works great so far.

Anyone know if this is possible to do on a Gargoyle router? Doesnt seems like I have the abbility to do this from the GUI, but maybe from ssh command line?

My setup is:

NAS running PMS 192.168.1.110

NAS running PlexConnect on 192.168.1.111

Apple TV 192.168.1.169

Would be sweet if I could configure my Gargoyle router so I dont have to change DNS settings on my Apple Tv since if NAS is down everything else on Apple TV is down aswell.

Will this also work with WHS2011 which is hogging ports 80 and 443.  I tried to get it to work by method listed here from the guide and all, but no love.  I got port 80 and 443 errors. 

Anyone know if this is possible to do on a Gargoyle router? Doesnt seems like I have the abbility to do this from the GUI, but maybe from ssh command line?

I'm not familiar with this firmware, but what I could find after some Googling was that you should be able to ssh into the device and edit the file /etc/dnsmasq.conf

After editing the file you should restart the dnsmasq process (I think...). You can reboot the router or use this command: /etc/init.d/dnsmasq restart

what about DD WRT and PMS on windows 7?

Trying to figure this out with whs2011 and dd-wrt myself, I'll post back any luck I may have but it will probably be a couple of days.

what about DD WRT and PMS on windows 7?

DD-WRT dnsmasq howto: http://www.dd-wrt.com/wiki/index.php/DNSMasq_-_DNS_for_your_local_network_-_HOWTO

DD-WRT and iptables: http://www.dd-wrt.com/wiki/index.php/Iptables_command

Info from this thread can be used.

Thanks sander1 will check out the links.  Seems like I'm almost there from my initial attempt but can't quite get past the port issues with WHS 2011 and not breaking some of it's functionality to boot.  Hoping this dnsmasq method will work things out for me. Some of this stuff is new ground for me. :unsure:

maybe a step by step guide for DD WRT using windows, guys? would really appreciate it. thanks

Did not work the way I thought sorry for confusion, if I figure it out I will post back.

iamjustme, 

I got a positive response from PlexConnect and the server seems to be running.
I can’t confirm as I am doing everything remotely on my dedicated
and don’t have access to ATV at the moment, but the cmd box seems to be showing
all the right info.

In DD-WRT
101 is Router
103 is ATV
133 is server

Go to administration, commands and paste the below with the ip’s for your devices.

iptables -t nat -I PREROUTING -p tcp -s 192.168.1.103 -d $(nvram get wan_ipaddr) --dport 80 -j DNAT --to 192.168.1.2:80
iptables -I FORWARD -p tcp -d 192.168.1.133 --dport 81 -j ACCEPT
iptables -t nat -I PREROUTING -p tcp -s 192.168.1.103 -d $(nvram get wan_ipaddr) --dport 443 -j DNAT --to 192.168.1.2:443
iptables -I FORWARD -p tcp -d 192.168.1.133 --dport 82 -j ACCEPT

Then under the services tab I added the following command which again is the router ip in the DNSmasq field

address=/trailers.apple.com/192.168.1.1

The follwing step from page 1 didn't matter in my setup either way worked.

3) Disable the PlexConnect DNS server (optional, but recommended for this setup)

The next step didn't show port 80 in the file so I also left it alone

4) Change the port that PlexConnect runs on (optional if you don't have a port conflict)
 
Since I'm using WHS 2011 this may be different for you.  I had to do some stuff in IIs to bind the trailers.apple.com site to port 81 and then that's when it was successful. 
 
Hopefully you can get going with what I listed above for the dd-wrt firmware.  I won't get to actually test the ATV until tonight or tomorrow, but from what I'm it says servers discovered and xmlconverter is sending to my server port 32400.
 
 
 

thank you so much for the guide. I'll give it a try and let you know if working

1 caveat is that it is messing with some of the functionality of whs remote access thru the servers domain site but Plexconnect seems to be running now.  I can still access thru RDP.

one more thing, I have multple atvs, do I need to set up each atvs like this?