Personal.X-Istence.com

Bert JW Regeer (畢傑龍)

Printer Setup

So, I set up a printer I had gotten from my dad today, I was expecting a fight, I had prepared for a fight...

I had received this printer after Thanksgiving since my dad wanted it no more. He gave me a D-Link DP-301U and a HP LaserJet 3200, a USB printer, and a USB network print server. Now, as almost any sane person knows printers are some of the most fickle beasts on this planet, and taming them is a task that no mere man is prepared for.

How many hours did you waste trying to stop a printer from printing some document, only to have to go to the emergency room because you needed stitches for the gash on your forehead?

I am fairly sure that with the amount of time and productivity lost to dealing with printers we could have solved world hunger, or at least cured cancer.

So after putting off this printer installation for many a month, for fear that I would end up losing all my hair as I pulled my hairs out one by one, I needed to print something, I had to finally cave.

I plugged in the printer, and I heard it whirl to life, the sounds instantly causing PTSD flashbacks to the many printers I have had the displeasure of turning on. I plugged the printer into the print server, plugged the print server in, and found myself silently praying, not merely praying but also slowly and surely rocking myself back and forth as if trying to calm myself.

After opening System Preferences, and adding the printer, selecting that it is a LaserJet, it said it had successfully added the printer. It has always seemed so deceptively simple, a couple of clicks and bam it should work. Surprisingly no drivers needed to be downloaded, no hundreds of megs worth of extra crappy software installed, could it be this simple?

I opened the file I wanted to print and started preparing for the worst. I had my hand on the paper tray, knowing that if it goes wrong this printer will go through 500 pages attempting to print pages of garbage, I hit print and immediately moved my hand to the power button, as an even better last resort. I tried to push the memory of older printers and how they had wronged me out of my mind as I got another flashback as the printer started spooling up, readying itself to print.

What happens next is somewhat of a miracle, the printer spat out my document, a perfect reproduction on paper. It didn't attempt print hundreds of pages of random characters and garbage, it didn't eat the pages and jam, it didn't start beeping at me because of the wrong printer drivers, my fears were unfounded.

Today is a great day, it is the day that I can start rebuilding my faith in printers, no longer afraid, no longer needing to worry about stitches, or that it really hurts to rip hair from my head. Today the printer gods smiled on me, and I smiled back.

An engineers technical notebook (a.k.a new blog)

If you are still reading this blog (all 5 of you out there according to Google Webmaster1), then you may have noticed that most of the content has been technical in nature, at least, that is what most of it has been lately. The idea is to save notes about setups I have done so that I can refer back to them at a later time, for a long time I've been wanting to do that on a domain called usingnamespace.com, but I just never really like the name for just a blog, I have other ideas for it.

Recently I was going through domain registration again and I was looking at a list of domains that I wanted, but couldn't get because at the time I looked they were already taken. I got lucky, I finally got funcptr.net/com and immediately purchased the two.

So without further ado, I introduce my new technical notebook named funcptr which is where I will be writing longer length, well thought out (hopefully) articles. The whole idea is for me to start writing down the solutions to technical problems I have encountered in both software engineering as well as system administration and various other technical tasks. It won't be strictly limited to software but will also include hardware projects, and electronics.

I hope you go over and take a look. I am slowly but surely migrating technical content from this blog to funcptr such as my NAT with pf on an interface with multiple IP addresses article that describes a problem I ran into with PF automatically enabling round-robin causing issues because the secondary IP address was not on the same network as the default gateway and thus NAT didn't function as you'd expect. I am setting up 301 redirects so if you have linked to a post here before, don't worry, it will transparently send you to the correct location!

Let me know if you have any suggestions, you can find my contact information on my portfolio site: contact Bert.


  1. I think Google Webmaster shows me the amount of people that have my RSS feed added to Google Reader... not entirely sure how else they are getting that statistic. 

Bug in Boost 1.4.7 when compiling with clang and c++0x support

This bug:

http://comments.gmane.org/gmane.comp.compilers.clang.devel/15926

still exists in 1.4.7.

Here is a small example:

#include <boost/thread/thread.hpp>

int main()
{
    return 0;
}

And compile it:

clang++ test.cc
clang++ -std=c++0x test.cc

In file included from test.cc:1:
In file included from /usr/local/include/boost/thread/thread.hpp:17:
/usr/local/include/boost/thread/pthread/thread_data.hpp:36:17: error: call to deleted constructor of 
'boost::shared_ptr<boost::detail::tss_cleanup_function>'
                func(func_),value(value_)
                ^    ~~~~~
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:164:25: 
               note: function has been explicitly marked deleted here
template<class T> class shared_ptr
                        ^
In file included from test.cc:1:
In file included from /usr/local/include/boost/thread/thread.hpp:22:
/usr/local/include/boost/thread/detail/thread.hpp:395:13: error: 
            call to deleted constructor of 'detail::thread_data_ptr' (aka 'shared_ptr<boost::detail::thread_data_base>')
            thread_data(thread_data_)
            ^           ~~~~~~~~~~~~
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:464:36: 
            note: function has been explicitly marked deleted here
    template<class Y> friend class shared_ptr;
                                   ^
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:301:9: error: functional-style cast from 
'const boost::shared_ptr<boost::detail::thread_data_base>' to 'this_type' (aka 'shared_ptr<boost::detail::thread_data_base>') 
uses deleted function
        this_type(r).swap(*this);
        ^~~~~~~~~~~
