
Ở Centos 7, firewall mặc định đã được chuyển sang firewalld thay cho Iptables . Nếu bạn vẫn muốn sử dụng Iptables trên Centos 7 thì bạn có thể làm theo hướng dẫn sau để disable Firewalld và sử dụng Iptables.
Dưới đây là so sánh điểm khác nhau giữa hai service này. Mình để nguyên tiếng Anh cho chính xác:
+ The iptables service stores configuration in /etc/sysconfig/iptables while firewalld stores it in various XML files in /usr/lib/firewalld/ and /etc/firewalld/. Note that the /etc/sysconfig/iptables file does not exist as firewalld is installed by default on Red Hat Enterprise Linux.
+ With the iptables service, every single change means flushing all the old rules and reading all the new rules from /etc/sysconfig/iptables while with firewalld there is no re-creating of all the rules; only the differences are applied. Consequently, firewalld can change the settings during runtime without existing connections being lost.
Cài đặt các gói Iptables
yum install -y iptables-services
Disable dịch vụ firewalld :
systemctl mask firewalld
Để iptables và ip6tables tự khởi động khi boot
systemctl enable iptables systemctl enable ip6tables
Stop dịch vụ firewalld
systemctl stop firewalld
Start iptables và ip6tables
systemctl start iptables systemctl start ip6tables
Từ bây giờ bạn có thể chạy lệnh system-config-firewall hoặc iptables mà không gặp lỗi gì cả.