Hi!
I need some help with my iptables rules.
I want to reject all incomming and forwarding traffic and allow all outgoing traffic.
I want to drop some ports and I want to allow SSH.
The problem is that I can't log in through SSH with there rules.
Code:
#!/bin/bash
IPTABLES = /sbin/iptables
# Clear and flush tables.
$IPTABLES -F
$IPTABLES -Z
# Reject all incomming and forwarding traffic. Accept all outgoing traffic.
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -A INPUT -j REJECT
$IPTABLES -A FORWARD -j REJECT
# Drop traffic on ports: 135, 137, 138, 139 and 445
$IPTABLES -A INPUT -p tcp --destination-port 135 -j DROP
$IPTABLES -A INPUT -p tcp --destination-port 137:139 -j DROP
$IPTABLES -A INPUT -p tcp --destination-port 445 -j DROP
# Accept SSH.
$IPTABLES -A INPUT -p tcp --destination-port 22 -j ACCEPT
I would also like to know which kernel options I need to have to be able to use this.
Code:
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Thanks!