<?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>logIt &#187; OS X</title>
	<atom:link href="https://lakm.us/logit/tag/os-x/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>That Handy Tap Interface on Mac OSX</title>
		<link>https://lakm.us/logit/2013/01/handy-tap-interface-mac-osx/</link>
		<comments>https://lakm.us/logit/2013/01/handy-tap-interface-mac-osx/#comments</comments>
		<pubDate>Fri, 04 Jan 2013 09:04:46 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Moving to Mac]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[virtualization]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=426</guid>
		<description><![CDATA[Ubuntu has been my desktop for some years. I&#8217;ve become so attached in a way that I no longer know how to work without. Then of course, the pain of moving to Mac is one foreseeable future. Unlike my usual repository where everything is on the table and for free, this one is a little [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.ubuntu.com/" title="Ubuntu" target="_blank">Ubuntu</a> has been my desktop for some years. I&#8217;ve become so attached in a way that I no longer know how to work without. Then of course, the pain of moving to <a href="http://www.apple.com/macbook-pro/" title="MacBook Pro" target="_blank">Mac</a> is one foreseeable future. Unlike my usual repository where everything is on the table and for free, this one is a little tougher to handle. Well, if I were to cut to the chase, <a href="./2009/02/startup-script-for-tap-interfaces/" title="Startup script for TAP interfaces" target="_blank">tap interface</a> for instance, was nowhere near to be found. My <a href="https://www.virtualbox.org/" title="VirtualBox" target="_blank">VirtualBox</a> depends a lot on these virtual networks as I&#8217;m used to try things out.</p>
<blockquote><p>
<em>..you’ll always have love-hate relationship with the tools you work with.. blindly turning yourself into devoted-fanatic is another thing..</em></p></blockquote>
<p>
<p>Enough bragging (let&#8217;s spare that). First we need to have <code>/dev/tap0</code>, <code>/dev/tap1</code>, etc., available using <a href="http://tuntaposx.sourceforge.net/" title="TunTap - SourceForge" target="_blank">TunTap</a> kernel extension.</p>
<p>I modify the small script from <a href="http://snakeoilresearch.com/blog_discussing_snake_oil_o/using_taptun_interfaces_in_.html" title="Using 'tap/tun' interfaces in Mac OS X with VirtualBox" target="_blank">this post</a> to have it available on background instead of keeping a shell open all the time:</p>
<p>I saved it as <code>/usr/local/bin/setup-tap1.py</code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:
	<span style="color: #ff7700;font-weight:bold;">try</span>:
		file_path = <span style="color: #483d8b;">'/dev/tap1'</span>
		dev_file = <span style="color: #dc143c;">os</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>file_path, <span style="color: #dc143c;">os</span>.<span style="color: black;">O_RDWR</span><span style="color: black;">&#41;</span>
		interface = <span style="color: #483d8b;">'tap1'</span>
		<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:
			<span style="color: #ff7700;font-weight:bold;">pass</span>
	<span style="color: #ff7700;font-weight:bold;">except</span>:
		<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;tap interface is closing&quot;</span>
		exit<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">break</span></pre></td></tr></table></div>

<p>Let the shell takes care of putting it to background (daemon):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>setup-tap1.py <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></div>

<p>and there you have one working tap interface:</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="virtualbox-mac-osx-tap-interface.png" src="../../../../images/virtualbox-mac-osx-tap-interface.png" title="VirtualBox tap interface in Mac OSX Lion" width="438" height="249" /><p class="wp-caption-text">VirtualBox tap interface in Mac OSX Lion 10.7</p></div>
<p>[Moving-in would probably be easier if I started <code>life</code> with <code><a href="http://en.wikipedia.org/wiki/FreeBSD" title="FreeBSD" target="_blank">FreeBSD</a></code>. More posts to come]</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/01/handy-tap-interface-mac-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
