LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   newb question about iptables (https://www.linuxquestions.org/questions/linux-newbie-8/newb-question-about-iptables-543071/)

ripper 04-08-2007 09:43 AM

Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination

i deleted all rules
now ho do i start from the begining :|

SlowCoder 04-08-2007 08:04 PM

Quote:

Originally Posted by ripper
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination

i deleted all rules
now ho do i start from the begining :|

First off, I recommend creating a script that populates iptables, rather than attempting to modify the tables directly. This way you can modify as needed, and run the script to update.

My script starts out like this:

Code:

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -F INPUT
iptables -F OUTPUT

iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED

iptables -A INPUT -j ACCEPT -p all -s localhost -d localhost
iptables -A OUTPUT -j ACCEPT -p all -s localhost -d localhost

iptables -A INPUT -j ACCEPT -p all --dport ssh
iptables -A INPUT -j ACCEPT -p all --dport http
iptables -A INPUT -j ACCEPT -p all --dport ftp

1st section: sets the default behavior to DROP, clears the current tables
2nd section: allows all established connections to go through
3rd section: allows local machine processes to talk to each other.
This is very important.
4th section: is where you can specifically allow connections via port.

This is not nearly all my script, but it should get you started. Don't place your script in the rc.local until you're sure it will work. You can just restart your box to regain access. Otherwise if you make a booboo you might not be able to access your system.


All times are GMT -5. The time now is 08:47 AM.