<?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>socks &#8211; Luxing Huang</title>
	<atom:link href="https://luxing.im/tag/socks/feed/" rel="self" type="application/rss+xml" />
	<link>https://luxing.im</link>
	<description>Thoughs and things</description>
	<lastBuildDate>Wed, 16 Dec 2020 20:41:01 +0000</lastBuildDate>
	<language>en-CA</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
<site xmlns="com-wordpress:feed-additions:1">58771605</site>	<item>
		<title>SOCKS5 as a VPN under Linux</title>
		<link>https://luxing.im/socks5-as-a-vpn/</link>
					<comments>https://luxing.im/socks5-as-a-vpn/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Fri, 09 Dec 2016 21:39:26 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[badvpn]]></category>
		<category><![CDATA[socks]]></category>
		<category><![CDATA[vpn]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=709</guid>

					<description><![CDATA[Being able to proxy via SOCKS5 on browser sometimes wasn&#8217;t enough, one needs a system-wide proxy. The best and simplest solution is of course VPN, but VPN is not as fast compare to SOCKS proxy like ShadowSocks under Linux. What can we do? In this article, I am going to briefly introduce System-wide SOCKS5 proxy &#8230; <p class="link-more"><a href="https://luxing.im/socks5-as-a-vpn/" class="more-link">Continue reading<span class="screen-reader-text"> "SOCKS5 as a VPN under Linux"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Being able to proxy via SOCKS5 on browser sometimes wasn&#8217;t enough, one needs a system-wide proxy. The best and simplest solution is of course VPN, but VPN is not as fast compare to SOCKS proxy like ShadowSocks under Linux. What can we do? In this article, I am going to briefly introduce System-wide SOCKS5 proxy for all applications.<br />
<span id="more-709"></span></p>
<p>This tutorial uses ShadowSocks as the primary proxy service. You should obtain ShadowSocks service before doing the following steps. You should also know this is a generic setup for SOCKS5 proxy, including SSH and others SOCKS services.</p>
<p>Warning: You cannot proxy DNS request with ShadowSocks, you can with SSH (requires remote server configuration). Hence if your ISP pollutes your DNS result, you must find another way to relay your DNS queries.</p>
<p>I am going to use BadVPN software for this purpose. Most of the steps are learned from their <a href="https://github.com/ambrop72/badvpn/wiki/Tun2socks" target="_blank" rel="noopener">WiKi</a>, I merely take notes here.</p>
<h3>Obtain BadVPN.</h3>
<p>Please note that the curly braced names are placeholders for you to change to a real value (without the braces themselves). This is a jinja2 template style.</p>
<p>ArchLinux user is able to install from AUR directly. For others, follow the following steps (Fedora as the example):</p>
<ol>
<li>Clone the repository:</li>
</ol>
<pre>git clone https://github.com/ambrop72/badvpn.git</pre>
<ol>
<li>Install necessary libraries</li>
</ol>
<pre>sudo dnf install nspr-devel nss-devel cmake -y</pre>
<ol>
<li>Create the build folder and start the compilation</li>
</ol>
<pre>mkdir build
cd build
cmake <path/to/badvpn>
make -j`nproc`
</pre>
<p>Now you see all the compiled software under build.</p>
<h3>Setup BadVPN</h3>
<p>All IP commands are used by root.<br />
1. Create TUN device</p>
<pre>
ip tuntap add dev tun0 mode tun user <your_user>
</pre>
<p>Replace <code>&lt;your_user&gt;</code> with your normal privileged user. This rule follows in the next steps.</p>
<ol>
<li>Assign IP to TUN interface</li>
</ol>
<pre>ip addr add 10.0.0.1/24 dev tun0</pre>
<ol>
<li>Enable TUN device</li>
</ol>
<pre>ip link set tun0 up</pre>
<ol>
<li>Add your ShadowSocks remote server and DNS servers to the routing table using the default gateway.</li>
</ol>
<pre>
ip route add 8.8.8.8/32 via {{ default_gw }} metric 5
ip route add 8.8.4.4/32 via {{ default_gw }} metric 5 # or you can combine those 2 with 8.8.0.0/16
ip route add {{ shadowsocks_remote_server }} via {{ default_gw }} metric 5
</pre>
<ol>
<li>Start BadVPN<br />
Use normal user</li>
</ol>
<pre>
cd tun2socks
./badvpn-tun2socks --tundev tun0 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 127.0.0.1:{{ shadowsocks_local_port }}
</pre>
<ol>
<li>Add default route to tun0<br />
Use root user</li>
</ol>
<pre>
ip route add default via 10.0.0.2 metric 6
</pre>
<p>Now everything you visit including Steam and Email agents etc will be routed via Socks.</p>
<h3>Cleaning up</h3>
<p>Remove the added default routes to 10.0.0.2, you optionally may remove other added routes but not necessary.</p>
<pre>ip route delete 0.0.0.0 dev tun0</pre>
<p>Stop BadVPN and ShadowSocks as usual (Ctrl-C).</p>
<h3>Notes</h3>
<p>If you want to proxy specifically with ShadowSocks, you may install the <code>shadowsocks-libev</code> package and use that instead of this way.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/socks5-as-a-vpn/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">709</post-id>	</item>
	</channel>
</rss>
