<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>How to Config &#187; TransparentProxy</title>
	<atom:link href="http://www.howtoconfig.com/tag/transparentproxy/feed" rel="self" type="application/rss+xml" />
	<link>http://www.howtoconfig.com</link>
	<description>how to config - how to configure</description>
	<lastBuildDate>Fri, 29 Apr 2011 09:52:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Check Transparent Proxy</title>
		<link>http://www.howtoconfig.com/os/debian/check-transparent-proxy.html</link>
		<comments>http://www.howtoconfig.com/os/debian/check-transparent-proxy.html#comments</comments>
		<pubDate>Mon, 01 Sep 2008 05:18:35 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Shell script]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Transparent]]></category>
		<category><![CDATA[TransparentProxy]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=43</guid>
		<description><![CDATA[คือมี case ที่ต้องทำ transparent proxy ครับ  แต่ว่าเวลา proxy มีปัญหา ผมอยากให้ทำการ ปลด proxy ออกเอง  ผมเลยเขียน shell script  มาเพื่อทำการ ตรวจสอบว่า proxy ทำได้หรือเปล่า ถ้าทำงานได้ ก็จะเพิ่ม iptables  ทำการสร้าง DNAT  ไปยังเครื่อง Proxy ครับ หลักกาารง่ายๆคือ  จะใช้ curl แล้ว set proxy เป็นเครื่อง Proxy ที่เรากำหนด   เสร็จแล้วก็ให้ curl ทำการ connect ไปยัง web ปลายทาง   ถ้า connect ได้ content ที่ return มาจาก curl จะมากกว่า 0    และทำให้ [...]]]></description>
			<content:encoded><![CDATA[<p>คือมี case ที่ต้องทำ transparent proxy ครับ  แต่ว่าเวลา proxy มีปัญหา ผมอยากให้ทำการ ปลด proxy ออกเอง  ผมเลยเขียน shell script  มาเพื่อทำการ ตรวจสอบว่า proxy ทำได้หรือเปล่า ถ้าทำงานได้ ก็จะเพิ่ม iptables  ทำการสร้าง DNAT  ไปยังเครื่อง Proxy ครับ</p>
<p><span id="more-43"></span></p>
<p>หลักกาารง่ายๆคือ  จะใช้ curl แล้ว set proxy เป็นเครื่อง Proxy ที่เรากำหนด   เสร็จแล้วก็ให้ curl ทำการ connect ไปยัง web ปลายทาง   ถ้า connect ได้ content ที่ return มาจาก curl จะมากกว่า 0    และทำให้ script เพิ่ม iptables  เข้าไปครับผม</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#	Check Proxy	v.10</span>
<span style="color: #666666; font-style: italic;">#	By Auttasak Wongkitta</span>
<span style="color: #666666; font-style: italic;">#	http://howtoconfig.com</span>
&nbsp;
<span style="color: #007800;">PROXY</span>=<span style="color: #ff0000;">&quot;192.168.100.254:3128&quot;</span>
<span style="color: #007800;">URL</span>=<span style="color: #ff0000;">&quot;http://manager.co.th&quot;</span>
<span style="color: #007800;">LINUX_IP</span>=<span style="color: #ff0000;">&quot;192.168.100.254&quot;</span>
<span style="color: #007800;">LINUX_IF</span>=<span style="color: #ff0000;">&quot;eth2.1&quot;</span>
&nbsp;
<span style="color: #007800;">RESULT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-x</span> <span style="color: #007800;">$PROXY</span>  <span style="color: #007800;">$URL</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">USEPROXY</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-L</span> PREROUTING <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$PROXY</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$RESULT</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$USEPROXY</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-D</span> PREROUTING <span style="color: #660033;">-i</span> <span style="color: #007800;">$LINUX_IF</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$LINUX_IP</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> http <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$PROXY</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$USEPROXY</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-i</span> <span style="color: #007800;">$LINUX_IF</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$LINUX_IP</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> http <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$PROXY</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fdebian%2Fcheck-transparent-proxy.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/debian/check-transparent-proxy.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

