netnerds.net

23Oct/110

OpenVPN: Update Client DNS Servers on Mac OS X Using the Command Line.

There's a bit of a debate on how best to update your DNS resolver on Mac OS X when connecting to an OpenVPN Server. For whatever reason, even if use DHCP on the VPN server, OS X won't use the assigned DNS server(s). It's been recommended to use scutil, but the scripts are crazy long and I've read the resolver order sometimes gets reset anyway.

The usual route of using /etc/resolv.conf does not work on OS X but specifying DNS servers in your Network Preferences does. If you use public network servers like 8.8.8.8 or 4.2.2.2, you're already set. Move along :) But if you rely on DHCP assigned DNS servers, the the script below will do the trick. This script specifies or clears (sets back to DHCP default) the DNS servers on each of the adapters listed in networksetup.

#!/bin/bash

# Set bash delimeter to be line break
IFS=$'\n'

# VPN DNS Server
vpndns='172.20.0.1'

# Get adapter list
adapters=`networksetup -listallnetworkservices |grep -v denotes`

for adapter in $adapters
do
        echo updating dns for $adapter
        dnssvr=(`networksetup -getdnsservers $adapter`)

        if [ $dnssvr != $vpndns ]; then
                # set dns server to the vpn dns server
                networksetup -setdnsservers $adapter $vpndns
                else
                # revert back to DHCP assigned DNS Servers
                networksetup -setdnsservers $adapter empty
        fi
done

Again, if you already set your DNS servers, your OpenVPN connection will use those. This script is effective for people who use DHCP assigned DNS servers by default and would like to tunnel their DNS requests when connecting to an OpenVPN server.

Posted by: Chrissy   Filed under: Apple, Networking No Comments
20Oct/110

OS X: Find Network Gateway using the Comand Line

This is a bit more complex than it should be; I was hoping networksetup would make this easier but, alas. Using netstat -nr appears to be the best way to find your gateway from the command line:

netstat -nr | grep '^default' | awk '{ print $2 }'

If you haven't played around with networksetup, I recommend checking out networksetup -getinfo "Airport" and networksetup -listnetworkserviceorder.

Posted by: Chrissy   Filed under: Apple No Comments
4Oct/110

iPhone Dev: Base SDK Missing Solved

