Configuring Static DNS with DHCP on Debian/Ubuntu

Note: This article is outdated as of Ubuntu 12.04. Please see this article if you're using Ubuntu 12.04 or later.

Dynamic Host Configuration Protocol (DHCP) is a commonly used method of obtaining IP and DNS information automatically from the network. In some cases, you may wish to statically define the DNS servers instead of using the ones provided by the DHCP server. For example if your ISP commonly experiences DNS outages, you might want to use the DNS servers provided by OpenDNS instead of the ones provided by your ISP.

When using a static IP configuration on Linux, you normally add the DNS servers to the /etc/resolv.conf. However, if you try to add a DNS server to /etc/resolv.conf under a DHCP configuration, you'll notice that your static entry disappears as soon as the DHCP client runs (usually on boot). To prevent this, you need to tell the DHCP client to prepend the static DNS server(s) to /etc/resolv.conf before adding the ones provided from the DHCP server (if any).

The configuration file you'll need to edit is the same on both Debian and Ubuntu, however depending on your setup the location of the file may vary. Here are the two common places I've found the file:

Debian: /etc/dhclient.conf
Ubuntu: /etc/dhcp3/dhclient.conf

Open the file in your favorite editor and add one of two lines at the top, separating multiple DNS servers with a comma and ending the entry with a semi-colon:

If you simply want to add static DNS servers to be used in addition to the ones provided by DHCP, use a prepend entry:

prepend domain-name-servers 208.67.222.222, 208.67.220.220;

If you want to override the DNS servers provided by DHCP entirely and force the system to use the ones you provide, use the supersede entry:

supersede domain-name-servers 208.67.222.222, 208.67.220.220;

Before these static DNS servers will to be appended to your /etc/resolv.conf file, you'll need to re-run the DHCP client. The easiest way to do this is by running /etc/init.d/networking restart (sudo required) or you can try running the dhclient command.

After re-running the DHCP client, check your /etc/resolv.conf file to confirm the static DNS servers have been added.

Vimperator Plugin Causing Accidental Post Publishing

After several drafts on my new tech blog mysteriously appeared publicly as published, I discovered that the new WordPress keyboard shortcut for Publish is the same as the Previous Tab shortcut in Vimperator (the Firefox plugin that allows me to browse the web using only the keyboard). Regardless of what mode I'm in (Insert mode or Normal mode), pressing CTRL+P publishes the post and switches to the previous tab.

Going Cold Turkey on Coffee

