My blog

APF Firewall หรือ Advanced Policy Firewall เป็นระบบ firewall ที่ค่อนข้างจะนิยมใช้งานกัน ในหมู่ admin ที่ใช้ cPanel เนื่องจากการติดตั้งที่ง่าย และแข็งแรง
ลองมาดูวิธีติดตั้งกันครับ



Login เป็น root ที่ Server ของคุณครับ
1. cd /root/downloads
หรือโฟลเดอร์อื่นที่คุณใช้เก็บไฟล์ครับ
2. wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz
3. tar -xvzf apf-current.tar.gz
4. cd apf-0.9.3_3/
หรืออาจจะเป็นชื่ออื่น กรณีที่ APF ออก Version ใหม่
5. Run the install file: ./install.sh
แล้วจะเห็นข้อความบอกถึงการติดตั้ง ว่ามีปัญหามั้ย หรือเรียบร้อยแล้ว ประมาณนี้ครับ


.: APF installed
Install path:    /etc/apf
Config path:     /etc/apf/conf.apf
Executable path: /usr/local/sbin/apf


6.
หลังจากติดตั้งแล้ว ก็ต้องมีการ Config กันนิดหน่อยครับ สั่ง: pico /etc/apf/conf.apf
นี่เป็นการติดตั้งและปรับแต่งพื้นฐาน หากคุณต้องการใช้งานส่วนอื่นๆ ของ APF เพิ่มเติมโปรดอ่านไฟล์ README ประกอบครับ


FIND: USE_DS=”0″
CHANGE TO: USE_DS=”1″


7. Configuring Firewall Ports:
สำหรับ Cpanel Servers ผมใช้ประมาณนี้ครับ


Common ingress (inbound) ports
# Common ingress (inbound) TCP ports -3000_3500 = passive port range for Pure FTPD
IG_TCP_CPORTS=”21,22,25,53,80,110,143,443,2082,2083, 2086,2087, 2095, 2096,30000_35000″
#


สำหรับ Ensim Pro ให้กำหนด Port ประมาณนี้ครับ


IG_TCP_CPORTS=”21,22,25,53,80,110,143,443,19638″
นอกนั้นครือๆ กัน


# Common ingress (inbound) UDP ports
IG_UDP_CPORTS=”53″
Common egress (outbound) ports
# Common egress (outbound) TCP ports
EG_TCP_CPORTS=”21,25,80,443,43″
#
# Common egress (outbound) UDP ports
EG_UDP_CPORTS=”20,21,53″
Save the changes: Ctrl+X then Y


8. Starting the firewall
/usr/local/sbin/apf -s
Other commands:
usage /usr/local/sbin/apf [OPTION]
-s|–start …………. load firewall policies
-r|–restart ……….. flush & load firewall
-f|–flush|–stop …… flush firewall
-l|–list ………….. list chain rules
-st|–status ……….. firewall status
-a HOST|–allow HOST … add host (IP/FQDN) to allow_hosts.rules and immediately load new rule into firewall
-d HOST|–deny HOST …. add host (IP/FQDN) to deny_hosts.rules and immediately load new rule into firewall


9.
หลังจากปรับแต่งเรียบร้อยแล้ว ให้เปลี่ยนค่า DEV option กลับเป็น “0″ ทั้งนี้ คุณควรทำหลังการทดสอบ ว่าไม่มีอะไรผิดพลาด โดยเฉพาะ Port 22 ซึ่งคุณจำเป็นต้องใช้งาน หลังจากนั้นสั่ง
pico /etc/apf/conf.apf
FIND: DEVM=”1″
CHANGE TO: DEVM=”0″
Save your changes! Ctrl+X then press Y
Restart the firewall: /usr/local/sbin/apf -r


10.
สั่งให้ APF autostart ทุกครั้งที่เปิดเครื่อง ดังนี้:
chkconfig –level 2345 apf on
ถ้าต้องการให้เอา APF ออกจาก autostart สั่งดังนี้:
chkconfig –del apf


ตอนนี้ Server คุณก็มี APF ทำหน้าที่ Firewall ให้แล้วครับ




My Links