Someone awesome sent me the code to an iPhone app that he created for RealCajunRecipes.com. I unzipped the file, and opened the project in XCode 4.2. I immediately noticed the upper left hand drop down (what's that called anyway?) said "Base SDK Missing." So I went to all the usual places to change the SDK, I saved it and restarted XCode. Nope, I still encountered the following error when trying to Build my project: error: There is no SDK with the name or path 'iphonesimulator3.1'.

Google searches gave me the same "solution" over and over but none of it worked. Ultimately, I had to go into my projects .xcodeproj directory to edit the file project.pbxproj.

I changed the lines that referenced SDKROOT from SDKROOT = iphonesimulator3.1 to SDKROOT = iphoneos, restarted XCode and successfully built the app.

Posted by: Chrissy   Filed under: Apple No Comments
3Nov/100

HOWTO: Simply Connect Mac OSX to a dd-wrt OpenVPN Server on TCP Port 443

If you find yourself on a really restrictive network but still want to connect to a remote VPN, consider this solution. It allows you to connect a Mac OS X OpenVPN client to an OpenVPN server using a static key. I figured it out using a combination of webistes, including dd-wrt's OpenVPN wiki, OpenVPN's documentation, and tinyapps.org.

This solution can probably be way more automated using tunnelblick, but I'm alright with running a couple scripts (for now) to get my VPN going. Here's what you'll need:

Network
- No web proxy or a proxy that allows persistent connections.

Server
- A Linksys WRT54GL router
- dd-wrt.v24_vpn_generic.bin (follow instructions on the website to flash from scratch.)

Client
- MacOS X Snow Leopard
- OpenVPN v2.1.3
- tuntap_20090913.tar.gz
- lzo 2.02

I downloaded all of these then compiled and installed them myself. Not because I'm leet, but because the network I was on blocked sync and I couldn't use MacPorts. So go download and compile these or use MacPorts.

First thing is first, I changed the subnet on my wireless router. I hate the 192.168 subnet; it's aesthetically unappealing and overused. Now 172.20.0.x is something pretty. Let's go with that.

We will not be using dd-wrt's GUI to enable or configure OpenVPN, but rather startup and firewall scripts in the /tmp directory. I also avoid using the default protocol and port (udp, 1194) and go with tcp port 443.

Here's a step by step

Server
- Generate the static key: openvpn --genkey --secret static.key
- Cat that key and place it in your clipboard
- Open up dd-wrt's admin webpage, and go to Administration -> Commands. Paste the following:

openvpn --mktun --dev tap0
brctl addif br0 tap0
ifconfig tap0 0.0.0.0 promisc up
echo "
-----BEGIN OpenVPN Static key V1-----
[Insert your static key  here]
   -----END OpenVPN Static key V1-----
"> /tmp/static.key
ln -s /usr/sbin/openvpn /tmp/myvpn
/tmp/myvpn --dev tap0 --secret /tmp/static.key --comp-lzo --port 443 --proto tcp-server --verb 3 --daemon



- Save that to Startup Scripts
- Next, back in the blank box, we'll place the code for the firewall and NAT:

iptables -I INPUT 1 -p tcp --dport 443 -j ACCEPT
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


Client
You will be creating 2 scripts and one key: openvpn.conf, startvpn.sh and secret.key. Place them in ~/Library/openvpn.

For your key, copy/paste your static.key from the dd-wrt router into a file named secret.key. Save the following two scripts as openvpn.conf and startvpn.sh, respectively. Don't forget to make startvpn.sh executable.

#openvpn.conf
remote my.vpn.external.ip
port 443
dev tap0
secret static.key
proto tcp-client
comp-lzo

Now this part is kinda ghetto. I want to route all my traffic through the VPN but I was unable to get route-gateway and redirect-gateway to work inside of openvpn.conf. I decided to save time and just do it through the startup script instead.

kill -9 `ps aux | grep openvpn.conf |grep config| awk '{ print $2 }'`
openvpn2 --config openvpn.conf --script-security 2 &
sleep 3

# Change your vpn server and internal subnet here
vpnserver='my.external.vpn.ip'
vpngw='172.20.0.1'

# If you use DHCP supplied DNS Servers, leave this as true
changedns=true

previousgw=`cat ./gateway 2> /dev/null`
currentgw=`netstat -nr | grep '^default' | awk '{ print $2 }'`

if [ -f ./gateway ]
then
# Set it back to the regular gateway
route delete default
route delete $vpnserver $previousgw
route add default $previousgw
rm ./gateway

echo gateway set back

                if [ $changedns ]; then
                networksetup -setdnsservers Ethernet empty
                networksetup -setdnsservers Airport empty
                echo dns reset
                fi
else
                # Set it to the VPN gw
                route add $vpnserver $currentgw
                sleep 7
                route delete default
                route add default $vpngw
                echo $currentgw > ./gateway

                # Tunnel your DNS Requests too.
                if [ $changdns ]; then
                networksetup -setdnsservers Ethernet $vpngw
                networksetup -setdnsservers Airport  $vpngw
                echo new dns set
                fi
fi

Check out this post on updating client-side DNS servers if you'd like to update all of your adapters instead of the ones most often used (Ethernet and Airport.)

Or something like that... Simple, right? ;)

Posted by: Chrissy   Filed under: Apple, Networking, Security No Comments
11Apr/101

OS X: Show hidden files and WTF to do with an ipsw file.

I just downloaded the iPhone OS 4.0 beta and have no idea what to do with the resulting ipsw file. Apple was awesome enough not to include any obvious directions. So after searching Google, I came across some forums that recommended the following:

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

That didn't show the files that were supposed to appear at ~username/Library/iTunes/iPhone Software Updates/ and Finder looked dirty so I reran the above command using FALSE instead of TRUE.

