23 มิถุนายน 2552

Squid Custom ACLs

Squid Custom ACLs Users often want to implement more complex access rules for the web proxy servers than the EFW GUI permits. The solution to this is to write custom ACLs for Squid (the proxy engine in EFW). Patricio Bruna has figured out how to do this. Reading the code in advproxy.cgi Patricio realized that Endian obeys two files: /var/efw/proxy/custom-acl.conf and /var/efw/proxy/custom-acl-allow.conf (this is not mentioned in the EFW documentation). The first file defines the ACLs and the second file declares the rules (i.e., the “http_access” lines). Patricio then created the appropriate web pages so that you can access these files from the EFW GUI. More specifically, he created an additional sub-menu called “Advanced ACL” in the HTTP page of Endian’s Proxy tab. Selecting this sub-menu provides a web page that allows you to specify ACLs and rules (“http_access”) that Squid will use. What I’ve done is package Patricio’s contribution into an RPM to make it trivial to install: endian_2.1.2_squid_custom_ACL-1.0-1.noarch.rpm endian_2.1.2_squid_custom_ACL-1.0-1.src.rpm ------------------------------------------------------------------------------------------------- Squid Custom ACLs - How to... Solution posted « on: January 01, 2009, 04:51:21 am » I wanted to use the extra squid ACL function provided in the extras but ran into a problem with the install script. The "Advanced ACL" link never shows up on the gui. Here's how to fix it. 1. Put this RPM file on your endian box: http://alumnus.caltech.edu/~igormt/endian/files/endian_2.1.2_squid_custom_ACL-1.0-1.noarch.rpm2. Log into your endian box via ssh.At the command line type: rpm -ivh endian_2.1.2_squid_ustom_ACL-1.0-1.noarch.rpm3. Edit the following with vi.vi /var/efw/er.pl4. Search in the file for $subhttp->{'07.pol5. Add the following below the chunk of code: $subhttp->{'08.advancedacl'} = { 'caption' => _('Advanced ACL'), 'uri' => '/cgi-bin/proxyacl.cgi', 'title' => _('HTTP: Advanced ACL'), 'enabled' => 1, };That's it. This add on is very valuable. I use it to easily filter doubleclick, remove *banners* *ads* etc.

19 มิถุนายน 2552

22 เมษายน 2552

ท้ายสุดกับ Endian Firewall 2.2 RC2 Load Balance

ส่งท้ายแล้วนะครับ กับ Endian Firewall 2.2 RC2 ก็สรุปว่าใช้งานได้จริง โดยที่เราต้องเพิ่ม routing เข้าไปเอง เพราะความสามารถเดิมของ Endian แค่ Backup Link ซึ่งกันและกัน และจะใช้งานอยู่เพียงลิงค์เดียว จะใช้งานอีกลิงค์หนึ่งก็ต่อเมื่ออีกลิงค์หนึ่งดาวน์ลง

สรุปปัญหาจากการเพิ่ม Routing เข้าไปเองนั้น

  1. เมื่อเราเข้าไปเปลี่ยนแปลงคอนฟิก Endian ผ่านหน้าเวบ
  2. เมื่อถึงเวลาที่ Crontab บางอย่างทำงาน
  3. เมื่ออัพลิงค์เส้นในเส้นหนึ่งดาวน์ลง

ก็จะทำให้เปลี่ยน routing กลับมาเป็นแบบเดิม นั่นก็คือกลับมาวิ่งเส้นเดียวไม่ Load Balance

วิธีแก้ปัญหา

วิธีแรกรัน Script เองเมื่อเห็นว่า routing ไม่ load balance อันนี้ไม่ดีแน่ใครจะมานั่งเฝ้าอยู่ใช่มั๊ยครับ

วิธีที่ 2 เอาคำสั่งที่เป็น routing load balance ให้ทำงานด้วย crontab ตามเวลาที่เรากำหนด โดยไปแก้ไฟล์

/etc/crontab

โดยเพิ่ม

*/15 * * * * /var/efw/inithooks/start.local ให้รัน script load balance ทุก 15 นาที หรือ

*/30 * * * * /var/efw/inithooks/start.local ให้รัน script load balanceทุก 30 นาที หรือ

00 * * * * /var/efw/inithooks/start.local ให้รัน script load balance ทุก ชั่วโมง

เลือกเอาเองนะครับแล้วแต่ความเหมาะสม

แล้วรีบูทเครื่อง เพราะผมหาวิธีการ restart crontab ของ Endian ไม่เจอวิธีการนี้สามารถแก้ปัญหา การกลับไปใช้ routing เดิม ที่ไม่ load balance ได้ แต่ยังกังวลอยู่ว่าเมื่อ uplink เส้นหนึ่งเส้นใดดาวน์ลง มันจะมีปัญหาหรือเปล่า (ยังไม่ได้ลอง)

ตัวอย่าง routing ที่ยังไม่ load balance

root@efw:~ # ip route show 192.168.3.0/24 dev br2 proto kernel scope link src 192.168.3.254 192.168.2.0/24 dev br0 proto kernel scope link src 192.168.2.254 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.254 192.168.0.0/24 dev eth3 proto kernel scope link src 192.168.0.254 default via 192.168.1.1 dev eth1

ตัวอย่าง routing ที load balance แล้ว

root@efw:~ # ip route show 192.168.3.0/24 dev br2 proto kernel scope link src 192.168.3.254 192.168.2.0/24 dev br0 proto kernel scope link src 192.168.2.254 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.254 192.168.0.0/24 dev eth3 proto kernel scope link src 192.168.0.254 default equalize nexthop via 192.168.1.1 dev eth1 weight 1 nexthop via 192.168.0.1 dev eth3 weight 1

จากการทดลองนี้ สรุปได้ว่า ประหยัดเงินค่าอปกรณ์ load balance ได้ สำหรับองค์กรที่ไม่ใหญ่โต ผมเอง ไม่เคยใช้อุปกรณ์ load balance เลยไม่รู้คุณสมบัติพิเศษอื่นๆ ของมัน ที่คิดว่าน่าจะมีอะไรดีกว่าสิงที่ผมทำ แต่สุดท้าย อะไรประหยัดได้ก็ประหยัดเถอะครับ ช่วยชาติหน่อยครับ

ที่มา : http://linux.sothorn.org

20 เมษายน 2552

วิธีป้องกัน SSH Brute Force บน Endian Firewall

case "$1" in start) iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 --hitcount 2 -j DROP ## add your 'start' rules here ;; stop) ## add your 'stop' rules here ;; reload) ## add your 'reload' rules here ;; *) echo "Usage: $0 {start|reload|stop}" esac ********************* reboot endian firewall ใหม่ mrt2514 บ.ไอทีทริปเปิลพลัส จก.