Username Always stay logged in
Password:

 

Pages: [1]
  Print  
Author Topic: iptables  (Read 2331 times)
martinc
Global Moderator
Pro Designer
*****

Karma: +1/-0
Offline Offline

Posts: 148



View Profile
« on: April 30, 2012, 01:38:16 AM »

a little basic firewalling

Code:
#!/bin/sh

echo "Flushing iptables rules..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

echo " Applying rules"
# allow whats listed

# loopback
iptables -I INPUT 1 -i lo -j ACCEPT

# need or http wont work for some reason
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# http
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

# ssh
iptables -A INPUT -p tcp --dport ssh -j ACCEPT

# ping
iptables -A INPUT -p icmp -j ACCEPT

# drop everything else
iptables -A INPUT -j DROP

should work fine, but if buggy then,
Code:
service iptables restart

http://www.netfilter.org/documentation/
Logged

I have as much authority as the Pope, I just don't have as many people who believe it. --George Carlin
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Greenday Theme Designed By [S.W.T]