Hi nobukadnezar,
Create a new file called 'clear-iptables', and inside this file; input the following.
Filename: 'clear-iptables'
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
After uploading this file onto your server, go into PuTTY/SSH and 'cd' to the directory of where you have uploaded this file and perform the following commands.
chmod +x clear-iptables
./clear-iptables
Now you can safely insert your own rules without previous rules conflicting your service. Here is an example of the iptables of which a server administrator should use for his RO service, but please note that this will close out all ports unless specified.
Filename: 'iptables-policy'
/sbin/iptables -F
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT
/sbin/iptables --policy INPUT DROP
/sbin/iptables --policy OUTPUT DROP
/sbin/iptables --policy FORWARD DROP
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# Allow incoming TCP port 22 (ssh) traffic
/sbin/iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
# Allow Ragnarok Online
/sbin/iptables -A INPUT -p udp --dport 6900 -m state --state NEW -j ACCEPT
/sbin/iptables -A INPUT -p udp --dport 5121 -m state --state NEW -j ACCEPT
/sbin/iptables -A INPUT -p udp --dport 6121 -m state --state NEW -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 6900 -m state --state NEW -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 5121 -m state --state NEW -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 6121 -m state --state NEW -j ACCEPT
# Allow MySQL
/sbin/iptables -A INPUT -p tcp --dport 3306 -m state --state NEW -j ACCEPT
/sbin/iptables -A INPUT -p udp --dport 3306 -m state --state NEW -j ACCEPT
# Have these rules take effect when iptables is started
/sbin/iptables-save
After uploading that file, you would simply 'cd' to the directory of the file location and perform the following commands.
chmod +x iptables-policy
./iptables-policy
And now, all traffic is blocked except for 22, 6900, 5121, 6121, and 3306. You can do some research on how to set limits/bursts, and then setting rules to drop malformed/ACK/SYN/spoofed packets, and other malicious traffic.