Originally Posted by branden_burger
Here's an iptables rule, which says to allow from 192.168.1.0/24 on my firewall/NAT/proxy box.
-A INPUT -s 192.168.1.0/255.255.255.0 -p tcp -m tcp --dport 3128 -j allowed
Now to be safe that only internal network traffic to squid is allowed, do I need to make sure that I also add an interface switch? I mean , do I need to do
-i eth(internal) ?
I mean, can there be packets out on the internet which claim to be from my internal network?
There could be, but enabling reverse-path filtering and/or the bogon filter will usually kill them off. Something's going to have to become severely broken for someone on the internet to be able to complete a TCP connection by spoofing a private network IP address, since as has been pointed out, these packets generally aren't allowed to cross the Internet--and your box is likely going to send it's handshake packets to your localnet instead of the Internet.
Note the usual suspects:
Stuff 1's in whichever of these you feel necessary (I wouldn't mess with lo's tho') to enable it. What will happen then is each packet arriving on an interface will be looked at briefly and if it wasn't supposed to have come from there, it'll be destroyed. There's a more detailed explanation hiding in /usr/src/linux/Documentation.
A *better/faster* way to deal with this issue is to simply drop in a rule at the end of your generic "apply 'em to all interfaces" rules section that will jump traffic to a chain of rules meant just for that interface. When I last checked, specifying an interface on a rule will make it only match traffic on that interface, but potentially all traffic can waste CPU time *attempting* to match against it. This can reduce the amount of overhead your system has to deal with during periods of heavy network load depending on how elegantly you've created your rules. (Either way, a chain named input_eth0 is kind of hard to misinterpret if you're up late at night trying to troubleshoot something) You can then be as particular as you want about each individual interface and what rules you wish to apply to it.