Ultimately, I successfully installed the new iPhone OS by following the directions outlined at felixbruns.de: I pressed option-click on the Restore button in iTunes and selected iPhone1,2_4.0_8A230m_Restore.ipsw. Good times!

Posted by: Chrissy   Filed under: Apple 1 Comment
12Dec/094

Hello World! I Created My First iPhone App (And Used Snow Leopard on a Netbook to do it.)

With the guidance of Apress's Beginning iPhone 3 Development, I was able to create my first iPhone App in less than two hours. While the book's first chapter used the classic yet very boring Hello World example, I knew I'd need to spice things up in order to keep my interest. Over the past few weeks, I've been playing pranks on my friend Chelsea and figured I could use an iPhone App to continue this trend.

Let's just say, if Apple made a commercial for my App, it would state: Need to turn Chelsea on? There's an App for that.

iPhone App

I know Netbooks are supposed to just be used for surfing, but they are plenty powerful as a secondary machine and hobbyist iPhone development. Earlier today, I was running Photoshop CS 4, Chrome, Adium and Xcode with no issues. Next up, writing a RealCajunRecipes.com iPhone app, then migrating the entire site to the WordPress platform!

Posted by: Chrissy   Filed under: Apple 4 Comments
9Oct/098

Dual Boot MBR-based OS X Leopard (Vanilla) and Windows 7 on $330 Dell Mini 10v Netbook

Natively booting OS X and Windows 7 on a hella fine Dell Mini is initially challenging but well worth the reward of being the coolest nerd on the block. Here's what you'll need to accomplish this task:

  1. Windows 7 DVD
  2. Leopard Retail Vanilla (I have 10.5.6)
  3. External USB Drive
  4. External CD/DVD drive
  5. DellMiniBoot123v8
  6. EasyBCD (optional)
  7. gparted disk partitioner (optional)
  8. A Dell Mini 10v w/A06 BIOS. I purchased my Inspiron iM10-008B at Best Buy for ~$330 .

