This is for raspbian acting as a gateway.
computers -> [eth1] raspberry pi (dhcp) [eth0] -> modem/router -> internet
I made an ip forwarding rule which redirects all traffic coming from eth1 (10.1.1.x) to eth0 which is connected to a modem/router (192.168.2.1) which sends traffic to the internets.
This works, computers inside 10.1.1.x which are connected to eth1 of raspberry pi can go to the internet fine.
I'm looking for:
- netfilter rules which by default forward all web (port 80 and port 443) traffic to a local website (10.1.1.1:80) and
- other rules which add exceptions to that rule to allow certain machines via their mac addresses (or ip if that's not possible) to go to the internet as usual.
I wrote this which redirects requests for port 80 to local website:
iptables -t nat -A OUTPUT -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.1.1.1:80
But this one doesn't work, I can't redirect to different port:
iptables -t nat -A OUTPUT -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.1.1.1:80
I also couldn't find how to write exceptions to this rule to forward certain macs/ips as usual.