Jinan's Journal

A journal of all the tidbits of information I gathered through the years.

OS X Lion Clean Install with Bootable CD

This quick guide will show you the steps needed to create a bootable OSX Lion CD and then will describe how to do a clean install of the OSX Operating System.

Make a bootable CD of Lion

  1. First you will need to obtain a copy of the Lion installer application. 
  2. Locate the Lion installer application with Finder.
  3. Right (Secondar) click on the application and goto Show Package Contents.
  4. Look for a  folder called SharedSupport.  Inside the folder you will see InstallESD.dmg, copy this file to a different location.
  5. Launch the Disk Utility application.
  6. Click the Burn icon then select the InstallESD.dmg you copied earlier and then insert a blank DVD.
  7. Once finished you will have a bootable OS X Lion CD!

 

 Clean Install with Lion

  1. Insert your CD and restart your computer while holding down option button. 
  2. Double click on the CD Icon and wait a few minutes while the CD loads.
  3. Open up the disk utility from the menu option.
  4. Select your primary partition (Macintosh HD is default) and click erase.  (Obviously this will erase all your data on this partition…)
  5. Once the partition has been erased, select the option to Reinstall OS X Lion on the same partition.
  6. After the installation, you will have a clean installation of OS X Lion!

Block ads with DD-WRT

