Jump to content
  • 0

IPTABLES - Configuration


CaioVictor

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Hi rAthena ^^'

 

First excuse my English.

 

I'm needing to install and configure IPTABLES to protect against DDOS attacks.

But I know nothing about the IPTABLES, so I need help.

 

To install I do the following:

yum install iptables

Am I right?

Once installed, to check if it is correct, I do the following:

iptables
yum info iptables

I'm still right?

If installed correctly, i can create a "iptables-policy" file to configure IPTABLES, right?

So i copied a file that i found in a thread here in the rAthena.

But I do not know if it is correct, to work with the emulator, mysql, phpmyamdin, ssh, ftp and remote connection to the database (because my website is hosted on a server different than the emulator, and the website connects remotely to the emulator database)

 

The configuration file is as follows:

#!/bin/sh

IPT=/sbin/iptables

$IPT -F INPUT
$IPT -f OUTPUT
$IPT -F FORWARD

$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT

$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP
echo "1" > /proc/sys/net/ipv4/ip_forward

IPCLIENT=`echo $SSH_CLIENT | sed 's/\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`
$IPT -A INPUT -s ${IPCLIENT} -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -d ${IPCLIENT} -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

# we add some SYN flood protection
$IPT -A INPUT -p tcp --syn -m limit --limit 5/s -j ACCEPT
$IPT -A INPUT -p udp -m limit --limit 10/s -j ACCEPT
$IPT -A INPUT -p tcp --syn -j DROP
$IPT -A INPUT -p udp -j DROP

# we add some ping flood protection
$IPT -A INPUT -p icmp --icmp-type echo-request -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-reply -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-request -j DROP
$IPT -A INPUT -p icmp --icmp-type echo-reply -j DROP

# Allow incoming TCP port 22 (ssh) traffic
$IPT -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT

# DNS (client)
$IPT -A OUTPUT -p tcp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --sport 53 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p udp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p udp --sport 53 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Web server (http, https)
$IPT -A INPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 443 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 443 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Web Client
$IPT -A INPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

# FTP Server
$IPT -A INPUT -p tcp --dport 20 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 20 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 21 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 21 -m state --state RELATED,ESTABLISHED -j ACCEPT

# FTP Client
$IPT -A INPUT -p tcp --sport 20 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 20 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --sport 21 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 21 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

# Portas Passivas do FTP
$IPT -A INPUT -p tcp --dport 1024:65535 --sport 1024:65535 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 1024:65535 --sport 1024:65535 -m state --state RELATED,ESTABLISHED -j ACCEPT

# auth
$IPT -A INPUT -p tcp --dport 113 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 113 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Allow Ragnarok Online
for PRT in 5121 6121 6900
do
$IPT -A INPUT -p tcp --dport $PRT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport $PRT -m state --state RELATED,ESTABLISHED -j ACCEPT
done

# Allow MySQL
$IPT -A INPUT -p tcp --dport 3306 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 3306 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 21 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 21 -m state --state RELATED,ESTABLISHED -j ACCEPT

 

After to run this file:

chmod +x iptables-policy
./iptables-policy

 

Could someone please check if everything is correct for perfect operation?
And if my website will not be blocked by flood?

 

Please, i really need to configure IPTABLES server protection.
Any help will be greatly appreciated.

 

Att,

CaioVictor.

Edited by CaioVictor
Link to comment
Share on other sites

13 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  707
  • Reputation:   168
  • Joined:  01/26/12
  • Last Seen:  

Hi CaioVictor,

 

You should consider installing CSF, as it's a more dynamic firewall than just having a static IPTables ruleset. The configuration file provided is not ideal, you should be making a chain to filter opened ports; but still can be used for minimal protection...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Hello great Asura xD

 

I've thought about installing "CSF", however, I was informed that he would consume an unnecessarily processing, is this true?

Anyway, I do not know how to configure it.

I'm studying a lot about it (linux firewall), but still did not understand much.

 

This setting i spent above, you could tell me if it is correct?

 

Att,

CaioVictor.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  707
  • Reputation:   168
  • Joined:  01/26/12
  • Last Seen:  

Hi CaioVictor,

 

I would fix "$IPT -f OUTPUT" to have -F, and also to remove the last 2 lines since they are duplicates. This is only a quick glance, but it looks okay to me.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Hi Asura ^^"

 

I made the changes you said:

 

#!/bin/sh

IPT=/sbin/iptables

$IPT -F INPUT
$IPT -F OUTPUT
$IPT -F FORWARD

$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT

$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP
echo "1" > /proc/sys/net/ipv4/ip_forward

IPCLIENT=`echo $SSH_CLIENT | sed 's/\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`
$IPT -A INPUT -s ${IPCLIENT} -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -d ${IPCLIENT} -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

