Pada saat virtual private server (VPS) CentOS pertama kali di install port pada firewall iptables yang di allow adalah port 22 dan konfigurasi file firewall iptables pada CentOS disimpan dalam /etc/sysconfig/iptables. Untuk membuka port hanya perlu mengedit file di /etc/sysconfig/iptables dan menambahkan “rules” untuk membuka port yang diinginkan. Dan berikut tutorial cara membuka port 80 (HTTP Web Server Port) iptables pada CentOS 6
Open port 80 pada iptables
command line untuk membuka port 80 (http) dan 443 (https) sebagai berikut:
1 2 3 |
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
menyimpan iptables yang telah diedit
1 |
service iptables save |
restart iptables
1 |
service iptables restart |
Jika port 80 (http webserver) belum bisa diakses juga, cek port 80 pada iptables
1 |
iptables -L |
atau bisa juga cek iptables dengan:
1 |
cat /etc/sysconfig/iptables |
pastikan port 80 berada diatas ‘reject-with icmp-host-prohibited‘ seperti dibawah ini
1 2 3 4 5 6 |
... -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited ... |
setelah diedit dan disimpan pastikan iptables direstart kembali
1 |
service iptables restart |
Port 80 (http) seharusnya sudah bisa diakses