r/iptables•
redd__it

Block housemates from accessing my Apple TV

Hi! I live in a house with a couple others, and I'm not the only one with an Apple TV. Now sometimes, by accident, people pick the wrong Apple TV to use when airplaying, which turns on the connected tv.

Now since I am the one who set up the router in our home and this router runs FreshTomato and has the ability to use iptables, I wondered if the following would work. My iPhone and Apple TV both have a static IP address.

iPhone = 10.0.0.101 Apple TV = 10.0.0.102

iptables -I FORWARD ! -s 10.0.0.101 -d 10.0.0.102 -m state --state NEW -j REJECT --reject-with icmp-host-prohibited
iptables -I FORWARD -p tcp ! -s 10.0.0.101 -d 10.0.0.102 -m state --state NEW -j REJECT --reject-with tcp-reset

Will this prevent others on the network to access the Apple TV?

Posted Mar 1, 2021, 12:41 AM UTC

14
Ok3761•

The first line doesn't just reject ping, rejects tcp, udp, icmp, ect for new connections. Which might not actually be an issue for what you want to do, but makes the second line redundant. Plus you can take out the --reject-with since it's not limited to just ping.

Also you may or may not need to look ipv6 too if the iphone/tv use it. Can confirm Android will bypass ad blocks if ipv6 isn't blocked too anyways.

At any rate this looks solid:
iptables -I FORWARD ! -s 10.0.0.101 -d 10.0.0.102 -m state --state NEW -j REJECT

This might be better:
iptables -I FORWARD -s 10.0.0.101 -d 10.0.0.102 -j ACCEPT
iptables -I FORWARD -d 10.0.0.102 -m state --state NEW -j REJECT

​

Assuming your roommates' devices don't happen to have the same IPs

2
redd__itOP•

Hi! Thanks for your reply!

Due to the -I (which inserts the rule at the top of the chain) the second line will come first. The reason why I made a difference between TCP traffic (-p tcp) and other traffic is because you can reject TCP traffic with tcp-reset, which makes it behave differently from just rejecting without --reject-with:

A straight REJECT will respond with an ICMP unreachable which is not the response you would see on a port which is not listening

REJECT -reject-with tcp-reset makes the port behave as though nobody was listing and no firewall is in the middle.

^Source: ^Mark ^Hack's ^reply ^at ^https://bobcares.com/blog/iptables-drop-vs-reject/

1
redd__itOP•

I haven't been able to get this to work, no matter how I write the rules. Then, after some more searching, I found a topic with a similar use case.

The conclusion is that because the devices are on the same network (subnet? switch?) all routing is bypassed.

Anyone who can confirm this is indeed why those iptables rules don't work?

1
Ok3761•

Does the router have tc filter? It happens before iptables and can see lower layer packets

1