I need to create a file to filter traffic.
It should work like this:
- Input traffic from 192.168.5.0/24 should be blocked unless it's ICMP or from 192.168.5.200
- Output traffic to 192.168.5.0/24 should be blocked unless it's ICMP or to 192.168.5.200
- The remaining traffic should be allowed.
This is my solution:
iptables -P INPUT DROP
iptables -F INPUT
iptables -A INPUT -i eth0 -p ICMP -s 192.168.5.200 -j ACCEPT
iptables -A INPUT -i eth0 -s 192.168.5.0 -j DROP
iptables -A OUTPUT -o eth0 -p ICMP -d 192.168.5.200 -j ACCEPT
iptables -A OUTPUT -o eth0 -d 192.168.5.0 -j DROP
iptables -A OUTPUT ACCEPT
iptables -A INPUT ACCEPT
I'm new to iptables, so I appreciate any help I can get.