iptables different ports on each ip address
What is the best way to set up port rules for 2 different IP addresses with iptables? eg
212.xxx.xxx.xxx open 80, 3128, DNS, and ICMP 213.xxx.xxx.xxx open 22 only. |
Well if they are on the same machine, then you'd just use standard iptables commands. Probably best to start off doing it with the system-config-security tool though if you're not familiar with iptables. There's nothign specifically interesting about doing it for two different IP adddress, it's still standard iptables if you do want to do it directly yourself.
/sbin/iptables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT /sbin/iptables -A INPUT -p tcp -m state --state NEW -d 213.x.y.z/32 --destination-port 22 -j ACCEPT /sbin/iptables -A INPUT -j DROP etc... http://linux.sys-con.com/node/32837 |
I get a bad argument error when using this:
Code:
*filter |
/32 makes it host specific, not sure if it's compulsory or not.
|
ACCEPT is an option to -j. you can't put things between them.
|
Quote:
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -d 88.xxx.xxx.xxx/32 -j ACCEPT Is it a bad idea to allow all icmp requests? |
So, it has to be?
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -d 88.xxx.xxx.xxx/32 -j ACCEPT |
That should work just fine.
As to whether it's bad to allow ICMP packets: Peoples views differ. According to the TCP/IP RFCs it's a must; but many firewalling folk (and mainly from the dark, errh, windows side) feel that stealthily dropping them is a good idea. Cheers, Tink |
Well remember also that there are LOTS of different types of ICMP packets not just echo-request and echo-reply for ping, and there are plenty of attacks that use certain obscure types. So you should really accept by exception, not by default. That's the theory at least.
|
Quote:
|
If I want to forward port 80 to port 3128 with the above iptables script do I only need to add:
-t nat -A PREROUTING -i eth0 -p tcp --dport 80 \ -j REDIRECT --to-port 3128 |
Is the following okay for ICMP?
Code:
SHould I add this for syn flood? I guess the last DROP is not needed if I add it to the rulebase above? Code:
iptables -N syn_flood |
All times are GMT -5. The time now is 04:28 AM. |