Friday, August 12, 2016

Hướng dẫn open port iptables trên CentOS

Firewall
Nếu bạn muốn mở hoặc đóng port cho VPS thì phải chỉnh sửa file cấu hình của iptables. Mặc định thì file này có đường dẫn là /etc/sysconfig/iptables

Mở port VPS

Ví dụ để mở port xxx, bạn hãy thực hiện lệnh sau:
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport xxx -j ACCEPT
Sau đó lưu lại cấu hình và khởi động lại iptables
service iptables save
service iptables restart

Đóng port VPS

Để đóng port bất kỳ, bạn chỉnh sửa trực tiếp file/etc/sysconfig/iptables bằng lệnh
vi /etc/sysconfig/iptables
xóa những dòng có port cần đóng.
Sau đó lưu lại cấu hình và khởi động lại iptables
service iptables restart

Kiểm tra lại port đang mở

iptables -L -n
Share:

0 comments:

Post a Comment

Find us on Google Plus

Powered by Blogger.

QUẢN TRỊ VIÊN