2. ตั้งค่า firewall CentOS 7

จาก Wiki_EAI
ไปยังการนำทาง ไปยังการค้นหา

1. ตรวจสอบสถานะ firewalld service บน mail server โดยต้องได้สถานะ active (running)

# systemctl status firewalld

ตัวอย่าง

Active: active (running) since Mon 2019-11-18 14:12:03 +07; 1h 13min ago

2. ตรวจสอบ firewall zone และ network interface ที่เปิดอยู่

# firewall-cmd --get-active-zones

ตัวอย่าง

public
interfaces: ens32

3. ตรวจสอบรายการ services ของ firewall ที่ zone public

# firewall-cmd --zone=public --list-services

ตัวอย่าง

 cockpit dhcpv6-client ssh 

4. เปิด firewall services ที่ zone public ของ mail server (สามารถเปิดเท่าต้องการได้)

# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --permanent --zone=public --add-service=https
# firewall-cmd --permanent --zone=public --add-service=mysql
# firewall-cmd --permanent --zone=public --add-service=smtp
# firewall-cmd --permanent --zone=public --add-service=smtps
# firewall-cmd --permanent --zone=public --add-service=imap
# firewall-cmd --permanent --zone=public --add-service=imaps
# firewall-cmd --reload

5. ตรวจสอบรายการ services ของ firewall ที่ zone public อีกครั้ง จะพบ services เปิดเพิ่มขึ้นมา

*ref: configure firewall services for mail server (https://spalinux.com/2015/06/centos-7-basic-configure-firewall-by-firewall-cmd)

# firewall-cmd --zone=public --list-services

ตัวอย่าง

 cockpit dhcpv6-client http https imap imaps mysql smtp smtps ssh  

6. ปิด selinux (เพื่อสะดวกต่อการ configure แต่ความปลอดภัยจะลดลง)

  • เปลี่ยน SELinux=enforcing เป็น SELinux=disabled
# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.
SELINUXTYPE=targeted
  • Restart ระบบ และทำการตรวจสอบ
# reboot
  • ตรวจสอบสถานะของ SELinux
# sestatus
disabled

7. ติดตั้ง wget เพื่อใช้ download service ที่จำเป็นต้องใช้งานเพิ่ม

# yum install wget