Setting firewall/iptables sederhana di linux

Saya post ini salah satu tujuannya spy saya gampang cari catatan jg sih πŸ˜›

Fungsi dari iptables a/ untuk buka tutup port sesuai keinginan kita, salah satu contoh sederhananya spt berikut ini:

*filter

# Allows all loopback traffic and drop all traffic to 127/8 that doesn't use lo
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT

# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allows all outbound traffic
-A OUTPUT -j ACCEPT

#SSH
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
#HTTP
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
#HTTPS
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
#SMTP
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
#IMAP
-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
#POP3
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
#PING
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
#oidentd
-A INPUT -p tcp -m tcp --dport 113 -j ACCEPT

# Log
-I INPUT 5 -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

# Reject all other inbound - default deny unless explicitly allowed policy
-A INPUT -j REJECT
-A FORWARD -j REJECT

COMMIT

LangkahΒ² utk seting iptables :
1. Buat file iptables, misalnya
nano /etc/iptables.conf
2. Kemudian copas contoh iptables diatas kedalamnya
3. Simpan file dan keluar
4. Restart iptablesnya
iptables-restore /etc/iptables.conf

Angka2 di file tersebut adalah port yg terbuka, sisanya ditutup, jika ingin buka port misalnya 12345 maka tambahkan baris :
-A INPUT -p tcp -m tcp --dport 12345 -j ACCEPT
sebelum baris -A INPUT -j REJECT

Semoga bermanfaat πŸ™‚

Incoming search terms:

  • cara setting firewall di linux
  • setting firewall di linux
  • firewall di linux
  • cara deactifkan firewall pada kali linux
  • cara melihat port debian iptables yang terbuka
  • membuka firewall dikaliLinux
work as freelancer - i’m a humanize human, a son, a father, a husband, who love coffee and cigarette, lazy and moody, entrepreneur, very easy to sleep, internet addict, bad designer, humorious, playing guitar, can’t singing & cooking, thin body, brown skin, smily, travelling & hiking, art & culture related, etc………

2 Comments

  1. ryurazen

    October 24, 2015 at 12:06 am

    Thx gan for the info πŸ˜€

    • admin

      August 27, 2016 at 10:53 am

      sama2 gan πŸ˜€

Leave a Reply

Your email address will not be published. Required fields are marked *

Top