Coffee is the one thing that I have tried to quit several times over the past few years and failed (it's been my new years resolution several years in a row). Failing is not like me. If I want to quit something, I just do it. I've never been addicted to anything in my life... except coffee.

I started drinking coffee with cream and sugar when I was 16. When I got into fitness a few years later, I slowly decreased the amount of cream and sugar in the coffee until it was black. From that point on, cream and sugar in my coffee ruined it for me so I continued to drink it black.

The average cup of black coffee contains between 115-175mg of caffeine. More than 300mg of caffeine a day on regular basis has been shown to cause several negative side effects, including increased urination (and dehydration as a result), disruption of normal diet (drinking coffee when hungry makes you no longer feel hungry, even though your body needs food), headaches, irritation, and mood swings. I have experienced all of these, but I'm only now beginning to realize how much they're affecting my fitness and overall health.

I recognized a pattern in my coffee consumption. Over a three month time span, I would go from drinking 1 cup to 4 cups of coffee per day. Eventually I would feel so sick of the high caffeine intake (or its side effects) that I would drop back down to 1 cup a day, only to begin the process all over again. Here's a chart of what I'm talking about:

Cups of Coffee Per Day

For some reason I've felt extremely motivated and strong about the fitness goals I set for this year, so since I'm on a roll I decided to go cold turkey on coffee last Tuesday (February 17th). The first few days were rough. Tuesday the bad headaches started. Wednesday the headaches were slightly better, but the mood swings crept in (mood swings are rare for me, so it was easy for me to recognize them). Thursday it was a combination of mood swings and headaches but by Friday the side effects were starting to wear off.

I had considered leaving the weekends open for one or two coffees, but I remembered when I did that in the past it resulted in eventually making exceptions during the week. I almost gave in on Saturday, almost. Today is Sunday and I can already feel my desire for coffee is slowly but surely wearing off. I feel so much better overall. I'm able to wake up easier in the morning, I'm spending less, my diet and digestion are better, and I don't feel this constant need for something external to keep me going.

The Pursuit of Knowledge

I started writing this as a comment in reply to Adam Bossy's post The Paradox of Self-Education. The comment became so long that I decided to turn it into a post here on my blog.

I grew up wanting to "be everything", from astronomer, to musician, to entomologist, to geneticist, to Navy SEAL, to writer, to geologist, to computer scientist. Hell, even meteorology (the study of weather, i.e., what the weather man does) fascinated me! I was home schooled through high school and never spent a single day in public or private school. (I actually ended up teaching myself through high school because my parents were busy teaching my younger brother and sister.) This gave me great freedom to study anything that happened to interest me. Over the course of a year, I probably switched between being totally engrossed in a dozen different fields. But in my teens, I realized that "being everything" wasn't a career path and just knowing a little bit about many different fields wasn't going to pay the bills. So I picked the most developed of my skills and went into IT.

Now at 26 and no college degree, I'm working for a software start-up doing a whole variety of things (programming, sysadmin, tech support, editor, you name it) and I run my own small but successful web hosting company. My interest in many other fields has not changed or decreased in any way. The only thing that has changed is my ability to spend ANY amount of time exploring them.

While pondering many of the same points as Adam does in his post, I came to the conclusion that it's our bills and our standards of living that are holding us down. By living paycheck to paycheck we make it impossible to take six months or a year off from work to explore some new thing that has peaked our interest. Socially, we're expected to follow the same routine advancement in our current field from one position to another, making a bigger paycheck and being able to raise our standard of living that much higher (thereby putting us back to where we started and resulting in yet another desire for a raise and advancement).

I went from spending upwards of $2,500 a month down to $800 a month by making lifestyle adjustments. "Do I need cable TV?" No, I have the Internet. "Do I need this two-bedroom, 1,500 sqft apartment?" No, I'm a single guy and the rent is a huge part of my paycheck -- 400 sqft will do. "Do I need to drive into work?" No, I can take public transportation. "Do I need this $5 coffee every day?" No, a $.50 green tea will suffice and it will be healthier.

My goal now is to continue living frugally so I can set aside a big enough bucket of money to get me through one year without work. Then, when the time is right, I'll spend a year learning something of interest, possibly making small amounts of money on the side. When needed, I'll start working and hopefully keep repeating this process. If something I do makes me tons of money, great. If not... well it's not about the money.

The pursuit of knowledge is to me more important than all the money in the world. Sure, money would make that pursuit easier, but life isn't easy. This is where I feel society gets it wrong. We put money and status first and education and knowledge second, using the latter to obtain the former. Imagine a society where the pursuit of knowledge defined our standards of living. (Oh no, what would happen to all the ads?!)

If we're willing to sacrifice our high-strung lifestyle for the ability to spend time learning and increasing knowledge, then we can accomplish amazing things, both individually and as a society. A world pursuing money and status has all the reason to fight amongst themselves and start wars, but a world pursuing knowledge and advancement has all the reason to maintain peace.

Additions to My 2009 Resolutions

While my current set of resolutions for this year includes getting in the best shape of my life, I want to set a few particular goals:

  1. 500-yard swim in under 10 minutes (using sidestroke or breaststroke)
  2. 80 Push-Ups in 2 minutes
  3. 80 Sit-Ups in 2 minutes
  4. 25 Pull-Ups (no time limit)
  5. 1.5 Mile Run in under 10 minutes
  6. Become a certified scuba diver
  7. Complete the AFF program

Those are some seriously tough fitness goals, but they're definitely reachable. I plan to do a lot more swimming this year and I'm going to work hard to increase my lung capacity. If you're not sure what the AFF program is, I'm sure you can figure it out. 🙂

Busy Free Time

I've been spending a lot of my free time working on the new website for my hosting business and integrating the new site with WHMCS (the web host management software I'm switching to). I'm currently using WHM.AutoPilot but it has failed to meet the needs of my growing business and it still seems quite buggy. I'm also working on a couple of posts -- one for this blog about how I hacked together remote Growl notifications from irssi, and one for my new tech blog about setting up a great local web development environment in OS X.

Zoomism: Navigate by Zooming

Zoomism allows you to navigate the site entirely by zooming. It's actually really fun and works quite well -- a lot more adventurous than scanning and clicking URLs on a page. The site is using Flash to make all this happen so obvious downsides exists (e.g., you cannot select text or easily save images), however I think there is real potential in this concept. I would love to have a tool that allowed me to generate a gigantic map of an entire website that I can explore by zooming!

The End of Alone

The End of Alone, an article in The Boston Globe, talks about how technology is removing what may be vital to our well being. I for one hate feeling connected 100% of the time and I have decided to make it a point to take regular (weekly) breaks from technology. This means turning off my phone and being disconnected from the Internet (but preferably not at my computer at all!).

Browsing the Web with only a Keyboard

The beauty and simplicity of the keyboard has always impressed me. As a kid, my Asian gaming friends taught me the importance of utilizing as much of the keyboard as possible (and the skill improvement was so great it often resulted in being accused of cheating). Many of the applications I use on a daily basis (which used to require a GUI) have been replaced by console-based, keyboard-only alternatives (in particular, instant messaging, email, IRC, and text editing). Each time I switched to a keyboard-only alternative, my productivity (and sanity) have improved immensely.