I have been using a windows host file to block ads on websites for a while now.  The host file (http://www.mvps.org/winhelp2002/hosts.txt) redirects most ad links to 127.0.0.1 instead of their IP address.  By doing this, it shows either a blank page or “page can not be displayed” instead of the normal advertisements.

I wanted to take this one step further and apply this to my router (Linksys E2000) using DD-WRT.  After searching the dd-wrt forums (http://www.dd-wrt.com/phpBB2/viewtopic.php?t=20346), I came across the script to do this.  Some routers like WRT54G v5 and v6 will not be able to do this as there is not enough memeory to store the host file. 

To apply the script you will need to do 3 steps.

  1.  Under the Services Tab, enable DNSMasq.
  2.  Under the Services Tab, enable Local DNS.
  3. Under the Administration Tab, click the Commands tab.  Paste the code below in the box and click ‘Save Firewall’.

 

  • Save Firewall – Saves this as a firewall script.  Every time your WAN port connects up, it will redownload the host file.
  • Save Startup – Saves this script as a startup script.  Each time your router boots, it will download the hosts file.
  • Run Commands – Run the script once.
  • Save Custom Script – Saves the script but does not run it, it stores it so you may run it manually.

 

What this script does it downloads the host file from the above link, searches for the IP address of 127.0.0.1, replaces 127.0.0.1 with 0.0.0.0 and then saves it to /etc/hosts on the router.  This will replace /etc/hosts file so you will not be able to use http://DD-WRT to get to the router anymore.  Just use http://192.168.1.1 or whatever the router IP address is.

Here is the script:
wget -O - http://www.mvps.org/winhelp2002/hosts.txt | grep 127.0.0.1 | sed -e '2,$s/127.0.0.1/0.0.0.0/g' -e 's/[[:space:]]*#.*$//' > /etc/hosts
logger "$0: Hosts-file downloaded"
stopservice dnsmasq
startservice dnsmasq
logger "$0: DNSMasq restarted"

Linux on Microsoft VirtualPC

I had an interesting thing happen to me when I tried installing CentOS 5 on VirualPC 2007. 

Currently RedHat and SuSe linux guests are supported by VirtualPC.  Installing other linux guests is possible.  To install CentOS 5 as a guest in VirtualPC you will need to install it via text mode.  If you try to run the setup normally, you get wierd graphic issues like the one posted below.  This is due to the fact that it does not understand the graphics chipset that VirtualPC uses.

CentOS 5 graphical installation on VirtualPC 2007

To get into text mode in CentOS 5 at the boot: prompt type in linux text

To install Ubuntu 8 and later on VirtualPC you will need to run the installer in SafeMode.

After that, its pretty much straight forward.

Installation of Street View on Google Maps unsucessful

Usually this happens when the trying to update Street View, Voice Search, etc. and the signatures do not match.  Either there was a hacked version of this installed or something happened.  I found a fix for this, this requires the Android SDK (adb atleast).  If you have this run the following commands:

adb root
adb remount
adb shell
rm /system/app/Street.apk
exit
adb uninstall com.google.android.street

Then reinstall Street View from the Market Place.

I have tried this method with VoiceSearch as well by doing:

rm /system/app/VoiceSearch.apk
adb uninstall com.google.android.voicesearch

This works with Google Search as well:

rm /system/app/GoogleQuickSearchBox.apk
adb uninstall com.google.android.googlequicksearchbox

If you get a Failure on trying to uninstall these apps, you will need to delete the APK first.

As always please backup your system first, I take no responsibility if this does not work.

ISC-DHCP Programming Notes

Here are some programming notes that I have collected working with ISC-DHCP at my job that may come in handy.

If you put this code in the dhcpd.conf file (Located at /etc/dhcpd.conf in RedHat/CentOS or /etc/dhcp3/dhcpd.conf in Ubuntu)

if known {
     log (info, concat ("HOSTNAME: ", host-decl-name, " on ",binary-to-ascii (10, 8, ".", leased-address)," at ", binary-to-ascii (16, 8, ":", substring (hardware, 1, 6))));
}

Will result in a message simular to the following in your DHCP Log file:

HOSTNAME: TestPC001 on 208.x.x.75 at d0:50:56:ac:74:71
DHCPDISCOVER from d0:50:56:ac:74:71 via eth0
DHCPOFFER on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
DHCPREQUEST for 208.x.x.75 (172.18.1.2) from d0:50:56:ac:74:71 via eth0
DHCPACK on 208.x.x.75 to d0:50:56:ac:74:71 via eth0

The following code will check to see if the incoming packet has the DHCP Broadcast Flag set.  If it does, it will log to the log file that someone has broadcast flag set.

if binary-to-ascii (16,8,"",packet(10,3)) = "8000" {
     log (info, concat ("The user ", binary-to-ascii(16,8, ":", substring(hardware,1,6)), " has the DHCP Broadcast Flag set."));
}

Example Log file entry:

DHCPDISCOVER from d0:50:56:ac:74:71 via eth0
The user d0:50:56:ac:74:71 has the DHCP Broadcast Flag set.
DHCPOFFER on 208.x.x.75 to d0:50:56:ac:74:71 via eth0

The following code in the configuration file will add anyone who has the DHCP Broadcast flag set to a member of “Broadcasters” then you may allow or deny them in a subnet declaration:

class "broadcasters" {
     match if binary-to-ascii (16,8,"",packet(10,3)) = "8000";
}

In the subnet declaration you then can do allow members of broadcasters; to allow only those specific users.

Term Explaination:

host-decl-name – Is the host declaration name in the dhcpd.conf file (host TestPC { … })
binary-to-ascii(a,b,c,d) – binary-to-ascii(Base 2 to 16, width in bits of each number, seperates each bit with the character, the numeric expression to be tested)
leased-address – The IP address leased to the client (in binary)
substring(a,b,c) - substring(hardware, 1, 6) – This gets the MAC address of the client.  substring(data expression, offset bytes, length in bytes)
hardware – Returns type of network indicated in packet (Ethernet), then the MAC address.
packet(a,b) – packet(offset byte, additional bytes) — This starts at the Bootstrap Protocol.

Packet Information:

0,1 – Message Type (01 – Boot Request, 02 – Boot Reply)
1,1 – Hardware Type (01 – Ethernet)
2,1 – Hardware Address Length (usually 06)
3,1 – Hops (usually 00)
4,7 – Transaction ID of the handshake.
8,3 – Seconds Elapsed
10,3 – Bootflag (0000 = off, 8000 = on)
12,7 – Client IP Address
16,7 – Your (client) IP Address
20,7 – Next Server IP Address
24,7 – Relay Agent IP Address
28,11 – Client MAC Address
34,19 – Client Hardware Address Padding
44,63 – Server host name
76,127 – Boot File
140,7 – Magic Cookie (DHCP)
144,1 – DHCP Message – Option
146,1 – DHCP Message – Length
148,1 – DHCP Message – Value
150,1 – Client ID – Length
152,13 – Client ID – Value (All of the client ID values past 152)
152,1 – Client ID – Hardware Type
154,11 – Client ID – Client MAC Address
160,1 – Requested IP – Option
162,1 – Requested IP – Length
164,7 – Requested IP – Value
168,21 – Host Name
180,19 – Vendor Class ID
190,1 – Param List – Option
192,1 – Param List – Length
194,23 – Param List – Value (All the param list values past 194)
194,1 – Param List – Subnet Mask
196,1 – Param List – Domain Name
198,1 – Param List – Router
200,1 – Param List – DNS
202,1 – Param List – NetBIOS Name Server
204,1 – Param List – NetBIOS Node Type
206,1 – Param List – NetBIOS Scope
208,1 – Param List – Perform Router Discover
210,1 – Param List – Static Route
212,1 – Param List – Classless Static Route
214,1 – Param List – Private Static Route (Microsoft)
216,1 – Param List – Vendor Specific