# we add some SYN flood protection
$IPT -A INPUT -p tcp --syn -m limit --limit 5/s -j ACCEPT
$IPT -A INPUT -p udp -m limit --limit 10/s -j ACCEPT
$IPT -A INPUT -p tcp --syn -j DROP
$IPT -A INPUT -p udp -j DROP

# we add some ping flood protection
$IPT -A INPUT -p icmp --icmp-type echo-request -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-reply -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-request -j DROP
$IPT -A INPUT -p icmp --icmp-type echo-reply -j DROP

# Allow incoming TCP port 22 (ssh) traffic
$IPT -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT

# DNS (client)
$IPT -A OUTPUT -p tcp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --sport 53 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p udp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p udp --sport 53 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Web server (http, https)
$IPT -A INPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 443 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 443 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Web Client
$IPT -A INPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

# FTP Server
$IPT -A INPUT -p tcp --dport 20 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 20 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 21 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 21 -m state --state RELATED,ESTABLISHED -j ACCEPT

# FTP Client
$IPT -A INPUT -p tcp --sport 20 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 20 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --sport 21 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 21 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

# Portas Passivas do FTP
$IPT -A INPUT -p tcp --dport 1024:65535 --sport 1024:65535 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 1024:65535 --sport 1024:65535 -m state --state RELATED,ESTABLISHED -j ACCEPT

# auth
$IPT -A INPUT -p tcp --dport 113 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 113 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Allow Ragnarok Online
for PRT in 5121 6121 6900
do
$IPT -A INPUT -p tcp --dport $PRT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport $PRT -m state --state RELATED,ESTABLISHED -j ACCEPT
done

# Allow MySQL
$IPT -A INPUT -p tcp --dport 3306 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 3306 -m state --state RELATED,ESTABLISHED -j ACCEPT

 

Now my fear is that the website can be blocked, as it is in different server and make remote connections to the database of emualdor.

Can that happen?

 

Thank you for reviewing my code and all the help you have given me.

 

Att,

Caiovictor.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  707
  • Reputation:   168
  • Joined:  01/26/12
  • Last Seen:  

Hi CaioVictor,

 

I would remove this from your code;

 

# Web server (http, https)
$IPT -A INPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 443 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 443 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Web Client
$IPT -A INPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

 

It should work fine; you do not need port 80 to be opened if you are not hosting your website on your server itself.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Ok!


But I access server phpmyadmin by the browser.

Removing these lines will not have problems accessing phpmyadmin?

 

If it is not too cumbersome, in this code the server is also protected against Death Ping?

 

Att,

CaioVictor.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  707
  • Reputation:   168
  • Joined:  01/26/12
  • Last Seen:  

Hi CaioVictor,

 

ICMP/Ping Requests are limited in the firewall script... as you should have been able to see clearly.

 

If your phpMyAdmin is hosted on your RO server, then I guess you should leave it alone and have the port 80/443 rules.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Hi Asura ^^'

 

I've been thinking...

As i just need server access(ragnarok online), phpmyadmin, ssh, local/remote database connection, the code might look just like this:

#!/bin/sh

IPT=/sbin/iptables

$IPT -F INPUT
$IPT -F OUTPUT
$IPT -F FORWARD

$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT

$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP

# SYN flood Protection
echo 1 > /proc/sys/net/ipv4/tcp_syncookies 

IPCLIENT=`echo $SSH_CLIENT | sed 's/\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`
$IPT -A INPUT -s ${IPCLIENT} -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -d ${IPCLIENT} -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

# IP Spoofing Protection
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
$IPT -A INPUT -s 192.168.1.0/24 -i ! eth0 -j DROP
$IPT -A INPUT ! -s 192.168.1.0/24 -i eth0 -j DROP

# Ping Flood Protection
$IPT -A INPUT -p icmp --icmp-type echo-request -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-reply -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-request -j DROP
$IPT -A INPUT -p icmp --icmp-type echo-reply -j DROP

# Web Server (HTTP, HTTPS) (Only for phpmyadmin)
$IPT -A INPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 443 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 443 -m state --state RELATED,ESTABLISHED -j ACCEPT

# Allow SSH
$IPT -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow Ragnarok Player/Server Connection
for PRT in 5121 6121 6900
do
  $IPT -A INPUT -p tcp --dport $PRT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
  $IPT -A OUTPUT -p tcp --sport $PRT -m state --state RELATED,ESTABLISHED -j ACCEPT
done

# Allow MySQL
$IPT -A INPUT -p tcp --dport 3306 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 3306 -m state --state RELATED,ESTABLISHED -j ACCEPT

More simple and direct, right?

Is there something wrong?
I forgot something?

 

Thanks for replying again!

 

Att,

CaioVictor.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  707
  • Reputation:   168
  • Joined:  01/26/12
  • Last Seen:  

Hi CaioVictor,

 

Looks good to me.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Hi great Asura!

 

First of all I want to thank you wholeheartedly for your help!

 

