This is G o o g l e's cache of http://www.debianclub.com/node/53 as retrieved on 16 Feb 2007 19:46:31 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?hl=en&q=cache%3Ahttp%3A%2F%2Fwww.debianclub.com%2Fnode%2F53&btnG=Search


Google is neither affiliated with the authors of this page nor responsible for its content.

User login

Links

debianclub.com
debian.org
ubuntuclub.com
blognone.com

Syndicate

Syndicate content

ipmasq กับการทำ transparent proxy

ตามที่ติดค้างไว้ใน ตอนที่แล้ว เกี่ยวกับการทำ internet gateway ด้วย ipmasq ว่าจะพูดถึงการทำ transparent proxy ก็จะพูดต่อ ซึ่งก็ไม่ยากอย่างที่คิด

หลักการคือ ให้ส่งต่อแพ็กเก็ตจากเครื่องภายในที่ติดต่อไปยังพอร์ต 80 ให้ไปที่พอร์ตของ HTTP proxy (เช่น 3128 หรือพอร์ตอื่นตามแต่กำหนดขณะติดตั้งพร็อกซี) เพื่อที่การติดต่อเว็บจากเครื่องในเครือข่ายภายใน จะได้ผ่านพร็อกซีเสมอ โดยไม่ต้องตั้งค่าพร็อกซีอีก

เริ่มจากติดตั้ง squid proxy ก่อน

# aptitude install squid

แล้วตั้งค่า squid ตามปกติ อาจจะทดสอบการทำงานของพร็อกซี โดยเปิดเว็บเบราว์เซอร์ในเครื่องลูก แล้วตั้งค่าพร็อกซีก่อนเปิดเว็บต่างๆ ดูก่อน แล้วดู access log ของ squid ที่ /var/log/squid/access.log ว่ามี request เข้ามา

จากนั้น ตั้งค่า squid ที่ /etc/squid/squid.conf ให้เป็น transparent proxy (สำหรับ squid 2.6 ขึ้นไป):

http_port 3128 transparent

แล้วก็คัดลอกตัวอย่าง transparent proxy ของ ipmasq มา:

# cp /usr/share/doc/ipmasq/examples/basics/I89tproxy.rul /etc/ipmasq/rules/

แล้วแก้หมายเลขพอร์ตของพร็อกซีใน /etc/ipmasq/rules/I89tproxy.rul ซึ่งค่าปกติเป็น 8081 ให้เป็นหมายเลขพอร์ตที่เรากำหนดไว้ใน /etc/squid/squid.conf เช่น ในที่นี้เราใช้พอร์ต 3128 ก็ค้นหาและแทนที่ 8081 ด้วย 3128 ทั้งแฟ้ม

จากนั้น เมื่อสั่ง ipmasq เพื่อคำนวณ iptables ใหม่อีกครั้ง ก็จะได้ transparent proxy เรียบร้อย

เพื่อความ

เพื่อความชัวร์
http_port ip-proxy:3128 transparent

ที่มา
http://www.squid-cache.org/mail-archive/squid-users/200607/0023.html

ip:port

ขอบคุณ ครับ รูปแบบ ip:port เป็นการกำหนดให้ squid listen ที่ network interface ที่กำหนดเท่านั้น ในที่นี้ เราก็ระบุ IP address ภายในของพร็อกซี ก็จะไม่รับ connection จากภายนอกเลย (ต่างกับการกำหนดแต่หมายเลขพอร์ตอย่างเดียว ซึ่งแบบนั้นจะรับ connection ภายนอก แต่กรองทิ้งด้วย ACL กินโหลด CPU นิดหน่อย)