One application I thought would always require the assistance of my tailed friend was web browsing. While text-based browsers like Elinks and Lynx have made a fantastic effort, they simply don't allow for the rich browsing experience provided by a full browser like Firefox. I had come to accept that maybe the future of keeping my hands in one place was lost to the ever-growing web-based world.

And then, randomly and entirely by chance, I discovered a way to browse the web using nothing but my keyboard: Vimperator, a Firefox plugin that turns the browser into a fully keyboard-accessible interface using vim bindings. It solves the problem of needing to click links and buttons beautifully. Simply pressing the letter f while in command-mode tags all visible links with a number. Typing that number clicks the link or button (you can also just start typing part of a word in the link and then press enter).

Firefox using the Vimperator plugin

It definitely takes some getting used to, but it is much faster than using a mouse! All the browser functionality is available through the keyboard, including tab management (I use tabs a lot). To open a new tab and type a URL, just press Esc to make sure you're in command-mode and then type t google.com. To close a tab, press d (think "delete-tab"). If you decide to try Vimperator and you freak out when your menu and address bar disappears, press Esc to get into command-mode and then type :set guioptions+=mT and press Enter. The :help section is very useful for learning more.

My purist mentality has often made me wonder if I could live entirely on the command line, or if everything I currently do in a GUI could at least be done without a mouse. I think it's more the latter than the former; it's about efficiency. Even when I'm using a mouse with the GUI, I find myself constantly searching for keyboard shortcuts. The mouse just feels so alien for anything but artistic stuff (i.e., working with shapes, graphics, etc) and gaming. It feels like a crutch; like a cane for someone with a typing disability.

I've been using Vimperator for two days now and I have already made several important observations regarding my web browsing usage. Without the mouse, I don't doodle. I don't scroll up and down pages randomly looking at stuff or skipping and then rereading text, all of which waste valuable time. Instead, I'm browsing more efficiently and with more purpose. Another thing I noticed (now that my mouse usage has almost dropped in half) is that when I do reach for the mouse my hand actually feels uncomfortable.

If you're a vim user, or you enjoy the command-line, give Vimperator a shot. You may find yourself very frustrated at first but try to stick with it for a few days and see how it changes your browsing habits. You may be in for a surprise.

Reconfiguring my Time Management

Time management is one of those things that Information Technology has made a fundamental requirement to living and managing day-to-day tasks (and it's a shame that Time Management is not a required course for everyone in IT). I consider myself fairly good with my own time management but lately I have been feeling as though the ratio of stuff getting done to the stuff I want to do is growing further and further apart. My todo lists always seem to be growing and never getting any shorter. Prioritizing and feeling as though I'm making progress on a day-to-day basis feels like a continuous, never ending up hill battle. I'm putting out the fires, but not building new cities.

When I read Sid Savara's "More Important than Money - Paying Myself First With My Time" post, I was incredibly encouraged by the fact that his observations of time and valuing time were almost identical to my own. I have always felt that it makes the most sense to start the day early; to get the things that matter most to you done early so that if you're wiped out at the end of the day, it's OK.

I'm somewhat of an organization freak and having things organized and structured helps me get things done. I don't like creating a schedule because schedules constantly change. Instead, I like creating time-goals so that I'm aware of approximately where my time is going. To start, I created somewhat of a framework for my weekly time:

Monday - Friday
2 hours - Personal Hygiene / Breakfast / Dinner
2 hours - Fitness/Yoga
3 hours - Commuting
8 hours - Work / Lunch
2 hours - Personal Projects / Reading / Writing / Learning
7 hours - Sleep

Saturday - Sunday
2 hours - Personal Hygiene / Breakfast / Dinner
2 hours - Fitness/Yoga
8 hours - Sleep
8 hours - Personal Projects / Reading / Writing / Learning
4 hours - Outdoor & Other Activities

While creating this outline I was surprised to discover how little time I have left for personal projects, reading, writing, and learning during the week. Those things are, of course, what I enjoy doing most and yet they make up only a fraction of my available time. Admittedly, I'm only spending about 1 hour a day on fitness right now, but I consider fitness to be of utmost importance and the highest-value item on the list. Also, I tend to get less than 7 hours of sleep and usually spend the time on personal projects, but sleep is an important part of health too.

Now that I've developed this outline for my time, I'm going to put it into practice and see how I can tweak it.

Upgraded to WordPress 2.7

I finally got around to upgrading this blog to WordPress 2.7. My main motivation for doing so was to enable comment threading. This means you can now respond directly to a comment instead of having your comment appended to the bottom of the list. Also, assuming you've signed up for a Gravatar, your comment will include your chosen Avatar to personalize your comments.