แค่เว็บๆหนึ่ง ! ที่อยากเก็บประสบการณ์
Home
 

TranparentProxy บน Freebsd6.2

วันศุกร์ที่ผ่านมา นั่งลง Server Dell PowerEdge 2950 Raid 5 RAM 2G     จะเอาไปให้ลูกค้า เพื่อทำเป็น Proxy  กับ Intra Mail และ Intra net   วันเสาร์นี้ เฮ้อ…  ไม่ได้ไปลอกะทง อีกแล้วเราปีนี้  เพราะไม่รู้ ว่าจะได้กลับกี่โมง
อย่าเสียเวลาเลยครับ…  เอาเป็นว่ามาดูกันเลยดีกว่า
โดยเรื่มต้นที่ ลงFreebsd เสร็จแล้วก็ set DNS ขึ้นมา ซึ่งผมขอข้ามการ set dns  น่ะครับ โดยจะเริ่มที่  SQUID กันเลย
web#cd /home/data
web#tar xvfz 
squid-2.5.STABLE11.tar.gz
web#cd squid-2.5.STABLE11
web#./configure –prefix=/usr/local/squid ; make ; make install
รอจนinstall เสร็จ  จากนั้นให้เข้าไปแก้ไขไฟล์
web#pico /usr/local/squid/etc/squid.conf
แก้ ดังนี้
http_port 8080
icp_port 3130
cache_dir ufs /usr/local/squid/var/cache 100 16 256
cache_access_log /usr/local/squid/var/log/access.log
cache_access_log /usr/local/squid/var/log/cache.log
cache_ store_log /usr/local/squid/var/log/store.log
acl Mynet src 192.168.1.0/255.255.255.0
http_access allow Mynet
#tranparent Proxy
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

เสร็จแล้วก็ให้ Save แล้วก็เข้าไป
web#
cd /usr/local/squid/var
web#
mkdir cache
web#
chmod 777 cache
web#cd logs
web#
touch access.log  cache.log  store.log
web#cd /usr/local/squid/sbin
web#
./squid -z

ต่อมา ก็ Compile NATโดย  เข้าไปที่
web# cd /usr/src/sys/i386/conf/
web#cp GENERIC XNAT
แก้ไขไฟล์
web#pico XNAT
เพิ่ม เข้าไปดังนี้

 

ident XNAT

 

 

options IPFIREWALL
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=120
options IPDIVERT
options SC_DISABLE_REBOOT   #ป้องงกัน Ctrl+Alt+Del
web#
config XNAT
web#
cd ../compile/XNAT
web# make depend && make && make install
รอจนทำเสร็จแล้ว Reboot

จากนั้นก็ไปเพิ่มรายการใน rc.conf
web#pico /etc/rc.conf
ifconfig_bce1=”inet 200.100.10.5 netmask 255.255.255.0″
ifconfig_bce0=”inet 192.168.1.1 netmask 255.255.255.0″
gateway_enable=”YES”
hostname=”web.hagarici.biz”
defaultrouter=”200.100.10.1″

firewall_enable=”YES”
firewall_type=”OPEN”
firewall_quite=”YES”

natd_enable=”YES”
natd_interface=”bce1″ ——-> (Card ที่ต่อเข้า IPSTART)
natd_flag=”-s -u -m”

จากนั้น ก็ SAVE แล้วเข้าไป แก้ไขไฟล์  rc.local
web#
pico /etc/rc.local
/usr/local/squid/sbin/RunCache &
ipfw add 4200 fwd 192.168.1.1,8080 tcp from 192.168.1.0/24 to any 80

จากนั้นให้ restart  แล้วลองให้เครื่องลูกเข้าใช้งานดู  
ทุกอย่างทำงานได้ ไม่น่าจะมีปัญหา  คืนนี้ นอนหลับสบายแล้วเรา

 

วันนี้พอแค่นี้ก่อนครับไว้จะมาเล่าต่อ..  ว่าจะเจออะไรที่หน้างานอีก  ไปล่ะครับ  อาบน้ำนอนดีกว่า

 

Off 

February 25, 2012 This post was written by Categories: เรื่องเล่ารายวัน No comments yet


Top