Can you explain the lines of IP Spoofing Protection and Ping Flood Protection, this can impair access to the server(ragnarok online game)?

 

Att,

CaioVictor.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  707
  • Reputation:   168
  • Joined:  01/26/12
  • Last Seen:  

Hi great Asura!

 

First of all I want to thank you wholeheartedly for your help!

 

Can you explain the lines of IP Spoofing Protection and Ping Flood Protection, this can impair access to the server(ragnarok online game)?

 

Att,

CaioVictor.

Hi CaioVictor,

 

What kind of service do you have? Dedicated Server? OpenVZ? KVM? XEN?

 

Ping Flood only limits ping requests, it has no affect on your RO gameplay. Anti-Spoof is a kernel-related; it may eat up a bit more CPU & RAM; though it also has no affect on your RO gameplay (unless CPU & RAM becomes exhausted).

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  75
  • Reputation:   0
  • Joined:  05/26/12
  • Last Seen:  

Hi again Asura xD

 

I have hired a VPS service.

With the help of a friend, we create a basic configuration for iptables, and i think for this moment, it is the best that i can get set up.

 

Thank you for all the help and support you gave me!

 

Att,

CaioVictor.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  7
  • Reputation:   0
  • Joined:  01/05/12
  • Last Seen:  

You should consider to get back DNS block

Your server use DNS request to get reverse of users, or to link some services

 

please find below some explanation with the modified code :

(comments betwen /* and */ , remove them before use)

/* script start */
#!/bin/sh
 
/* we create a shortcut to call iptables */
IPT=/sbin/iptables
 
/* we flush actual rules for incoming data, outgoing data, and data we are forwarding */
$IPT -F INPUT
$IPT -F OUTPUT
$IPT -F FORWARD
 
/* first of all, we can consider server is safe, and so we just allow loopback not to be blocked or filtered */
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT
 
/* set default policy to drop datas */
$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP

echo "1" > /proc/sys/net/ipv4/ip_forward
 
/* we don't want to be banned as we are running script, so we keep our actual IP, and allow incoming traffic on server from us, and outgoing traffic from server to us */
IPCLIENT=`echo $SSH_CLIENT | sed 's/\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`
$IPT -A INPUT -s ${IPCLIENT} -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -d ${IPCLIENT} -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
 
/* Syn flood is a sort of dos attack in which an attacker sends a succession of SYN requests to a target's system in an attempt to consume enough server resources to make the system unresponsive */
/* here we accept SYN requests, but set a limit for that */
# we add some SYN flood protection
$IPT -A INPUT -p tcp --syn -m limit --limit 5/s -j ACCEPT
$IPT -A INPUT -p udp -m limit --limit 10/s -j ACCEPT
$IPT -A INPUT -p tcp --syn -j DROP
$IPT -A INPUT -p udp -j DROP
 
/* same here but for ping of death, and so icmp requests (be carefull that setting a strict limite can slow down traffic like TeamSpeak */
# we add some ping flood protection
$IPT -A INPUT -p icmp --icmp-type echo-request -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-reply -m limit --limit 4/s -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-request -j DROP
$IPT -A INPUT -p icmp --icmp-type echo-reply -j DROP
 
/* here we accept incoming ssh traffic on server, and request from server */
# Allow incoming TCP port 22 (ssh) traffic
$IPT -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT
 
/* we accept here DNS request from and to your server. This is needed since server need to resolve ip-address if option is active. Eventualy, you could only accept DNS traffic from and to your DNS server (see your network configuration, or your provider to get ip address */
# DNS (client)
$IPT -A OUTPUT -p tcp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --sport 53 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p udp --dport 53 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p udp --sport 53 -m state --state RELATED,ESTABLISHED -j ACCEPT
 
/* we accept web traffic to server as we want to access phpmyadmin */
# Web server (http, https)
$IPT -A INPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp --dport 443 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 443 -m state --state RELATED,ESTABLISHED -j ACCEPT
 
/* i recommand to keep this block as you need this to upgrade your applications (yum update / upgrade like aptitude use http  ) */
# Web Client
$IPT -A INPUT -p tcp --sport 80 -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
 
/* we can remove FTP section as you don't have FTP server /*
 
/* auth section goes with FTP as it is used to authenticate client computer on server. here we can remove this */
 
/* we just allow your "ragnarok's traffic" */
# Allow Ragnarok Online
for PRT in 5121 6121 6900
do
$IPT -A INPUT -p tcp --dport $PRT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --sport $PRT -m state --state RELATED,ESTABLISHED -j ACCEPT
done
 
/* we allow remote access on our SQL server. Local access is already accept since it's going directly from system to system, bypassing network */
# Allow MySQL
$IPT -A INPUT -p tcp --dport 3306 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 3306 -m state --state RELATED,ESTABLISHED -j ACCEPT
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...