/usr/local/include/boost/thread/detail/thread.hpp:181:24: note: in instantiation of member function 
'boost::shared_ptr<boost::detail::thread_data_base>::operator=' requested here
            thread_info=other.thread_info;
                       ^
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:464:36: note: candidate constructor (the implicit copy constructor) has 
            been explicitly deleted
    template<class Y> friend class shared_ptr;
                                   ^
/usr/local/include/boost/smart_ptr/shared_ptr.hpp:227:5: note: candidate constructor [with Y = boost::detail::thread_data_base]
    shared_ptr( shared_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
    ^
3 errors generated.

Steve Jobs - 1955 - 2011

Yesterday the world lost a great visionary and leader. Whether you hated the guy or are an admirer you can't deny the fact that Steve Jobs had a great amount of influence in shaping the world of technology as it exists today.

He was always a step ahead of everyone else, knew what people wanted before they wanted it and was able to give it to them in beautiful product that people fell in love with; and still do fall in love with.

You may disagree with his business practices, you may dislike him, but he lived the American dream. He started from nothing in a garage and ended up as the CEO of one of the biggest and richest corporations of our time. We may not be able to follow in his footsteps, we are at least able to gain wisdom and knowledge from his experiences and missteps so that we too may one day be as great of a man as he was.

He did what he loved, he ran Apple until his last breath. I hope that one day I may be so lucky as to say that I too did what I loved until the day I died. May we all be so lucky as to die doing what we love surrounded by loved ones and friends.

At the end of Stanfords Commencement address in 2005, Steve Jobs quoted a magazine he used to read called the "Whole Earth Catalog", and they said on the back of their last issue "Stay Hungry. Stay Foolish".

It is one of the quotes that has stuck with me from that address, it is something that I truly believe in. It is something I attempt to follow every day. Every person interprets it differently, and that is the beauty of it. I find it apt then to end this article by thanking Steve Jobs for bringing my attention to these four words and how they have changed me.

Thanks for everything Steve. You made a huge dent in the universe, I can only hope to scratch the surface compared to what you accomplished. May you rest in peace.

Stay Hungry. Stay Foolish.

Setting up jails with multiple IPs and providing it with internet access

I have multiple VMs up and running and generally I have an internal to the VMs only network set up, in the current project I am working on I have three completely different networks set up.

  1. DHCP assigned network that routes to the outside network on the host (192.168.0.1/24)
  2. An internal to the VM's network interface (10.99.12.1/24)
  3. A network that is tied to the hosts wireless network (setup to be an AP) (10.99.11.1/24)

So within my FreeBSD VM I have the following: em0, em1, em2 as "network cards". In my FreeBSD VM, I am creating two jails that are going to contain different pieces of server software. The jails need ip's in the following ranges, 10.99.12.1/24 (to connect to another VM), 10.99.11.1/24 (Wifi network) and then it needs to have an IP address that is considered "local" and we can NAT on, so in addition to the above networks we also needed to add another network. The easiest way to create new interface with IP address' is using a bridge. They can be assigned IP addresses, which is all we need.

At this point inside of a jail it kinda looks like this:

em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
    ether 52:54:00:6b:6a:49
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
    ether 52:54:00:2f:a5:55
    inet 10.99.12.4 netmask 0xffffffff broadcast 10.99.12.4
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
em2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
    ether 52:54:00:bb:b6:43
    inet 10.99.11.14 netmask 0xffffffff broadcast 10.99.11.14
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=3<RXCSUM,TXCSUM>
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether da:de:63:c9:55:6c
    inet 10.0.1.4 netmask 0xffffffff broadcast 10.0.1.4
    id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
    maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
    root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0

em0 doesn't have an address since that is our DHCP address, em1, em2 and bridge0 all have IP addresses, in the jail configuration the bridge0 IP address is listed first, and thus when something binds or sends it sends from that IP address. The thing is that at this point the jail does not have internet access.

Jail's inherit the routing table from their host environment (yes, you can compile in more routing tables ... but I don't want to modify stock), any traffic that goes to the outside is going to go out over the default route, thing is you'd expect that traffic to show up on bridge0 where the IP address exists, instead using tcpdump you see it show up on em0, which is where the default route is. I would have expected having to do NAT on the bridge, not just the external interface.

Here is the pf configuration.

ext_if="em0"
jail_if="bridge0"

set optimization aggressive
set block-policy drop
set skip on lo

nat on $ext_if from $jail_if:network:0 to any -> ($ext_if)

pass quick all

And we've got internet within our jail. I am looking forward to setting this all up when the new VIMAGE stuff lands in 9.0-RELEASE so that I can have virtual network cards that are not tied to a physical network card!