I'm using amazon EC2 and looking to set up some firewall rules for my scenario. EC2 is strange - in case you aren't familiar with EC2 - amazon offers elastic IP addresses that resolve to private IP addresses - there is no such thing as a truly public IP. I've got two private IP addresses attached to a single ethernet interface (eth0), and two corresponding elastic IPs that resolve to the private IPs to allow public access to the machine.
For the second private IP, I only want to accept packets if they come from a particular source (my IP address).
I can NOT use multiple ethernet interfaces to solve this, as I can only simulate multiple public IP addresses from the same interface (eth0) on EC2.
I've got standard rules in-place that allow ALL connections to commonly-used public ports from any source.
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 995 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 993 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 9001 -j ACCEPT
How can I add a rule further in the chain, that will further inspect the destination for EVERY request, and simply drop the request if the source (-s) isn't the IP address I specify?
I basically want to use a second IP address along with iptables and apache2 to only serve certain pages to me when I'm on my home network.
Thanks!