First thing is first, get setup by burning the CDs and DVDs that you'll need. Next, you will have to create a bootable USB drive with Leopard on it. You can probably do this using a Linux utility or you can do it if you have an extra Mac laying around, but I did it by temporarily booting to the Kalyway OS X DVD and then following the instructions for creating the USB boot drive. Note that this tutorial does not use the Kalyway DVD for the actual install. Then...

  • Install Windows 7 on freshly partitioned and formatted disk
    • I loosely followed the gizmodo dell mini 9 tutorial. First, I installed Windows 7 from scratch, with a fresh partition and a fresh format. Note: when you format/partition under Windows 7, it creates some kind of System partition. In order to avoid this, you can click "Cancel" when the message pops up about Windows automatically adding files/a partition. Alternatively, you can pre-partition the drive under the Kalyway boot or by using gparted disk partitioner. This will partition the drive using MBR; that's what you want, fa sho.
    • Make sure no other system formatted drives (such as the Mac OS X USB drive you will create) are plugged in when you attempt to install Windows 7. You'll run into a variety of errors. Check my blog for details.
  • Create 2 new partitions for Mac OS X and the temporary installer
    • Once Windows was installed, I used Windows Disk Management to shrink my Windows partition and create two new partitions. One was 50gb (for Mac OS X) and one was 5GB (for a trick we'll do later). You can merge this partition later, don't fret.
  • Using the DellMiniBoot123v8 CD, I booted to my USB Mac OS X install.
    • Basically, I pressed Esc at the boot prompt, typed in the hex for my USB drive (80) and then booted  with the -f option. Once I was able to, I opened the Disk Utility and properly formatted my two new drives to Mac OS X Journaled.
  • I then used this INCREDIBLY EASY tutorial for enabling Leopard to install on MBR formatted disk
    • Leopard usually requires a GUID partioned drive but Windows 7 (x86) refuses to install on such a setup.
  • I installed Vanilla Leopard 10.5.6
    • I deselected all the language and printer packages. This saved gigs of space.
  • I used the DellMiniBoot CD to boot AGAIN into the OS X installer
    • Pressed escape, keyed in 80 at the prompt
    • Gave the -f param at the boot: prompt
  • I set the Mac partition to active.
    • If you install the DellEMI utils without doing this, you will destroy your Windows 7 install and have to start all over again.
  • I used the DellMiniBootCD to boot into my  new OS X install
    • Pressed escape, keyed in 81 at the prompt (ir 80 if you remove your USB drive)
    • Gave the -f param at the boot: prompt
  • I copied the DellMini folder from the CD to the Desktop, and ran the installer.
  • I repeated the last two steps once more for good measure
    • NOTE: This installs the Darwin boot loader. You can now boot up to Windows using this, but I prefer the prettier menu-driven one that defaults to Windows so I used EasyBCD for boot management.
  • I removed all media (External CD drive, Mac OS X USB drive) and rebooted
  • I used the Darwin boot loader to boot into Mac, threw my hands up in the air and drank a glass or three of La Crema Pinot Noir in celebration.
  • I later booted into Windows and setup EasyBCD to manage my bootup.

It took about a week and about 3200 repartitions/reformats to get this routine down but it was time well spent; my $350 Hackbook is mega. Thanks to the slew of people who spent the time creating various tutorials that made this party possible!

Here are some of the resources I used:

MyDellMini.com:  USB Install (no DVD drive)
Gizmodo: Hackintosh a Dell Mini 9 Into the Ultimate OS X Netbook
How to: Install to an MBR Drive from an Unmodified Vanilla OSX DVD
Hack Attack: Dual Boot Windows and OS X Leopard
InsanelyMac: Setting Your Mac OS X Partition to Active
Upgrading to 10.5.8

If you have any questions or if I left something out, please feel free to comment.

Posted by: Chrissy   Filed under: Apple 8 Comments
7Oct/096

Easily Install Mac OS X Leopard on an MBR Formatted Disk

Ugh, eff a GUID formatted disk! This is by far the easiest way to get OS X Leopard (Retail/Vanilla) to install on an MBR formatted disk. I've gone through about 400 other tutorials and most were so complex. This method, which consists of about 20 simple steps has worked like a charm so far. I suggest reading the tutorial, but it's pretty much as easy as this:

Create a temp 6 gig partition. Then, in a Terminal window, run:

  • cp -R /System/Installation/Packages/* /Volumes/TempPart
  • cd /Volumes/TempPart
  • mkdir temp
  • mv OSInstall.mpkg temp/
  • cd temp
  • xar -x -f OSInstall.mpkg
  • cat Distribution | sed "s/eraseOptionAvailable='true'//g" > Distribution2
  • mv Distribution2 Distribution
  • rm -Rf OSInstall.mpkg
  • xar -c -f OSInstall.mpkg *
  • mv OSInstall.mpkg ../
  • cd
  • rm -Rf temp
  • mount
  • cd /
  • umount /Volumes/TempPart
  • mount -t hfs /dev/diskXsX /System/Installation/Packages

Getting Windows 7 and OSX Leopard to dual-boot on a Hackintosh/Hackbook has not been easy. I'll be posting how I did it once I've successfully booted into both.

Posted by: Chrissy   Filed under: Apple 6 Comments
22Feb/0710

Kickin My Macbook to the Curb

I believe I have a pretty high tolerance for inconveniences but I just couldn't take it: running Windows Server 2003 as a primary OS on Macbook blows.

As a fan of Unix, Windows and beautiful UIs, I promised myself I would put down any amount of money for a small Macbook the day it came out and I did just that. Then I ran back to work and attempted a Windows Server 2003 install. I never liked Windows XP and all the free crap it had to offer; I wanted a bare bones, unrestricted workstation and Win2k3 gave me that. It took about a week of hacking but I finally got the drivers installed. From there, my Macbook looked sexy and was super fast but ultimately became an utter inconvenience. As you can see from the sidebar, one of my most popular posts is about running Windows 2003 on a Macbook. I feel for those poor souls and can only hope they don't plan to use Win2k3 as their primary OS. As a friend said, "The Macbook is great. It's just not great for you."

So I've bought a new beauty and I love it, but before I get there, let me outline what sucks about running Win2k3 on a Macbook.

  • This applies to all Macbooks: inconsistent yet persistent fan issues. I don't care what you or you or you say, fans aren't supposed to sound that way. And it's not cool. Speaking of not cool, the Macbook gets way hot at times.

  • Remapping the keyboard to a Windows layout makes for a nasty delay after coming back from standby. The InputRemapper software from that guy works very well, I just don't like the wait.
  • If you want Bluetooth in Win2k3 to work, you have to run hid2hci every time it comes back from being on standby.
  • Built-in microphone jack + loud fans = impossible to make CBTs.
  • Power management sucks.
  • Will installing Leopard mess up my hacked 2k3 install? Will Parallels replace Bootcamp at some point, leaving me with no real option to boot Windows natively? I don't know but wondering causes stress.
  • No right click. I mapped the right Apple key to it but still.

So here I sit at Tommy's Joynt in San Francisco drinking coriander spiced beer and playing on my new Dell XPS M1210. I spent the past two weeks deciding between buying the super sexy but slower Sony Vaio, the equally sexy & slow new Fujitsu LED backlit Lifebook or this pretty-damn-affordable-and-unattractive-yet-lightweight-powerhouse from Dell. Dells just aren't pretty. I often wonder if Ford Motor outsources their car designers to Dell. Sure, you can make a laptop that looks like this..but why?

My new Dell lacks visual appeal (in my opinion) but makes up for it with its incredible amount of power. I've got a Core 2 Duo with 4MB of on-board cache (stylin' like a Xeon), 2 GB of RAM, 80GB 7200 RPM HDD and a 256MB nVidia card.. And to top it off, it's about 4.5lbs and retailed for about $2300 after tax, warranty, shipping and all that. Now I'm finally running Vista Enterprise with nothing but drivers, something I never really expected to do. But I really like it (also unexpected). "WOW" not so much but it's definitely a long overdue improvement. Here's my top favorite features so far

  • I don't need third party drivers to output my laptop display solely to my monitor. Finally!
  • The System Tray is cleaner and more informative
  • Vista Enteprise doesn't come with extra crap I don't need or want
  • Aero is really nice. I like how the taskbar now has popups to show you whats going on.
  • The search actually works. Searching in Windows, especially when searching inside files for text, was broken by Microsoft in XP and 2003. Even NT returns more accurate matches. How was this not noticed by engineers at Microsoft? I'm thinking it was a way to make people frustrated enough to install that Live Search bar.
  • Task scheduler and Event Viewer are super improved
  • The Windows Orb (formerly the Start button) is a big improvement over XP.
  • Dynamic disk resizing -- even on the windows partition

This page has a great outline of some of the new features and it also includes screenshots. Actually, the more tweaks and tricks I find, the more I realize that my initial list is going to change a ton over time. Something cool I just found is called "Additional Clocks" which allows you to add additional time information to the system tray clock hover. You can add up to 2 additional clocks.. I just added Louisiana and GMT.

A few things suck about Vista, including some networking issues but overall, I'm really digging both Vista and the Dell XPS M1210 I've named CRACKLIN. As for the Macbook, I've sold it to a Mac fan who can put it to better use.

Posted by: Chrissy   Filed under: Apple, Windows 10 Comments
21Aug/0617

MacBook: Run Windows 2003 Server SP1 on your Macbook

I'm on my second Macbook. My first one was fast and beautiful but it had that annoying moo and randomly shut down on a regular basis. For reasons unknown, an AppleCare rep told me on my 5th call that my laptop was DOA and could be exchanged for a new one. It was well past my 14-day exchange limit and I found it so hard to believe, I asked him/her to note it on my profile. It took about 3 weeks for me to find the time to back it up, wipe it and schedule an appt with a Mac Genius. I get there after wiping my drive (as instructed) and the rep told me that I was given the wrong information -- I could only repair my laptop, not exchange it. I was liek omg, check my profile, plz. Long story short, they honored the inaccurate information because it was noted (so always ask for it in writing!)

Posted by: Chrissy   Filed under: Apple, Windows Continue reading