Cara Membuka Port di Firewall Linux CentOS
Secara default firewall iptable menyimpan konfigurasi di /etc/sysconfig/iptables . Anda dapat mengedit file tersebut dan menambahkan aturan/rules untuk membuka nomor-nomer yang ada pada port. Konfigurasi ini bisa digunakan pada versi Linux :- Red Hat Enterprise Linux 3 / 4 / 5 and above
- Old Red hat Linux version
- CentOS 4 and above
- Fedora Linux
buka flle /etc/sysconfig/iptables:
# vi /etc/sysconfig/iptables
Tambahkan aturan/rule sebagai berikut :
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
Simpan dan tutup file. Restart iptables:
# /etc/init.d/iptables restart
Cara Membuka Port 3306 (MySQL Remote) :
# /sbin/iptables -A INPUT -i eth0 -p tcp –destination-port 3306 -j ACCEPT
atau dari hanya IP Address 192.168.1.15
#/sbin/iptables -A INPUT -i eth0 -s 192.168.1.15 -p tcp –destination-port 3306 -j ACCEPT
atau dari lan subnet 192.168.1.0/24
#/sbin/iptables -A INPUT -i eth0 -s 192.168.1.0/24 -p tcp –destination-port 3306 -j ACCEPT
Cara Restart service iptables
Ketikkan perintah berikut:
service iptables restart |
Jalankan perintah berikut:
netstat -tulpn | less |
iptables -L -n |
man iptables |
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
COMMIT
"/etc/sysconfig/iptables" 23L, 1110C
[CODE]# nano /etc/sysconfig/iptables[/CODE]
tambah baris berikut
[CODE]-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT[/CODE]
restart iptables-nya
[CODE]# /etc/init.d/iptables restart[/CODE]
mudah2an worked
kalau untuk menambah port di kali linux juga tinggal edit doang om?
ReplyDelete