<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-15341180</id><updated>2008-10-28T12:52:48.151-05:00</updated><title type='text'>Hosting Geek Blog</title><subtitle type='html'>I am the hosting geek. I work for a hosting company and these pages cronicle my daily encounters working as a -- Hosting Geek.</subtitle><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/'/><link rel='next' type='application/atom+xml' href='http://www.hostinggeek.com/atom.xml?start-index=26&amp;max-results=25'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.hostinggeek.com/atom.xml'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-15341180.post-6223303998483851947</id><published>2008-10-28T11:55:00.002-05:00</published><updated>2008-10-28T12:52:48.172-05:00</updated><title type='text'>How To Recover Data From a Badly Corrupted Drive</title><content type='html'>&lt;span style="font-family: arial;"&gt;Recently I had a customer's hard drive on a dedicated server corrupt so badly that we couldn't access the information on it at all. Any attempt to fsck the drive or even just mount it produced weird errors and strange notifications (like trying to mount it would say "not found" and other really vague answers).&lt;br /&gt;&lt;br /&gt;We basically determined that the inode that held the partition tables as well as the inode that held root directory (/) were corrupted. We were able to run a fsck on it initially, and were prompted to repair the entries as well as multiply linked inodes and other errors. After letting fsck finish, the drive was completely unreadable. No partition tables, nothing... We told the customer that the drive corrupted and that they would have to restore their site from backups. Well guess what they said? "What backups?" Ugh... So...&lt;br /&gt;&lt;br /&gt;Moving on... we installed a new drive, moved the old drive as the slave to attempt to recover the data for them. We installed the OS and setup the control panel, and put a page "Site crashed... we are working on restoring it." and moved forward.&lt;br /&gt;&lt;br /&gt;Here is what we did and the results we had and some notes about the process along the way.&lt;br /&gt;&lt;br /&gt;1) &lt;span style="font-weight: bold;"&gt;Do not panic! &lt;/span&gt;The first thing you have to remember in dealing with a corrupted drive is &lt;span style="font-weight: bold;"&gt;don't panic&lt;/span&gt;! The information is still there... and with enough effort can be recovered provided that the drive still functions at some level.&lt;br /&gt;&lt;br /&gt;2) &lt;span style="font-weight: bold;"&gt;Make a backup image.&lt;/span&gt; This will help you out a great deal when things go wrong. I recommend using dd to just mirror the data to a new drive or some place with enough storage to hold the drive data.&lt;br /&gt;&lt;br /&gt;3) &lt;span style="font-weight: bold;"&gt;Take your time.&lt;/span&gt; This one is hard to follow because normally the site is down and the customer is absolutely panic striken and calling you every 15 minutes asking about the status. Working with large sets of data takes time, so be patient and wait for the various processes to complete... They always take a while, and cutting corners here to save time will only lead to misery if you screw things up.&lt;br /&gt;&lt;br /&gt;Okay... Now that we have the ground rules laid out, here is how we restored all their data save one database table, and even then we managed to save that and I will show you how we did that as well.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1: &lt;/span&gt;Take the drive to another machine if you can, or a safe place to work on it. We had another machine with a large enough hard drive to hold the data on the drive and made a disk image of it.&lt;br /&gt;&lt;br /&gt;dd if=/dev/sdb bs=1k conv=sync,noerror | gzip -c &gt; /path/to/disk.img.gz&lt;br /&gt;&lt;br /&gt;This will save your a potential future headache, but it takes a long time for a fair amount of data. Wait it out... it is worth it in the long run.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2:&lt;/span&gt; Determine how badly the drive is corrupted. In our case an "fdisk -l /dev/sdb" didn't show any partition tables, so we had to recover that first before we could start getting at the data.&lt;br /&gt;&lt;br /&gt;The application we used to recover the partition table is &lt;a href="http://www.cgsecurity.org/wiki/TestDisk"&gt;TestDisk&lt;/a&gt;. It is written by a gentleman named Christopher Grenier, and to say that it is awesome is a complete understatement. You will be using this software for all steps that follow, that is how useful it is.&lt;br /&gt;&lt;br /&gt;Okay... so download TestDisk from the link above and extract it. Make sure to grab the version for the OS you are using. We used the linux 2.6 kernel version since the drive is attached to a 2.6 kernel machine that we are using for recovery purposes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3:&lt;/span&gt; Recover the partition table. When you first run TestDisk it provides you with a list of drives available. Select the drive (in our case it was /dev/sdb), and the partition table type (we used Intel/PC since that is what we have). Select "Analyse" and the software will inspect the drive to look for partitions. The software will do a quick search first and scan the drive very quickly looking for partitions. In our case it found the boot partition almost immediately, however the other partition was not found on the first pass, so we needed to do a "Deeper Search". The Deep Search found the other partition.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 4: &lt;/span&gt;Once you have the partitions listed, you will want to write them to the drive if possible. This will help you in the next step. After we wrote the partition table we exited TestDisk and did step 5. If you just have a Linux based partiton instead of an LVM partition, then you can just continue to step 6.&lt;br /&gt;&lt;br /&gt;This is where things get a little tricky. In our case the partition was actually an LVM physical volume partition, meaning it holds additional information for LVM volume groups and logical volumes inside it. TestDisk won't allow you to read files directly from the LVM partition, which makes sense since there aren't technically any files inside that. What you need to do is get your OS to import and activate the volume groups and logical volumes so that TestDisk can see them and use them.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 5:&lt;/span&gt; Import and activate your LVM volume groups and logical volumes. First you need to find your LVM settings. So run:&lt;br /&gt;&lt;br /&gt;lvm vgdisplay&lt;br /&gt;&lt;br /&gt;This will show you the volume groups for the drive. Then you run:&lt;br /&gt;&lt;br /&gt;lvchange &lt;volgroup&gt; -ay&lt;br /&gt;&lt;br /&gt;This will activate the volume groups and logical volumes so that the OS can use them.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 6: &lt;/span&gt;Start TestDisk again, and this time you should see the logical volume or partition with your files on it. Select it and this time (if you are using LVM) you should select "None" as the partition type, since LVM doesn't have partition information. Select Analyse and you will see the partitions hopefully.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 7: &lt;/span&gt;Move the partition that contains your files, and press the letter p. This will give you a directory listing of the files as they are found in the partition/logical volume. From here it is just a matter of navigating to the correct location and finding the files you need to recover and pressing "c" to copy them off the drive onto your working drive.&lt;br /&gt;&lt;br /&gt;The customer's drive was a mess. Basically all the directories and files were linked under "lost+found" with names like #123456789. We had to hunt and peck through the drive structure to find the information that we needed. We eventually found the mysql directory and the web space directory and copied those to the working drive (/dev/sda) on our recovery machine.&lt;br /&gt;&lt;br /&gt;I have to say that we were pretty pleased with the results. Out of all the files we recovered (and there thousands of images and other files) we only had one file that was damaged. Unfortunetly it was a MySQL FRM file which contains the schema information for the associated table. Without this information MySQL can't read the data from the MYD file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Recovering from a damaged FRM file&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;The FRM file doesn't often get modified, so the likelyhood of it being damaged is small, but in our case the damaged drive did corrupt this file. Here is how we recovered the data.&lt;br /&gt;&lt;br /&gt;If you have a copy of the original schema, and I mean an exact copy with correct field lengths/types, etc. then you are in luck and the restore process is very simple.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1: &lt;/span&gt;Make backups of your files. Copy the MYD file out of the databases folder (/var/lib/mysql/databasename) to someplace safe. You are goint to need this later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2: &lt;/span&gt;Delete the other files that make up the table files (remove the corrupted FRM file, MYI file and the MYD file you just copied). For example if the table is named foobar in database example, then you will have files named: foobar.MYD, foobar.MYI, and foobar.frm in a folder named example in your mysql directory.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3: &lt;/span&gt;Recreate the table schema. Generally this involves logging into the MySQL command line interface and typing in the CREATE TABLE sql queries to make the table. This will recreate the table in MySQL, but the table will be empty.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 4:&lt;/span&gt; Copy your data file back to your database folder. Take the backup you made of the MYD file in step 1 and copy it over the file that is now in the database folder. Using our example again, you would copy the file foobar.MYD over the file that exists in the example folder in the MySQL data folder.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 5: &lt;/span&gt;Restart MySQL. Not really necessary, but can't hurt either.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 6: &lt;/span&gt;You will need to repair the table to make sure your indexes are correct and everything is working correctly.&lt;br /&gt;&lt;br /&gt;And that is it!&lt;br /&gt;&lt;br /&gt;Good luck, and I hope you never need this information.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/6223303998483851947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=6223303998483851947' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/6223303998483851947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/6223303998483851947'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2008/10/how-to-recover-data-from-badly.html' title='How To Recover Data From a Badly Corrupted Drive'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-7560733744304628420</id><published>2008-09-22T10:33:00.004-05:00</published><updated>2008-09-22T11:34:18.558-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pxe'/><category scheme='http://www.blogger.com/atom/ns#' term='gpxe'/><category scheme='http://www.blogger.com/atom/ns#' term='dom0'/><category scheme='http://www.blogger.com/atom/ns#' term='hba'/><category scheme='http://www.blogger.com/atom/ns#' term='Xen'/><category scheme='http://www.blogger.com/atom/ns#' term='iscsi'/><title type='text'>Turn Your PXE Enabled Network Card Into an iSCSI HBA</title><content type='html'>&lt;span style="font-family: verdana;"&gt;You can turn that PXE enabled network card into an iSCSI enabled HBA for free. Save yourself a couple of bucks on an iSCSI HBA, and boot your server/workstation diskless via iSCSI.&lt;br /&gt;&lt;br /&gt;Here is how you turn your card into an HBA.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://etherboot.org/"&gt;gPXE&lt;/a&gt; is a PXE compatible bootloader that provides some great functionality including &lt;a href="http://en.wikipedia.org/wiki/ATA_over_Ethernet"&gt;AoE (ATA Over Ethernet)&lt;/a&gt;, HTTP (loading boot scripts  and boot images from HTTP), and the one we are most interested in, iSCSI which allows us to boot from an iSCSI target.&lt;br /&gt;&lt;br /&gt;We start off with a working PXE enviroment; DHCP server (to provide IP and PXE settings) and TFTP server (to provide the PXE files we need to load). Now in order to get PXE to load the gPXE firmware we need to do what is called "chainloading". This means that our network card will do its standard PXE boot up, and when it loads, we will then load the gPXE loader and use gPXE for the rest of the boot process.&lt;br /&gt;&lt;br /&gt;Here is how we do that:&lt;br /&gt;&lt;br /&gt;In our DHCPd server we need to add some specific settings to enable us to detect wether or not the DHCP request is coming from PXE, or gPXE.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;/etc/dhcpd.conf:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;allow booting;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;allow bootp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;default-lease-time 600;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;max-lease-time 7200;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;authoritative;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;option space gpxe;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;option gpxe-encap-opts code 175 = encapsulate gpxe;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;option gpxe.bus-id code 177 = string;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ddns-update-style ad-hoc;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;subnet 192.168.2.0 netmask 255.255.255.0 {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        use-host-decl-names on;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        range 192.168.2.20 192.168.2.200;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        option subnet-mask 255.255.255.0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        option broadcast-address 192.168.2.255;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        default-lease-time 1800;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        max-lease-time 86400;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        option domain-name-servers 192.168.1.10;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        next-server 192.168.2.1;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        if not exists gpxe.bus-id {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                filename "undionly.kpxe";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        } else {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;                filename "http://192.168.2.1/default/install.gpxe";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The important lines are:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;option space gpxe;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;option gpxe-encap-opts code 175 = encapsulate gpxe;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;option gpxe.bus-id code 177 = string;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;if not exists gpxe.bus-id {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        filename "undionly.kpxe";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;} else {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;        filename "http://192.168.2.1/default/install.gpxe";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This conditional statement allows us to load either the gPXE chainloader when we are called from a standard PXE request (the if not exists gpxe.bus-id) or a gPXE compatiable script when we are called from gPXE.&lt;br /&gt;&lt;br /&gt;We are currently using this setup to handle new server OS installations, hence the install.gpxe file.&lt;br /&gt;&lt;br /&gt;The contents of that file are rather simple.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;install.gpxe:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;#!gpxe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;kernel http://192.168.2.1/default/centos5 askmethod&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;initrd http://192.168.2.1/default/centos5.img&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;boot&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This loads the CentOS 5 PXE installation image and initrd to handle OS installation on the server.&lt;br /&gt;&lt;br /&gt;Once the server has its OS installed, we then need to add the server's MAC address to the DHCPd server so that it will chain load gPXE and then load the server's root disk via iSCSI.&lt;br /&gt;&lt;br /&gt;Here is how we accomplish that:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;/etc/dhcpd.conf (added in the subnet 192.168.2.0 section above):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;host server01 {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      hardware ethernet 00:xx:xx:xx:xx:xx;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      fixed-address 192.168.2.21;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      if not exists gpxe.bus-id {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;         filename "undionly.kpxe";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      } else {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;         filename "";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;         option root-path "iscsi:192.168.2.1::::iqn.2001-04.com.server:server01.vg00.lun0";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This, again, chainloads the gPXE chainloader from PXE, and on the next DHCP request from gPXE we provide the iSCSI target to load the root for the server. This brings up the normal GRUB screen and the system boots as normal.&lt;br /&gt;&lt;br /&gt;And that is how you turn your PXE enabled network card, into an iSCSI HBA.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Gotchas:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I had originally wanted to use gPXE/iSCSI to host the root drive for a Xen based Dom0, however I have discovered that the Xen hypervisor does not support this feature. I have done some searching on the internet and it seems that the problem does lie with Xen's hypervisor kernel and its inability to read the iBFT (Iscsi Boot Firmware Table). gPXE does support and utilize the iBFT, however the Xen Hypervisor kernel only recognizes the iBFT from certain iSCSI HBAs (listed in thier HCL).&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/7560733744304628420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=7560733744304628420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/7560733744304628420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/7560733744304628420'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2008/09/turn-your-pxe-enabled-network-card-into.html' title='Turn Your PXE Enabled Network Card Into an iSCSI HBA'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-4483783476387883495</id><published>2008-04-14T12:37:00.002-05:00</published><updated>2008-04-14T13:14:54.454-05:00</updated><title type='text'>Installing CentOS 5 as a DomU with a Debian Dom0</title><content type='html'>&lt;span style="font-family: arial;"&gt;There isn't a whole lot of information about how to setup CentOS as a DomU under a Debian 4.0 based Dom0 and still maintain the use of pygrub to boot the CentOS kernels. This howto will give you a general overview on what steps to take without having to use an incomplete CentOS image. This is not going to be a copy and paste sort of howto, but rather a more high level detail, and a couple of fixes to make it all work correctly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A couple of assumptions I am making here:&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;You have a working Xen install already under Debian&lt;/li&gt;&lt;li&gt;You can edit files using vi or a comparable editor.&lt;/li&gt;&lt;li&gt;You understand how Xen and LVM can work together at least at some basic level&lt;/li&gt;&lt;li&gt;You are confident to compile your own applications using make, etc...&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-family: arial;"&gt;Here is what you need to do to get started:&lt;br /&gt;&lt;br /&gt;Step 1:&lt;br /&gt;&lt;br /&gt;Download the kernel image and ram disk for CentOS and put them some place you can access them on the Dom0.&lt;br /&gt;&lt;br /&gt;In my case, I put them in /usr/local/src/xen/ (vmlinuz and initrd.gz respectively). I downloaded these files from a CentOS mirror. The files you are after are located in the centos/5.1/os/i386/images/xen/ directory as these contain the Xen code compiled into the kernel so that you can boot the DomU in paravirtualization mode.&lt;br /&gt;&lt;br /&gt;Step 2:&lt;br /&gt;&lt;br /&gt;Create a Xen DomU configuration file that points to these files for the boot kernel.&lt;br /&gt;&lt;br /&gt;I edited the two lines:&lt;br /&gt;&lt;br /&gt;kernel = "/usr/local/src/xen/vmlinuz"&lt;br /&gt;ramdisk = "/usr/local/src/xen/initrd.img"&lt;br /&gt;&lt;br /&gt;This tells Xen to use these kernels on boot up.&lt;br /&gt;&lt;br /&gt;Step 3:&lt;br /&gt;&lt;br /&gt;Modify your DomU config to point to your disks:&lt;br /&gt;&lt;br /&gt;disk = [ 'phy:/dev/xen01/centos5-disk,xvda,w', 'phy:/dev/xen01/centos5-swap,sda1,w']&lt;br /&gt;&lt;br /&gt;It is important to note that you must export the drives from the Dom0 as xvda, otherwise the CentOS installer will not be able to detect them properly and you will have no target drive to install to.&lt;br /&gt;&lt;br /&gt;We will also want to modify the default restart behavior as you will see later, this is important:&lt;br /&gt;&lt;br /&gt;on_reboot = 'destroy'&lt;br /&gt;&lt;br /&gt;Step 4:&lt;br /&gt;&lt;br /&gt;Go ahead and boot up the Xen DomU using xm create -c &lt;your&gt;&lt;br /&gt;&lt;br /&gt;Install CentOS as a normal network installation (point it at an FTP or HTTP mirror and let it install normally).&lt;br /&gt;&lt;br /&gt;Step 5:&lt;br /&gt;&lt;br /&gt;Once the CentOS installation is completed, the DomU will attempt to reboot itself. This is why we set the on_restart to destroy instead of the defautl of restart. We need to edit the configuration to boot up via pygrub instead:&lt;br /&gt;&lt;br /&gt;bootloader = "/usr/lib/xen-3.0.3-1/bin/pygrub"&lt;br /&gt;&lt;br /&gt;Step 6:&lt;br /&gt;&lt;br /&gt;Here is where things get a little tricky. The pygrub application is missing a library that it needs in order to boot up CentOS based kernels. We must build this ourselves.&lt;br /&gt;&lt;br /&gt;Download the xen-3.0.3 source (the new sources do not build this file, so I used this version specifically, I don't know if others will work). I know for a fact that xen-3.2.0 does not work.&lt;br /&gt;&lt;br /&gt;wget http://bits.xensource.com/oss-xen/release/3.0.3-0/src.tgz/xen-3.0.3_0-src.tgz&lt;br /&gt;&lt;br /&gt;Untar the file and cd into the directory xen-3.0.3_0-src&lt;br /&gt;&lt;br /&gt;Then:&lt;br /&gt;&lt;br /&gt;cd tools/pygrub&lt;br /&gt;&lt;br /&gt;Then you need to run make. Pay attention to the errors, you might need to install additional libraries if you don't have them on your Dom0. (e2fslibs-dev comes to mind).&lt;br /&gt;&lt;br /&gt;Step 7:&lt;br /&gt;&lt;br /&gt;Once your build has successfully completed, you will need to copy the files to your local xen installation.&lt;br /&gt;&lt;br /&gt;cd build/lib.linux-i686-2.4/grub/fsys/ext2&lt;br /&gt;mkdir /usr/lib/xen-3.0.3-1/lib/python/grub/fsys/ext2&lt;br /&gt;cp * /usr/lib/xen-3.0.3-1/lib/python/grub/fsys/ext2/&lt;br /&gt;&lt;br /&gt;Step 8:&lt;br /&gt;&lt;br /&gt;Boot your DomU using:&lt;br /&gt;&lt;br /&gt;xm create -c &lt;your&gt;&lt;br /&gt;&lt;br /&gt;Finished:&lt;br /&gt;&lt;br /&gt;You should now have a working Xen DomU under Dom0 without having to resort to broken CentOS images.&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/4483783476387883495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=4483783476387883495' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/4483783476387883495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/4483783476387883495'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2008/04/installing-centos-5-as-domu-with-debian.html' title='Installing CentOS 5 as a DomU with a Debian Dom0'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-3684698887901312867</id><published>2007-05-15T17:47:00.000-05:00</published><updated>2007-05-15T18:02:25.918-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='centos asus p5gc-mx'/><title type='text'>CentOS 4.4 and Asus P5GC-MX Motherboard</title><content type='html'>&lt;span style="font-family:arial;"&gt;I recently had to install CentOS 4.4 on the &lt;a href="http://www.asus.com/products.aspx?l1=3&amp;l2=11&amp;amp;amp;l3=498&amp;l4=0&amp;amp;model=1574&amp;modelmenu=1"&gt;Asus P5GC-MX motherboard&lt;/a&gt;. The board works very well with the installer as long as you aren't doing a network install as the network drivers are not available.&lt;br /&gt;&lt;br /&gt;Here is some information about the boards network controller, that was almost impossible to track down. The board uses a network chipset called the &lt;a href="http://www.attansic.com/english/products/index.html"&gt;Attansic L2&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;More specifically, you can compile the drivers from source files against the current kernel.&lt;br /&gt;&lt;br /&gt;I have included a copy of the driver for you to download if you need it. I searched through many mailing list postings to locate these file and I can confirm that it will compile against the kernel in CentOS 4.4.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.hostinggeek.com/l2-linux-driver-new.rar"&gt;l2-linux-driver-new.rar&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;In order to compile the kernel module you will need to install the kernel source for your current kernel version (yum install kernel-devel and kernel-smp-devel if you need it). You will also need to create a symbolic link from the source to /usr/src/linux as the kernel module looks at this location for the current kernel.&lt;br /&gt;&lt;br /&gt;Then you need to cd to the src directory in the archive and run make to compile the module.&lt;br /&gt;&lt;br /&gt;Once completed you can run insmod to install the module into the kernel.&lt;br /&gt;&lt;br /&gt;After you have done that, you will need to make sure you create module alias between the module and eth0.&lt;br /&gt;&lt;br /&gt;It is a little bit of a pain to get working, but it can be done.&lt;br /&gt;&lt;br /&gt;Good luck and I hope that the source files come in handy to somebody out there.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/3684698887901312867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=3684698887901312867' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/3684698887901312867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/3684698887901312867'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2007/05/centos-44-and-asus-p5gc-mx-motherboard.html' title='CentOS 4.4 and Asus P5GC-MX Motherboard'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-4137957190422391113</id><published>2007-04-27T18:57:00.000-05:00</published><updated>2007-04-27T19:10:33.488-05:00</updated><title type='text'>CentOS 4.4 and New nForce Chipsets</title><content type='html'>&lt;span style="font-family: arial;"&gt;CentOS is a great OS, and we use it for all our cPanel installs. It is getting a little old, but currently CentOS 5 isn't supported by cPanel, so we must continue to use CentOS 4.4 for these installs.&lt;br /&gt;&lt;br /&gt;The latest batch of motherboards we got in use the MCP61 (nForce 430 chipset). Luckily the SATA controller is supported using the nv_sata kernel module that comes with CentOS 4.4, so there is no need to upgrade that. However the network interface of this chipset is not recognized by the forcedeth driver (reverse engineered nForce network driver).&lt;br /&gt;&lt;br /&gt;The solution to fix this problem is to compile the latest forcedeth.ko (kernel module). Here is how you do it.&lt;br /&gt;&lt;br /&gt;1) Install CentOS and be sure to install gcc and kernel-devel for your kernel.&lt;br /&gt;2) Download the latest forcedeth drivers from nVidia. You can get them from here: &lt;a href="http://www.nvidia.com/object/linux_nforce_1.21.html"&gt;http://www.nvidia.com/object/linux_nforce_1.21.html&lt;/a&gt;&lt;br /&gt;3) Extract the files from the zip file.&lt;br /&gt;4) Change to the directory that contains the forcedeth.c source code. (./NV_Linux_DRV_PKG_v1.21/RHEL4_U4/source)&lt;br /&gt;5) Create a Makefile that contains:&lt;br /&gt;obj-m := forcedeth.o&lt;br /&gt;6) Now compile the module with the following command:&lt;br /&gt; make -C /usr/src/kernels/2.6.9-42.0.10.EL-i686/ SUBDIRS=$PWD modules&lt;br /&gt;&lt;br /&gt;Please note that your path might differ as you might be using a different version of the kernel.&lt;br /&gt;&lt;br /&gt;7) When this completes you will have a new forcedeth.ko file in the current directory. Move this file into modules directory:&lt;br /&gt;&lt;br /&gt;cp forcedeth.ko /lib/modules/2.6.9-42.0.10.EL/kernel/drivers/net/&lt;br /&gt;&lt;br /&gt;Again, your path might differ based on the version of the kernel you are running.&lt;br /&gt;&lt;br /&gt;8) Add an entry to alias the kernel module to your network interface in /etc/modprobe.conf&lt;br /&gt;alias eth0 forcedeth&lt;br /&gt;&lt;br /&gt;I threw a reboot at the machine just in case, but you can also do:&lt;br /&gt;&lt;br /&gt;modprobe forcedeth&lt;br /&gt;&lt;br /&gt;and your network card should now appear in:&lt;br /&gt;&lt;br /&gt;ifconfig -a&lt;br /&gt;&lt;br /&gt;And there you go...&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/4137957190422391113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=4137957190422391113' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/4137957190422391113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/4137957190422391113'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2007/04/centos-44-and-new-nforce-chipsets.html' title='CentOS 4.4 and New nForce Chipsets'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-3168710417447090088</id><published>2007-02-07T11:41:00.000-06:00</published><updated>2007-02-07T11:58:29.581-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Xen'/><category scheme='http://www.blogger.com/atom/ns#' term='XenExpress'/><title type='text'>XenExpress Makes Xen Easy</title><content type='html'>&lt;span style="font-family:arial;"&gt;As regular readers of this blog know (all two of you), I am a huge fan of Xen. It has never been easy to configure or install Xen, but that hasn't really stopped me from using it when ever I have had the chance.&lt;br /&gt;&lt;br /&gt;Well recently I was pointed to XenExpress, and XenExpress is about to make Xen a whole lot easier for the average user to install and use.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;XenExpress is an all in one ISO that you can download from the makers of Xen (for free). It is an ISO that you burn to a CD, and then boot a server off that CD to install Xen. While this isn't really that big of a deal, what it offers in management of Xen is where it truly shines.&lt;br /&gt;&lt;br /&gt;Once you have XenExpress installed on the server, you can then install the Windows Xen Admin interface and use that to monitor the Xen server, as well as create new Xen virtual machines. To say that it is easy is an understatement.&lt;br /&gt;&lt;br /&gt;Here is a screen shot of the admin interface at work:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.hostinggeek.com/uploaded_images/xenadmin-installing-win2k3-765954.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://www.hostinggeek.com/uploaded_images/xenadmin-installing-win2k3-764104.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In this picture I am in the process of installing Windows 2003 as a virtual machine, via the XenAdmin interface.&lt;br /&gt;&lt;br /&gt;Here are some of the monitoring features of the XenAdmin interface:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.hostinggeek.com/uploaded_images/xenadmin-monitoring-799982.png"&gt;&lt;img style="cursor: pointer;" src="http://www.hostinggeek.com/uploaded_images/xenadmin-monitoring-796776.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;XenExpress is about to make Xen a whole lot easier to use and manage.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/3168710417447090088/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=3168710417447090088' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/3168710417447090088'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/3168710417447090088'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2007/02/xenexpress-makes-xen-easy.html' title='XenExpress Makes Xen Easy'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-116770932394178324</id><published>2007-01-01T20:29:00.000-06:00</published><updated>2007-02-07T11:21:18.056-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rootkit'/><category scheme='http://www.blogger.com/atom/ns#' term='removal'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows 2003'/><title type='text'>How To Find and Remove Windows Rootkits</title><content type='html'>&lt;span style="font-family:arial;"&gt;First of all I want to wish everyone a very Happy New Year. It has been a while since I made my last posting and I want to apologize for that.&lt;br /&gt;&lt;br /&gt;Now let's get down to business...&lt;br /&gt;&lt;br /&gt;So recently we discovered that a Windows 2003 server had been exploited via an apparently well known 0day exploit in MailEnable's SMTP service. This has since been corrected by the MailEnable developers (&lt;a href="http://www.mailenable.com/hotfix/default.asp"&gt;you can read about that here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;At first there was some doubt as to whether or not there was a hacker on the server. Our first clue was the abnormal amount of traffic the server was doing. Typically this server moved about 100-200KBps per day. We knew something was up when this server started moving 2MBps. Upon inspection of the server we couldn't see anything out of the ordinary, however we did notice that taskman.exe (Task Manager) was running at 100% CPU utilization when ever we looked at it. This threw up all sorts of red flags to us, and we knew that we had a hacker on the server and we needed to find out what they were doing.&lt;br /&gt;&lt;br /&gt;I have to say that Event Viewer is your friend. You must look at it every once in a while to make sure you know what is going on. Even with a hacker on the server and rootkit installed on the server to hide his activity, he still wasn't able to hide some log entries in Event Viewer. After looking in Event Viewer we noticed several references to VMWare. After asking around, we determined that none of the legitimate administrators had installed VMWare and we knew that this must be the hacker.&lt;br /&gt;&lt;br /&gt;Here is how we found him, and how we removed him.&lt;br /&gt;&lt;br /&gt;We could see that there were some hidden directories on the server that we could access through the normal Explorer interface, so we knew we were dealing with an on boot rootkit. (You can see file accesses using the file system and disk tools from &lt;a href="http://www.microsoft.com/technet/sysinternals/default.mspx"&gt;Windows SysInternals Tools&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;We installed &lt;a href="http://www.hijackfree.com/en/"&gt;HiJack Free from a-squared&lt;/a&gt;. This piece of software is pretty powerful and does some deep inspections of the registry to find services and applications that are not normally visible in the Control Panel services listing. We sorted the services and looked for services that were set to start at boot up, and looked for anything that wasn't signed. Hi-Jack Free displays the company that signed the driver/service, and any service that was set to run, but wasn't signed was on our hit list to remove.&lt;br /&gt;&lt;br /&gt;With a list of services to disable, we installed the Windows Recovery Console and rebooted the server into the recovery console. We disabled the services that we identified as problems and rebooted the system normally.&lt;br /&gt;&lt;br /&gt;At this point we could see the directories that were hidden from us earlier. We discovered that the hacker had installed VMWare. Because we wanted to see what the hacker was actually doing with the VMWare installation, we used &lt;a href="http://chitchat.at.infoseek.co.jp/vmware/vdk.html"&gt;Virtual Disk Driver&lt;/a&gt; to mount the WMWare disk images to see what they were doing. Turns out they were downloading Pokemon episodes. Ugh... All that hassle and it wasn't even anything good. :)&lt;br /&gt;&lt;br /&gt;So we removed the rootkit from the server, removed the VMWare installation, and patched the MailEnable install, and the server has been cruising along ever since.&lt;br /&gt;&lt;br /&gt;We hope that this description of what we did will help you find and remove Windows rootkits on your servers.&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/116770932394178324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=116770932394178324' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/116770932394178324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/116770932394178324'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2007/01/how-to-find-and-remove-windows.html' title='How To Find and Remove Windows Rootkits'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-115920984266673527</id><published>2006-09-25T12:21:00.000-05:00</published><updated>2006-09-26T11:41:18.546-05:00</updated><title type='text'>Find Out What Your DNS Server is Doing</title><content type='html'>&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;What is my DNS server responding to?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have been in the process of moving from an old server to a newer server. The process is straight forward, we move the sites over to the new server and then update their zone records to point at the new server (the zone has a low TTL - Time To Live to make this transition smoother). Overall everything has gone smoothly with little interuption in the service of each site.&lt;br /&gt;&lt;br /&gt;Finally once everything was moved over, we updated the nameserver records to point at the new server so now everything should be running off the new server's DNS. We are ready to turn off the old server, but noticed that named (bind) was still handing out DNS responses (based on its activity in top). We thought we had everything updated so that this server shouldn't be used at all.&lt;br /&gt;&lt;br /&gt;So we had to find out what DNS requests were still hitting the old server and why we missed those. Here is what we did to find out.&lt;br /&gt;&lt;br /&gt;Edit your named.conf (ours was in /etc).&lt;br /&gt;&lt;br /&gt;Add the following section if you do not already have a section called logging {}.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;logging {&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;     channel query_logging {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;          syslog daemon;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;          severity debug 9;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;     };&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;     category queries {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;          query_logging;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;     };&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;What this does it record any DNS query named serves up in the default syslog for named (generally /var/log/messages). This will help you see what domains are being requested from your server.&lt;br /&gt;&lt;br /&gt;We determined what DNS queries were coming in, and based on the whois information found out that there were some very old nameserver records pointing at the server's IP. Without the logging change above, we could have lost 3 or 4 long time customer's DNS information when the old server was turned off. As it is now we have updated those nameserver records to point at the new nameservers, and will need to keep the old server up and running for at least another 48 hours (the amount of time a root nameserver record is cached). Saved us a black eye for sure.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What else is my DNS server handing out?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Additionally, you might want to look at the log information and determine if anybody is using your server for recursive lookups too.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:arial;"&gt;What is DNS recursion?&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;Well, recursion itself isn't bad, and actually a vital part of DNS. Recursion means that if you request a DNS lookup against a DNS server, and that server isn't authoritative for that domain (it doesn't have a zone for that domain), it must pass the DNS request to another server.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Why is it bad to allow recursion?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Until recently DNS recursion wasn't really a bad thing, but hackers have determined that it is possible to "amplify" or magnify their DDoS (Distributed Denial of Service) attacks using spoofed UDP based DNS requests. (UDP is extremely easy to spoof the originating IP address of the request.) The hackers send a spoofed UDP request for a given domain with a large number of records to a DNS server that allows recursive lookups. Since the initial UDP request is realtively small, and the response (because it has so many records in it) is very large, hackers can amplify the amount of data they can send at a target using recursive third party DNS servers.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How do I turn off recursion in named/bind?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To turn off recursive lookups from unauthorized sources you can add the follownig ACL to your named.conf:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;acl recursion { 127.0.0.1; 1.2.3.4/24; };&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And then in your options do:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;options {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;     allow-recursion { "recursion"; };&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The first line creates an ACL (Access Control List) to let named (bind) know who is allowed to do recursive lookups against the server. The IP's should be listed in CIDR notation, and be followed by a semicolon. Include any IP address that uses this server for legitimate DNS lookup purposes.&lt;br /&gt;&lt;br /&gt;The second section should already exist in your named.conf, and you just want to add the allow-recursion line to that section. This will apply the ACL to your server. Then you just need to restart named, and you are good to go.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;So that is why you should know exactly what your DNS server is doing.&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/115920984266673527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=115920984266673527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115920984266673527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115920984266673527'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/09/find-out-what-your-dns-server-is-doing.html' title='Find Out What Your DNS Server is Doing'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-115825527741503193</id><published>2006-09-14T11:29:00.000-05:00</published><updated>2006-09-14T12:41:52.390-05:00</updated><title type='text'>How To Install NetBSD as a DomU in Xen 3.0</title><content type='html'>&lt;span style="font-family:arial;"&gt;Ever since the first time I heard about Xen and its ability to run any OS side by side on the same server I have had the urge to run a BSD based OS with a Linux OS. Today I have sucessfully achieved my goal, and this is how I did it.&lt;br /&gt;&lt;br /&gt;First some background on the server itself. The server is a Dell PowerEdge 1750 with Dual Xeon processors and 3GB of RAM and 500GB of RAID storage. The server is running the Xen 3.0.2 hypervisor kernel (the main kernel that handles the paralization, or virtualization, of the hardware). The Dom0 system is running Debian 3.1 with some patches to the kernel to work with the LSI based RAID 5 card in the server. Each virtual OS installed on the server is given its own partition and is managed using LVM in Dom0.&lt;br /&gt;&lt;br /&gt;The vast majority of information about NetBSD running under Xen as a DomU seems to be either Xen 2.0 specific, or assumes you are running NetBSD as Dom0. Unfortunetly, the Xen 2.0 information is no going to work on a Xen 3.0 machine, and more so our Dom0 is Debian, so we needed to come up with our own.&lt;br /&gt;&lt;br /&gt;Here is how I did it, and what sort of problems I encountered.&lt;br /&gt;&lt;br /&gt;The entire process is pretty easy, but finding the actual information can be tough, and finding the files you need can be even tougher. Here is kind of a rough over view of the process...&lt;br /&gt;&lt;br /&gt;1) Set up your partition that will hold NetBSD. We are using a LVM partition named vg00-netbsd.&lt;br /&gt;2) Set up the xen domU config file.&lt;br /&gt;3) Boot the netbsd install kernel for Xen 3.0.&lt;br /&gt;4) Follow the sysinstall steps like you normally do to install NetBSD. I had to use an FTP based installation, because I could never get the CDROM to work correctly.&lt;br /&gt;5) Complete the install and shutdown NetBSD.&lt;br /&gt;6) Edit the domU config file and change the kernel from the install kernel to the normal NetBSD kernel.&lt;br /&gt;7) Boot NetBSD DomU and enjoy.&lt;br /&gt;&lt;br /&gt;So here are the specifics.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1:&lt;/span&gt; You need to download the NetBSD Xen 3.0 kernels (install and normal) and put them some place on your Dom0. I put mine in the /boot of the server, because it sort of made sense to me, but they can be almost anywhere. You can download the DomU kernels from NetBSD's FTP servers from the daily build areas. The kernels for Xen 3.0 are not in the release versions of NetBSD so you have to find them. I would post links to them, but most likely the would go stale over time. Go to ftp://ftp.netbsd.org/pub/NetBSD-daily/ and navigate through to either the NetBSD 3.1 tree or the NetBSD 4.0 tree. You are looking for the directory i386/binary/kernel/ in that directory you will find the two kernels you need. The install kernel is called &lt;/span&gt;&lt;a style="font-family: arial;" href="ftp://ftp.netbsd.org/pub/NetBSD-daily/netbsd-4/200609100000Z/i386/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz"&gt;netbsd-INSTALL_XEN3_DOMU.gz&lt;/a&gt;&lt;span style="font-family:arial;"&gt; and the normal kernel is named &lt;/span&gt;&lt;a style="font-family: arial;" href="ftp://ftp.netbsd.org/pub/NetBSD-daily/netbsd-4/200609100000Z/i386/binary/kernel/netbsd-XEN3_DOMU.gz"&gt;netbsd-XEN3_DOMU.gz&lt;/a&gt;&lt;span style="font-family:arial;"&gt;. Download both of those kernels as you will need them later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2:&lt;/span&gt; Once you have downloaded your kernels you will need to create a xen config file for your NetBSD DomU. Here is an example of the one I used:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;kernel = "/boot/netbsd-INSTALL_XEN3_DOMU.gz"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;memory = 128&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;name = "netbsd"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;vif = [ '' ]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;disk = [ 'phy:/dev/mapper/vg00-netbsd,0x01,w' ]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;root = "/dev/wd0d"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You will need to change the disk = line to match where you are installing NetBSD to on your server. After you have created that file in your xen config directory (our was /etc/xen/).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3:&lt;/span&gt; We are ready to boot NetBSD for the first time. To boot NetBSD we run the command:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;xm create -c netbsd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;"netbsd" is the name of the DomU config file we created in step 2, so change that to match what you used in that step.&lt;br /&gt;&lt;br /&gt;A couple of times we noticed that Xen didn't attach us to the console of the booting NetBSD DomU, so you may need to connect to it manually. To do so do the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;xm list&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which will print out a list of running Xen instances like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Name                              ID Mem(MiB) VCPUs State  Time(s)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;debian                             0     1374     4 r-----  2354.5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;plesk                             10     1024     1 -b----   161.5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;netbsd                            50      128     1 -b----     1.2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;qmail                              8      128     1 -b----   953.4&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We will need to know the ID of the instance we want to attach to. In the example above this is 50. Then we attach to the console of that DomU by typing:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;xm console 50&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To break out of the console at any time simple press CTRL+] at the same time.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 4:&lt;/span&gt; Once you are in the console you should see the sysinstall application. You can follwo the prompts and install NetBSD like you would normally do. One problem I did encounter was that for what ever reason the server would stop talking to the FTP server due to some sort of DNS lookup failure. It did this no matter which kernel I tried. I eventually resorted to using the IP address instead, and the installation worked perfectly.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 5:&lt;/span&gt; Once the install is completed, break out of the server and shut it down via the command:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;xm shutdown 50&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Again replace 50 with the ID of the DomU of your NetBSD install.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 6:&lt;/span&gt; Edit the DomU file and change the kernel line to point to your normal NetBSD kernel. So your DomU config file should look somethnig like this now:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:courier new;"&gt;kernel = "/boot/netbsd-XEN3_DOMU.gz"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;memory = 128&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;name = "netbsd"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;vif = [ '' ]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;disk = [ 'phy:/dev/mapper/vg00-netbsd,0x01,w' ]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;root = "/dev/wd0d"&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;Step 7:&lt;/span&gt; Reboot your NetBSD DomU via the command:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;xm create -c netbsd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Enjoy your NetBSD running under a Debian/Linux Dom0 in Xen 3.0!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Gotchas:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Having used the NetBSD system only breifly I have noticed that there is something "funky" with the networking and the way it behaves. I noticed over a sustained ping that the network interface starts to drop packets, every other packet it seems. Modifying the vif = line in the DomU config to read:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;vif = [ 'bridge=xenbr0' ]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;seems to have cleared up the issue. This line bridges the ethernet interface inside the DomU to the xenbr0 interface in the Dom0. It seems to have cleared up the issue to date.&lt;br /&gt;&lt;br /&gt;And there you have it! NetBSD running under a Linux Dom0 on top of Xen 3.0. The world just got a whole lot smaller.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a style="font-family: arial;" href="ftp://ftp.netbsd.org/pub/NetBSD-daily/netbsd-4/200609100000Z/i386/binary/kernel/netbsd-XEN3_DOMU.gz"&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/115825527741503193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=115825527741503193' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115825527741503193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115825527741503193'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/09/how-to-install-netbsd-as-domu-in-xen.html' title='How To Install NetBSD as a DomU in Xen 3.0'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-115704586199970131</id><published>2006-08-31T12:10:00.000-05:00</published><updated>2006-09-14T12:43:43.603-05:00</updated><title type='text'>Why You Shouldn't Use Fedora Core For Production Servers</title><content type='html'>&lt;span style="font-family:arial;"&gt;I am going to vent a little here.&lt;br /&gt;&lt;br /&gt;I don't understand why web hosting companies (and dedicated server providers for that matter) continue to provide Fedora Core based servers to customers. It just doesn't make sense. Fedora Core was never intended to be used in a production enviroment and why people keep using in those enviroments baffles me.&lt;br /&gt;&lt;br /&gt;We had a server that was running Fedora Core 4 and cPanel and has been in production for almost a year. It was always updated and properly maintained... that is until RedHat dropped updates for it (which they do every 6 months as that is the development cycle for Fedora). Dropping updates isn't that big of a deal as there is the Fedora Legacy Project that continues to provide updates after RedHat has dropped updates.&lt;br /&gt;&lt;br /&gt;Here is what happened with this server, Fedora Core 4 was dropped from RedHat support, and was being taken over by Fedora Legacy. No big deal, this has happened a bunch of times in the past with previous Fedora Core versions. The problem enters when you throw in a local kernel exploit that is discovered for the /proc fs. We attempted to upgrade this kernel to prevent this problem, but because FC4 was in a state of transition between the two providers, the updates weren't available yet. As such this server was put into the "holding for update" queue.&lt;br /&gt;&lt;br /&gt;In that time the server was hacked and needed to be wiped and reinstalled with another OS that won't cause this particular problem (CentOS 4.3).&lt;br /&gt;&lt;br /&gt;What we recommend to customers instead of Fedora Core?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CentOS:&lt;/span&gt; RedHat Enterprise Linux based OS. They grab the source RPM files from RedHat and remove the images that reference RedHat and replace them with CentOS based images, and other minor modifications, but generally this is the same code that is used to run RedHat Enterprise Linux. Because it is based on RHEL it has a good development cycle as well as excellent support for new drivers. Does it have it's problems? Yes, any problem that exists in RHEL will also exist in CentOS (various spin_lock kernel panic issues have been documented).&lt;br /&gt;&lt;br /&gt;We recommend the use of CentOS for any application that does not support our number one OS of choice.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Debian (stable):&lt;/span&gt; I admit it. I am a big fan of Debian. It works great and I am very familair with it. It handles in place version upgrades (moving from woody to sarge was done with minimal effort using apt-get dist-upgrade). It has an easy to use package manager, with a large selection of applications, as well as an active developer community. My biggest problem with Debian is the that the kernel gets out of date very quickly. Unlike CentOS which actually backports drivers from a more current kernel revision (for instance 2.6.16) into the current standardized kernel for the OS (2.6.9 for CentOS 4.3), Debian does not do that. So it is often a chore to get Debian to run (or even install) on newer chipsets.&lt;br /&gt;&lt;br /&gt;Overall, Debian is the winner for us. We install it anytime we have the option (even for Virtual Private Servers) as it just works. It has its faults and is by no means perfect, but we are willing to over look those as they are minor in comparison to the benefits it can provide in ease of management and administration.&lt;br /&gt;&lt;br /&gt;So to recap:&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Don't use Fedora Core for a production server, it will only cause you pain and suffering in the long run.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;Anyone that suggests you use Fedora Core in a production enviroment has not analyised the potential ramifications of that decision completely.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;There are many viable alternatives that are actively developed and maintained as well as providing up to date and current device driver support and security updates.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:arial;"&gt;In conclusion:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Don't use Fedora Core on a production machine.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/115704586199970131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=115704586199970131' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115704586199970131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115704586199970131'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/08/why-you-shouldnt-use-fedora-core-for.html' title='Why You Shouldn&apos;t Use Fedora Core For Production Servers'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-115376082006149950</id><published>2006-07-24T11:05:00.000-05:00</published><updated>2006-07-24T12:07:00.116-05:00</updated><title type='text'>Steps to Tighten PHP Security</title><content type='html'>&lt;span style="font-family: arial;"&gt;Recently I have had to deal with some insecure PHP scripts on a couple of servers that have caused us some serious problems, as well as time, to recover from.&lt;br /&gt;&lt;br /&gt;I am going to list some of the important steps you can take to protect your server and your site from insecure PHP applications. This will by no means a complete list of items to stop them, but this should help prevent most of the basic attacks ("script kiddie" attacks - where the attacker doesn't have a great deal of skill and is depending on a preset scenario).&lt;br /&gt;&lt;br /&gt;Most of these solutions will assume you have some level of control (root) over the server.&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;Turn off allow_url_fopen: This modification will prevent the use of http://www.domain.com/somescript.php and ftp://www.domain.com/somescript.php from being used in include(), include_once(), require(), require_once(), as well as fopen(). This will prevent a hacker from including malicious code remotely. This modification will prevent the vast majority of hack attempts in PHP from working.&lt;br /&gt;&lt;br /&gt;The downside of this modification is that some legitmate applications that use fopen() to open a remote web page might be broken. You can encourage users to use the PHP curl functions instead as they accomplish the same results.&lt;br /&gt;&lt;br /&gt;Edit your php.ini and change allow_url_fopen = On to allow_url_fopen = Off and restart your web server.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;Use open_basedir: open_basedir allows you to dictate which paths PHP is allowed to access for a given site. Generally we set this to the path of the website (/var/www/html), /tmp (for writting session data as well as for file uploads), and the path to the PEAR repository.&lt;br /&gt;&lt;br /&gt;The good thing about open_basedir is that it is default deny, meaning if you don't specify the path in the open_basedir it is blocked.&lt;br /&gt;&lt;br /&gt;The bad part about open_basedir is that it come sometimes block access to legitmate applications needed by your PHP applications (Gallery is one that comes to mind, as it makes use of some external applications in /usr/bin, so you must open access to that location).&lt;br /&gt;&lt;br /&gt;Generally, you should use this directive for every website you host as it allows you to control which directories PHP can access and you can make sure that those directories have the correct permissions to prevent potential exploitation.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;Mount /tmp noexec, nosuid and nodev: This one is particularly useful as it allows you to tell the operating system not to run any applications in a given area of the hard drive. I can tell you personally that this one as saved me numerous times. When used in combintation with the open_basedir directive you can effectively limit what the hackers have access to, and what they are able to run.&lt;br /&gt;&lt;br /&gt;If you have a seperate /tmp partition on your hard drive you can edit the /etc/fstab file and change the options for the /tmp line.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;/dev/hda3   /tmp        ext3    noexec,nosuid,nodev    0   0&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;If you don't have a seperate /tmp partition you can create one as a loopback filesystem and mount that as noexec. I will make a seperate post on how to do this later.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: arial;"&gt;Mount your web space noexec: This might not be possible, but is a great option just like mounting /tmp in noexec. The reason for this is to prevent binary applications from being uploaded and executed in your webspace. Like I said this might not be possible, but is an excellent prevention method to prevent local root exploit binaries (where a binary exploits a problem in the kernel to gain escallated priviledges on the server, the /proc race in the 2.6 kernel is a recent example of this type of exploit).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: arial;"&gt;Make sure your permissions are correct: You should not allow world write permissions on any files, other than those required (configuration files that are written by the web server, etc). This is very important as it will save you a great deal of trouble in the event that a hacker does gain access to your site, as they won't be able to overwrite your files. Additionally, you should only allow write access to specific folders where needed.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: arial;"&gt;Prevent PHP from parsing scripts in world writtable directories: This will prevent hackers from uploading malicious scripts and running them from your site. This is a great way to tighten security, and is pretty easy to manage, just set "php_admin_flag engine off" for any directory that can be written to by the web server user. This one will save you more hassle than you can ever imagine.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: arial;"&gt;Install mod_security: Mod Security is basically a web server firewall, allowing you to block specific types of requests, as well as inspect data as it is sent to the server. My only problem with mod_security is that it isn't default deny, which means you must identify what is blocked, rather than identifying what is allowed and rejecting everything else. Still it has its uses and you should have it installed in order to react to problems that do not have patches available yet.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: arial;"&gt;We hope that this list of items will help protect your server from hackers and allow you to have some peace of mind that your sites are as secure as you can make them.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/115376082006149950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=115376082006149950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115376082006149950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/115376082006149950'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/07/steps-to-tighten-php-security.html' title='Steps to Tighten PHP Security'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-114982063087591980</id><published>2006-06-08T21:14:00.000-05:00</published><updated>2006-06-08T21:38:00.713-05:00</updated><title type='text'>Linux Things I Learned Today</title><content type='html'>&lt;span style="font-family:arial;"&gt;What fun things did I learn today? Let me see...&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li style="font-family: arial;"&gt;Intel based ICH7 chipsets are not fully supported in the linux kernel until kernel version 2.6.11. With additional features added in 2.6.15.&lt;/li&gt;&lt;li style="font-family: arial;"&gt;The Debian Installer is based on the 2.6.8 kernel, and therefore can not install on to hard drives attached to the ICH7 chipset (at least in SATA2 mode, which is the whole point).&lt;/li&gt;&lt;li style="font-family: arial;"&gt;The northbridge chipset on the MSI 945GM2 motherboard is OMG HOT! (I have the burn marks to prove it.)&lt;/li&gt;&lt;li style="font-family: arial;"&gt;Motherbards are moving to a new auxillary power connector (in addition to the ATXv2.0 spec). This new connector is called an EPS12V connector and consists of an 8 pin connector for 12V power to the CPUs.&lt;/li&gt;&lt;li style="font-family: arial;"&gt;The EPS12V power connector seems to be standard on most "Cedar Mill" (Intel's new 65nm fab CPUs) "Ready" motherboards. Where as most power supplies do not yet have this connector.&lt;/li&gt;&lt;li style="font-family: arial;"&gt;The case I buy do not have the EPS12V connector on them - which made me sad.&lt;/li&gt;&lt;li style="font-family: arial;"&gt;The standard 4 pin 12V connector that is standard now on most power supplies DOES work in the EPS12V plug - which make me happy.&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;SATA2 (SATA 3.0Gbps) can be used in "comptability mode" in the BIOS, but it makes them SLOW.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:arial;"&gt;The default kernel installed with Debian doesn't support over 1GB of RAM. You must install another kernel if you have more than 1GB of RAM.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family:arial;"&gt;I think that about covers what I ran into today. Just some random facts that might help somebody some day.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/114982063087591980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=114982063087591980' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114982063087591980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114982063087591980'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/06/linux-things-i-learned-today.html' title='Linux Things I Learned Today'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-114858862629613123</id><published>2006-05-25T14:36:00.000-05:00</published><updated>2006-05-25T15:23:46.363-05:00</updated><title type='text'>Moving Servers Realtively Painlessly</title><content type='html'>&lt;span style="font-family: arial;"&gt;Let's face it, moving from one server to another server is nasty and something any of us would try to avoid as often as we can. Unfortunetly, there are instances where we can not avoid this and we must bite the bullet and do it.&lt;br /&gt;&lt;br /&gt;Here are some tips that I have gathered up that will help you maintain your sanity as much as possible. Honestly even with all the planning and preperation, there will be issues so just prepare yourself mentally for that. &lt;span style="font-weight: bold;"&gt;It will happen&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;So here are some things you can do to help the transition:&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;DNS Caching: DNS has to be one of the most difficult things to deal with, because you only have a certain level of control over what occurs. Caching of DNS results will often cause many problems. The trick here is to plan ahead and remove the caching from the picture until the move is completed.&lt;br /&gt;&lt;br /&gt;Setting your DNS to a low TTL (I use 5 seconds versus the recommended 86400 seconds/ 24 hours). The TTL tells other DNS servers and clients how long they should hold the information they just received, in their cache. Since we are going to be moving the site to a new IP soon, we don't want them caching the old IP once the site is on the new IP. The low TTL will help prevent this.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;Pathing: If you are moving to a server with different paths, you should at least try to setup symbolic links to help any hard coded paths in the site's content.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;PHP register_globals: This one has bitten me a couple of times. Most ofthen when you move to a new server the server will have the default settings for PHP which turns off register_globals. This will cause all sorts of problems that you won't be able to track down easily. Check it early on and make sure that both servers match settings wise. (A a general rule register_globals should be set to off, but there are some legacy PHP apps that need it.)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;SSH Tunnels: Most of the time you should adjust your TTL for your DNS long before you do the actual move, but sometimes that isn't an option. In a pinch you can use an SSL tunnel to redirect traffic from your old server to the new server. This will help users that have the old IP cached, still access the new site. It should be noted that SSH tunnels are pretty unstable and shouldn't be really be depended on, but like I said, they are good in a pinch. Here is an example of one, you run this on the old server as root with the httpd process stopped:&lt;br /&gt;&lt;br /&gt;ssh -g -C -N -f -L 80:newserverip:80 root@newserverip&lt;br /&gt;&lt;br /&gt;This will prompt you for a password (if you don't have key based access already setup). You will get a warning 'bind: Address already in use', but the process is working. This message is just letting you know that the remote endof the tunnel has something already on port 80, which is actually a good thing.&lt;br /&gt;&lt;br /&gt;You can read more about this process in my blog post &lt;a href="http://www.hostinggeek.com/2005/08/redirecting-tcp-ports-with-ssh.html"&gt;Redirecting TCP Ports with SSH&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;DNS: Once you have everything moved over to the new server, update the current authoritative DNS servers with the new IP as soon as possible. Once you have done that change the domains name server records also. The name server change takes longer to complete (will normally be done in 8 hours at the root servers).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;How To Deal With a Highly Dynamic Website: For sites that have alot of content, or for sites that have users contributing data often (mainly forums) you need to draw a line in the sand and take the site offline during the move. This ensures that you have all the content and that no one loses any content that was contributed during the move.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: arial;"&gt;&lt;a href="http://rsync.samba.org/"&gt;Rsync&lt;/a&gt;: Also in the same vein as dynamic sites (user images etc) rsync is your best friend. Run rsync, and run it often. Run it even before you move. It keeps the two sites in sync with each other and can be run while the old site is still up and running. The more you run rsync leading up to the actual move, the faster the actual move will occur. Faster move == less downtime for your users.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: arial;"&gt;There are many other issues to consider, but if you take these items into consideration you should not have any major surprises coming your way.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/114858862629613123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=114858862629613123' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114858862629613123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114858862629613123'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/05/moving-servers-realtively-painlessly.html' title='Moving Servers Realtively Painlessly'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-114425361659994885</id><published>2006-04-05T10:55:00.000-05:00</published><updated>2006-04-05T11:41:13.143-05:00</updated><title type='text'>Apple Boot Camp, Windows XP and Xen Sitting in a Tree</title><content type='html'>&lt;span style="font-family:verdana;"&gt;So today I came across this site for &lt;a href="http://www.apple.com/macosx/bootcamp/"&gt;Apple's Boot Camp&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Basically the concept behind Apple's Boot Camp is to allow users to install Windows XP side by side with MacOSX, which many people have been trying to do since the first Mac's shipped with Intel based processors.&lt;br /&gt;&lt;br /&gt;So now it is possible to run Windows XP on a Mac with Apple's blessings.&lt;br /&gt;&lt;br /&gt;Here is where things get interesting: Throw Xen 3.0 into the mix. For those that don't know what Xen is, it is a hardware virtualization technolgoy (based ont he linux kernel) that allows multiple OS'es to run on the same hardware at the same time. It allows concurrent access to the network, hard drives, memory, cpu etc. Prior to Xen 3.0 you needed to have an OS specifically compiled for Xen in order to run it. That has all changed with the new technology included in the latest processors from Intel  (and soon AMD - June 2006 I think). The new processors have a technolgoy called Virtualization that allows hardware virtualization applications like Xen (and VMWare) to run OS'es that are not compiled natively for Xen itself (such as OSX and Windows XP).&lt;br /&gt;&lt;br /&gt;This is where I think there is a huge opportunity for Apple (and for all I know they might actually be working on this already, I haven't a clue). To allow Xen to boot OSX as a Xen Dom0 (the OS that is allowed access to the Xen kernel for control over the other OS'es on the virtualized machine). Then boot Windows XP as a DomU. Then a user would be able to boot their computer, access OSX and switch to Windows XP all in one machine.&lt;br /&gt;&lt;br /&gt;An interesting thought... If you can get both OS'es to boot at turn on, and used OSX as the Dom0, then you would be able to access the Windows XP virtual machine via the Mac OSX RDP (Remote Desktop Protocol) client and never have to actually leave OSX or figure out how to switch between the two. Oh man... my head spins... I need to get a MacBook Pro and start working on that.&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/114425361659994885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=114425361659994885' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114425361659994885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114425361659994885'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/04/apple-boot-camp-windows-xp-and-xen.html' title='Apple Boot Camp, Windows XP and Xen Sitting in a Tree'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-114179615298089461</id><published>2006-03-07T20:43:00.000-06:00</published><updated>2006-03-07T23:35:53.023-06:00</updated><title type='text'>exit signal File size limit exceeded (25) in Apache</title><content type='html'>&lt;span style="font-family: verdana;"&gt;Today was a fun day. I have a buddy that has spent the last 3 or 4 months (maybe longer) working on a complete ground up redesign of a PHP/MySQL website. The current code base was horrid, and that is putting it lightly. The code was so poor that it was hampering the overall performance of the server. The pages were very slow to display, often taking 30-45 seconds to complete the rendering of one page. Looking at the top process list I could see that several httpd processes were dying off, and dying off frequently. I had assumed that this was due to the poor codebase of the existing application.&lt;br /&gt;&lt;br /&gt;The launched the new codebase today, and things didn't improve. So my buddy called on me to help him out. First a little bit of background on the server: Dual Athlon (yes it was weird to me too), 1GB of RAM, and 1 IDE HD (again, yes I know who ever speced out this server should have their head examined). Server is running Cpanel 10.8.1-C112 under Fedora Core 2. We had rebuilt apache already (using easyapache) and the httpd zombies kept occuring. They weren't true zombies, only momentary zombies, because the child process was dying without permission from the parent process, so they only showed up in the zombie count for a couple of seconds, so they were being cleaned up properly.&lt;br /&gt;&lt;br /&gt;Here is what we found: the main site for the server is a heavily trafficed PHP/MySQL based site with a lot of images. I started looking through the error logs and came across a bunch of messages like:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[notice] child pid 10009 exit signal File size limit exceeded (25)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After some quick googling we were able to determine that this message means that the child httpd process died, because it encountered a file that is too large for it to handle. The max file size is 2GB in this instance. There is some discussion on if this is an Apache 1.3.x limitation or a limitation a little further down (glibc or filesystem).&lt;br /&gt;&lt;br /&gt;How did we fix it? Well short term was to shutdown apache and move the offending log file out of the way, and restart apache. Longer term fixes involve some settings inside Cpanel itself. You basically need to tell Cpanel to remove the log files after it has processed the log files.&lt;br /&gt;&lt;br /&gt;Log in to WHM and click on "Tweak Settings", then check mark &lt;/span&gt;"Delete each domain's access logs after stats run"&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;&lt;span style="font-family: verdana;"&gt;That will delete the log files daily, and all should be well with the world.&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/114179615298089461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=114179615298089461' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114179615298089461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/114179615298089461'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/03/exit-signal-file-size-limit-exceeded.html' title='exit signal File size limit exceeded (25) in Apache'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-113977899159361367</id><published>2006-02-12T15:02:00.000-06:00</published><updated>2006-02-12T15:16:31.620-06:00</updated><title type='text'>Missing /proc/megaraid</title><content type='html'>&lt;span style="font-family:arial;"&gt;Recently I did a Xen 3.0 install on a Dell 1750 server with RAID5. By default the Xen 3.0 installation (from source) doesn't compile in the LSI drivers for the RAID card, so I had to enable the option in the Dom0 kernel in Xen.&lt;br /&gt;&lt;br /&gt;So I went in to the xen0 directory under my Xen source (/usr/src/xen-3.0.0/linux2.6.12-xen0) and ran:&lt;br /&gt;&lt;br /&gt;make ARCH=xen menuconfig&lt;br /&gt;&lt;br /&gt;I then went to Device Drivers -&gt; SCSI Device Support -&gt; SCSI low-level drivers -&gt; and enabled the "LSI Logic New Generation RAID Device Drivers", because after all... Newer is better right?&lt;br /&gt;&lt;br /&gt;I recompiled Xen and the Xen kernels (cd ../; make kernels; make install) and reboot the machine and went on with my day.&lt;br /&gt;&lt;br /&gt;I got a call from the client later in the day that the server was reporting a problem with the RAID array. Long stroy short, the customer was running a NAGIOS plugin to monitor the RAID array via the /proc/megaraid entry. Little did I know that the new generation RAID device drivers in the 2.6 kernel no longer make use of the /proc/megaraid proc entry, so it was breaking the NAGIOS plugin.&lt;br /&gt;&lt;br /&gt;To correct this problem use the "LSI Logic Legacy MegaRAID driver" instead of the "LSI Logic New Generation RAID Device Drivers" in the 2.6 kernel (this is not an option in the 2.4 kernel). That will give you back the /proc/megaraid entry and you should be all set.&lt;br /&gt;&lt;br /&gt;Additionally, since you are already compiling a kernel, you should enable the kernel option "Use register arguments" under "X86 Processor Configuration". This option will allow you to use the Dell OMSA device drivers for additional control over your Dell PowerEdge server. You can read more about it here: &lt;a href="http://www.uta.fi/%7Epauli.borodulin/dellomsa/omsa44.html"&gt;http://www.uta.fi/~pauli.borodulin/dellomsa/omsa44.html&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/113977899159361367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=113977899159361367' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113977899159361367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113977899159361367'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/02/missing-procmegaraid.html' title='Missing /proc/megaraid'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-113917711622166213</id><published>2006-02-05T15:25:00.000-06:00</published><updated>2006-02-05T16:05:16.306-06:00</updated><title type='text'>Logs at a Glance</title><content type='html'>&lt;span style="font-family: verdana;"&gt;I have many servers that I have to watch on a regular basis. We use a KVM to switch between the consoles of the servers and generally we only see the console for any given server for a couple of seconds.&lt;br /&gt;&lt;br /&gt;The KVM we use has this great feature where if it detects any activity on the console, the KVM will swtich to that console and display the output for us.&lt;br /&gt;&lt;br /&gt;This is how we use that functionality to quickly display any problems a server might be having. It is by no means a fool proof and accruate, but it does help to bring things to our attention on a regular basis, doesn't require you to install anything special (all programs should come with a basic install of a linux OS), and its cool... What else do you really need?&lt;br /&gt;&lt;br /&gt;What we do is one turn off the console's screen saver. It is evil, and we don't like it. Actually it serves a valid purpose, but not for our needs so lets turn it off:&lt;br /&gt;&lt;br /&gt;/usr/bin/setterm -blank 0&lt;br /&gt;&lt;br /&gt;Now you can put that into /etc/rc.local for RedHat based distros (Fedora, Redhat Enterprise Linux, CentOS, etc).&lt;br /&gt;&lt;br /&gt;For Debian you can create a file in /etc/init.d/ and name it blank_screen and chmod 755 the file. Then just create a symbolic link to the startup dir:&lt;br /&gt;&lt;br /&gt;ln -s /etc/init.d/screen_blank /etc/rcS.d/S61blank_screen&lt;br /&gt;&lt;br /&gt;Now that we have the console set not to turn off, we can do the next part of our monitoring mojo. We will setup to monitor files that are important to us, such as /var/log/messages, and /var/log/syslog. These files might not be the files you want to monitor, so you can modify the line below to match the files of your choosing.&lt;br /&gt;&lt;br /&gt;We use tail, because it displays the lines as they are added to the file we are monitoring, and it is simple and lightweight.&lt;br /&gt;&lt;br /&gt;/usr/bin/tail -v --follow=name /var/log/messages --follow=name /var/log/syslog &gt; /dev/tty2&lt;br /&gt;&lt;br /&gt;What this does is runs tail to monitor the files /var/log/messages and /var/log/syslog. We monitor the filename, rather than the descriptor (which is the default behavior of tail). Monitoring the descriptor means that if the filename is changed -- for example logrotate, then we will follow the file to the new name. Since once a file is rotated by logrotate it won't be updated, we don't want this behavior. We add the -v (verbose) so that tail will tell us the name of the file that corresponds with the output. Then we redirect the ouput to /dev/tty2 (virtual console 2).&lt;br /&gt;&lt;br /&gt;This will output the information directly on the screen so that we can see it via the KVM.&lt;br /&gt;&lt;br /&gt;Additionally you might want to turn off the login prompt on the virtual console 2. We can do this by editing the /etc/inittab file and commenting out the following line:&lt;br /&gt;&lt;br /&gt;2:23:respawn:/sbin/getty 38400 tty2&lt;br /&gt;&lt;br /&gt;You can just put a # in front of that line and then have init re-examine the file by running:&lt;br /&gt;&lt;br /&gt;kill -HUP 1&lt;br /&gt;&lt;br /&gt;So there you go... you now have the output of any file you want to the console of your server. Set your KVM to autoscan, and enjoy your easy to view logs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/113917711622166213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=113917711622166213' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113917711622166213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113917711622166213'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/02/logs-at-glance.html' title='Logs at a Glance'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-113710606189194316</id><published>2006-01-12T16:37:00.000-06:00</published><updated>2006-01-12T16:47:41.906-06:00</updated><title type='text'>Using MySQL in a Shell Script</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Every once in a while I come across the need to access data that is stored in a database inside MySQL from a shell script. Here is a quick and dirty way to access that information without having to resort to PHP or Perl.&lt;br /&gt;&lt;br /&gt;Run a SELECT:&lt;br /&gt;&lt;br /&gt;By default this would return output like:&lt;br /&gt;&lt;br /&gt;id&lt;br /&gt;514&lt;br /&gt;&lt;br /&gt;So we need to use sed to remove the name of the field.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;SITEID=$(mysql -D database -u root --password=password --silent --exec="SELECT id FROM domains WHERE name = '`echo $SITE`';"  |sed 's/id//')&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Since INSERTs, UPDATEs and DELETEs don't return any information you won't need to pipe the information returned from MySQL to sed.&lt;br /&gt;&lt;br /&gt;This handy tip will work for basic MySQL queries, but for more complex queries, I would recommend something with a little more control over the information such as PHP or Perl.&lt;br /&gt;&lt;br /&gt;I hope that helps somebody.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/113710606189194316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=113710606189194316' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113710606189194316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113710606189194316'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/01/using-mysql-in-shell-script.html' title='Using MySQL in a Shell Script'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-113683150164070008</id><published>2006-01-09T11:32:00.000-06:00</published><updated>2006-02-03T12:51:51.783-06:00</updated><title type='text'>XEN, Hardware Virtualization - The Wave of Future</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Let me introduce you to my new favorite piece of open source software: &lt;a href="http://www.cl.cam.ac.uk/Research/SRG/netos/xen/"&gt;Xen&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Xen is a virtualization operating system that allows you to share hardware between multiple OS'es. The concept isn't really new, as there are several commercial as well as open source implementations of this concept already.&lt;br /&gt;&lt;br /&gt;In the past I have used &lt;a href="http://www.linux-vserver.org/"&gt;Linux-Vserver&lt;/a&gt; which is a set of kernel patches that create security contexts inside the kernel that different versions of Linux can co-exist in. It works very well and I have been using it for over 2 years in production. The main drawback is that it only works with Linux based OS'es. The same with Jail in FreeBSD which I have also used for a while, but again is specific to the OS, in this case FreeBSD.&lt;br /&gt;&lt;br /&gt;Now I have never used &lt;a href="http://www.vmware.com/"&gt;VMWare&lt;/a&gt;, but VMWare uses a "core" application that the guest OS'es run in. This works very well with all current OS'es from Windows, Linux to *BSD. I have heard that there is some performance degradation with this method, but I have never used it so I don't really know for certain.&lt;br /&gt;&lt;br /&gt;Now enter Xen. Xen works much the same way as VMWare, but is more lightweight. Xen loads up as a base kernel that in turn loads a Dom0 kernel.  The Dom0 is the OS that runs with higher priviledges than any other guest OS on the system. The purpose of the Dom0 is to allow an interface between the guest OS'es and the Xen kernel (to start and stop guest OS'es, create new ones, etc).&lt;br /&gt;&lt;br /&gt;The biggest limitation for Xen currently is that in order to run under Xen, an OS must be compiled to run under Xen. Currently there are hardware compile options for Linux (patchset), FreeBSD, and NetBSD (both support Xen as a native hardware architecture, like i386, or PowerPC). You will notice that Windows is missing from this list, and that is because while Xen will run Windows as a guest OS, there is currently no way the average Joe can get access to the code to Windows to make the changes necessary to get Windows to run under Xen. The Xen guys have gotten Windows to run under Xen by modifying the Windows source, and I am betting by signing NDAs and giving away their first born children, so we know that Windows will work under Xen with some modifications.&lt;br /&gt;&lt;br /&gt;That is the basics of Xen. Now we turn an eye to the future and find out what is on the horizon.&lt;br /&gt;&lt;br /&gt;Here is where things get interesting, both Intel and AMD are planning on offering a new technology into their CPUs that supports virtualization. Intel calls theirs VT (Virtualization Technology - catchy right?). Currently (as of the last processor table guide from Intel) two processors support the VT technology, the Pentium 4 662 and 672. I am assuming (using my secret decoder ring) that the XX2 designator will indicate the presence of VT for the chip. I have looked around, but I haven't found a single place that sells these processors yet so who knows how much they will cost.&lt;br /&gt;&lt;br /&gt;I don't have any details on AMDs VT offering yet.&lt;br /&gt;&lt;br /&gt;So what is so special about VT? Well Xen 3.0 (released December 2005) supports this new feature (VmWare also supports this feature). With support for VT technology it is now possible to run guest OS'es in Xen that are not compiled for the Xen architecture.... Hello Windows!&lt;br /&gt;&lt;br /&gt;So lets stop and think about this for a minute, it will now be possible to purchase a fairly large server (lots of RAM and disk space) and run Linux, FreeBSD and yes, even Windows side by side by side.&lt;br /&gt;&lt;br /&gt;It seems that this next innovation might just be a great way to improve the over all cost of operating multiple servers with multiple OS'es. Only time, and probably usability tools will tell.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Update&lt;/span&gt;: I want to thank &lt;/span&gt;&lt;span style="font-family: verdana;"&gt;Karsten Kruse&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; for quoting me in an article done on installing XEN under NetBSD. If you want to know how to install XEN on NetBSD you can read Karsten's post about how to do it &lt;a href="http://blog.onetbsd.de/?p=88"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/113683150164070008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=113683150164070008' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113683150164070008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113683150164070008'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2006/01/xen-hardware-virtualization-wave-of.html' title='XEN, Hardware Virtualization - The Wave of Future'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-113350344979111728</id><published>2005-12-01T23:57:00.000-06:00</published><updated>2006-01-04T17:37:49.623-06:00</updated><title type='text'>m0n0wall Firewall</title><content type='html'>&lt;span style="font-family:arial;"&gt;I have to admit that I don't really like GUI interfaces. I use them, but often I find that I move more efficently in a text based enviroment. I am so bad that I often find :wq in various text files that I edit in Windows (:wq is vi short hand for "write then quit").&lt;br /&gt;&lt;br /&gt;When it came time to find a firewall application, I was not keen on some of the more "flashy" alternatives out there. I had my heart set on a Cisco PIX and was planning on using that until I discovered &lt;a href="http://www.m0n0.ch/wall/"&gt;m0n0wall&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;m0n0wall had all the features I was looking for. Stateful firewall, logging, could run from an optimized compact flash device, supported VLANs (802.1q), supported device polling, and last but not least, ran FreeBSD.&lt;br /&gt;&lt;br /&gt;I have to say that my experience with m0n0wall over the past month has really proven to me that there is some really great software out there. It just works. It is flexible enough that is does exactly what I need, efficient enough that I don't dread making changes to it, and out of all the things I have used for firewalls it is easy to learn and not difficult to master.&lt;br /&gt;&lt;br /&gt;The best part is that it does so much more than what I am using it for. Not only does m0n0wall excel as a border firewall/router, but you can use it at home as well. It fully supports NAT, wireless  network cards, VPN endpoints, etc... Couple this software with some &lt;a href="http://www.soekris.com/"&gt;soekris hardware&lt;/a&gt; and you could easily duplicate the functionality of the Linksys. Granted this option might cost you a little bit more money, but that also comes with added flexibility in how you can configure the device, not to mention more CPU intensive operations like VPNs.&lt;br /&gt;&lt;br /&gt;If you are considering a firewall for your network, personal or professional, I highly recommend the m0n0wall application.&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/113350344979111728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=113350344979111728' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113350344979111728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113350344979111728'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2005/12/m0n0wall-firewall.html' title='m0n0wall Firewall'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-113148323042653862</id><published>2005-11-08T14:37:00.000-06:00</published><updated>2006-01-04T17:42:26.973-06:00</updated><title type='text'>Network Booting Your Computer</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Look, I know it has been a while since I posted. I am a busy guy, and the blog is one of those "you know I will do that tomorrow" things.&lt;br /&gt;&lt;br /&gt;Here is a quick write up of how I took a PC Chips 871G motherboard, and turned 4 of them into network bootable servers. It is worth it trust me.&lt;br /&gt;&lt;br /&gt;The PC Chips 871G is an SiS chipset based motherboard, with an SiS900 based onboard LAN. Out of the box the motherboard comes with a network boot option, but it is RPL, and pretty much useless unless you are running Netware, and I haven't touched Netware since 4.0.&lt;br /&gt;&lt;br /&gt;The new universally supported standard of network booting is PXE, so we are going to need to get the computer to boot up using PXE. Here is where things get very interesting.&lt;br /&gt;&lt;br /&gt;You have to hack the BIOS. It isn't for the faint of heart, and I actually killed two bios images before I got this right. As an aside you can flash a non-booting BIOS by booting up the same motherboard with the same type BIOS (like I said I have 4 of them) and then while the computer is running, you pull the working BIOS out of the socket - CAREFULLY. Then you place the dead BIOS chip into the socket and reflash it using your known good BIOS image. I got pretty good at this, I am sorry to say.&lt;br /&gt;&lt;br /&gt;You will need a program to edit your BIOS images, there are plenty of places on the internet to find the utilities to do this, but it takes some patience to find one that will work for you. My BIOS was an AMI BIOS, so I had to find AMI BIOS tools. Once you have the tools you can download the latest BIOS from PC Chips, and then grab the latest ROM BIOS for the LAN card. You can get this from the handy site &lt;a href="http://www.rom-o-matic.com/"&gt;Rom-O-Matic&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The BIOS image I had to work with, was limited in space. The current RPL part of the BIOS was 16KB in size, however the new Etherboot image was 32KB in size, so I had to remove some other things from the BIOS. I removed the RPL portion of the image as well as the SATA RAID software and, boot screen images.&lt;br /&gt;&lt;br /&gt;After I flashed the BIOS with this new image, I had the ability to select a new option from the boot menu "Etherboot SIS900".&lt;br /&gt;&lt;br /&gt;The BIOS boots as normal and you can boot into a PXE boot environment to load the OS of your choice.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/113148323042653862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=113148323042653862' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113148323042653862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/113148323042653862'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2005/11/network-booting-your-computer.html' title='Network Booting Your Computer'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-112727714841851813</id><published>2005-09-20T22:50:00.000-05:00</published><updated>2005-09-20T23:32:29.270-05:00</updated><title type='text'>A Tale of Heat and Peace</title><content type='html'>&lt;span style="font-family:verdana;"&gt;I am a geek. Let's just get that out of the way right now. I am a &lt;span style="font-weight: bold;"&gt;very&lt;/span&gt; big geek.&lt;br /&gt;&lt;br /&gt;I run servers for a living, but mainly I don't get to play with them. I get to configure them and fix them when they break, but generally... I just get them to work and make sure they keep working, I never get to play.&lt;br /&gt;&lt;br /&gt;That is where my home server closet comes in. My home server closet is my playground. I get to play with things, test out new software, basically break things and have fun in the process. My server closet at home helps me do that.&lt;br /&gt;&lt;br /&gt;It really is a closet, a small walk-in closet 4 foot by 3 foot, with a bakers rack full of computer equipment, monitors, keyboards, cables, and the like. There are servers in there too. Three of them actually.&lt;br /&gt;&lt;br /&gt;Server 1 is my media server (pragmatic). This server handles streaming duties, video from an onboard tv tuner (&lt;a href="http://www.mythtv.org/"&gt;mythtv&lt;/a&gt;) as well as some streaming mp3s (&lt;a href="http://www.icecast.org/"&gt;icecast&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Server 2 is my development server and general all around do boy (tragic). This server handles &lt;a href="http://www.samba.org/"&gt;samba&lt;/a&gt; (windows based file sharing), &lt;a href="http://cr.yp.to/djbdns.html"&gt;tinydns&lt;/a&gt; (dns for the internal network), &lt;a href="http://cr.yp.to/djbdns.html"&gt;dnscache&lt;/a&gt; (to handle dns requests to the clients in the local network), apache2, PHP4, PHP5, SVN, etc...&lt;br /&gt;&lt;br /&gt;Server 3 is my phone system server (magic). This server handles only one thing, my phone lines. It serves as a media gateway allowing me to connect POTS (Plain Old Telephone System) lines to VoIP services like Voneage (which I don't use, but there are others out there like them, just not as popular). The software that handles this is called &lt;a href="http://www.asterisk.org/"&gt;Asterisk&lt;/a&gt;, and by all accounts it is a pretty amazing piece of open source software made by a company called &lt;a href="http://www.digium.com/"&gt;Digium&lt;/a&gt;. The software itself is free, but Digium makes their money off the hardware, and considering how good the software is... I am inclined to throw money their way as often as I can.&lt;br /&gt;&lt;br /&gt;Anyways...&lt;br /&gt;&lt;br /&gt;Server 3... "Magic" has been the bane of my existence since I put it into service about a year and half ago. It isn't so much that the hardware is bad, but rather the hardware in relation to the environment it was in. Magic has always had an IBM Ultrastar 9GB drive since the day I built it. 10K RPM of SCSI lovin. It is fast... really fast... and pretty reliable... only one or two problems. It is &lt;span style="font-weight: bold;"&gt;HOT&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;LOUD&lt;/span&gt;. Really loud.&lt;br /&gt;&lt;br /&gt;So enters the paradox that is the server closet. The server is loud, as such, I don't want the noise in my home office, so I close the door. Enter the other problem, heat. As I close the door to the closet, temperatures in the server closet climb to insane levels. So then I have to open the door to let the heat out. Lather, Rinse, Repeat.&lt;br /&gt;&lt;br /&gt;So finally today... the heat was unbearable... and was starting to effect the PBX cards in the machine. So I decided to see why. Turns out the PSU fan died, and the computer was just roasting inside. So I pulled it out to replace the PSU and decided that I wanted to remove the noisy SCSI drive. So I start looking around for my Ghost disks... Long story short... no matter what I tried Ghost refused to see the SCSI drive.&lt;br /&gt;&lt;br /&gt;Enter my savior: I have had a copy of &lt;a href="http://www.ultimatebootcd.com/"&gt;Ultimate Boot CD&lt;/a&gt; for a couple of years now. So after blowing a couple of hours with Ghost. I figured what the heck. I threw it in, did a little g4l (Ghost 4 Linux) diskcopy sc0 wd0 mojo and it did its thing. I rebooted fully expecting it not to work... but much to my surprise, it worked flawlessly. Just a couple of adjustments to the grub loader to allow it to boot from the IDE drive instead of the SCSI drive and I was in business.&lt;br /&gt;&lt;br /&gt;So now... I am basking in the quiet and reduced heat levels in my server closet. Life is good, and geek points restored.&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/112727714841851813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=112727714841851813' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/112727714841851813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/112727714841851813'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2005/09/tale-of-heat-and-peace.html' title='A Tale of Heat and Peace'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-112693819941405799</id><published>2005-09-17T01:03:00.000-05:00</published><updated>2005-09-17T01:30:19.956-05:00</updated><title type='text'>Mod_Rewrite: A Deeper Look</title><content type='html'>&lt;span style="font-family:verdana;"&gt;I have used mod_rewrite to great extent in the past with great success. It is great to handle search engine friendly urls. This article won't be covering how to do that sort of thing as that has been beat to death, rather this article will show you some of the quirks of using mod_rewrite with apache and apache's different configuration options.&lt;br /&gt;&lt;br /&gt;I have used mod_rewrite a great deal and I consider myself to be well versed in how to set it up and use it. That being said, I learned a couple of little quirks about using it in the apache config file and how these might surprise you.&lt;br /&gt;&lt;br /&gt;Prior to today I have always used mod_rewrite in a .htaccess file. I feel safe in saying that 100% of my usage of mod_rewrite to date has been via .htaccess. So today when mod_rewrite wasn't working I tried to use my normal methods of debugging and was stumped as to why it wasn't working.&lt;br /&gt;&lt;br /&gt;First off a little background: We were running mod_rewrite from within the httpd.conf file. Further more we were actually calling RewriteEngine On from inside a virtualhost apache directive. In the past people have told me this is a faster way of using mod_rewrite so we decided to use it as this was a some what speed sensative server. What I discovered is that running mod_rewrite within this directive changes the way mod_rewrite directives work.&lt;br /&gt;&lt;br /&gt;Previously when using mod_rewrite via .htaccess I was always able to turn on logging using the directives in the "root" level of the httpd.conf file:&lt;br /&gt;&lt;br /&gt;RewriteLog "/var/log/apache/modrewrite.log"&lt;br /&gt;RewriteLogLevel 10&lt;br /&gt;&lt;br /&gt;Lesson 1 learned: This works great if you are running mod_rewrite from a .htaccess, however it has zero effect if you are running mod_rewrite from inside a virtualhost directive. For this to work properly in the virtualhost you must place the RewriteLog directives &lt;span style="font-weight: bold;"&gt;inside&lt;/span&gt; the virtualhost directive where you are using RewriteEngine On. Good to know...&lt;br /&gt;&lt;br /&gt;Once I turned on the logging I was able to determine that my regex pattern matching for mod_rewrite was missing my target.&lt;br /&gt;&lt;br /&gt;Lesson 2 learned: When you are running mod_rewrite in virtualhost you can not use RewriteBase. This means you must manually correct for this in your regex to match the leading / and the trailing / match.&lt;br /&gt;&lt;br /&gt;Hopefully those will help out others who aren't getting the results the expect.&lt;br /&gt;&lt;br /&gt;And now for those of you that have made it this far down, here are some fun things you can do with mod_rewrite.&lt;br /&gt;&lt;br /&gt;Have all files that don't have an extension be passed to the PHP parsing engine. This is particularly usefuly for creating scripts that look like directories. So you have http://somedomain.com/foobar/action/1/name/smith/ and first part of the url (foobar) is actually a PHP script that the rest of the url gets passed to. Sneaky huh? Here it is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;FilesMatch "^([^\.]+)$"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; ForceType application/x-httpd-php&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;/FilesMatch&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I hope this posting helps others in using the powerful apache module mod_rewrite and maybe prevent some lost hairs in the process.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/112693819941405799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=112693819941405799' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/112693819941405799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/112693819941405799'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2005/09/modrewrite-deeper-look.html' title='Mod_Rewrite: A Deeper Look'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-112683282901152595</id><published>2005-09-15T19:53:00.000-05:00</published><updated>2005-09-15T20:10:18.596-05:00</updated><title type='text'>How Is It Possible?</title><content type='html'>&lt;span style="font-family:verdana;"&gt;How is it possible that people who are running an online company don't have a clue when it comes to technology?&lt;br /&gt;&lt;br /&gt;Case in point today: I was handed a project to take care of for a client. They want me to take input from a form, validate it, store it in a local database and then create a CSV file and send that via FTP to a remote server. Not a difficult request, but also not a terribly secure one either. So I decided I would call the company that was supposed to be getting the CSV via FTP and see if I could just POST the data to a web form instead. So I called them...&lt;br /&gt;&lt;br /&gt;Me: "Yeah, hi. This is so and so from company and I was wondering if you guys had a web form that I could send this CSV/FTP data to instead of the CSV/FTP method."&lt;br /&gt;&lt;br /&gt;Other Guy: [:long pause:] "Uhm... I have no idea what you are talking about. The CTO is out of town and won't be back until tomorrow. Let me ask [so and so]."&lt;br /&gt;&lt;br /&gt;Me [now with so and so on the phone listening]: "Yeah I would like to just send this via curl data post."&lt;br /&gt;&lt;br /&gt;At this point I could tell that the loud sucking sound coming from the other end of the line wasn't a good sound. So I tried to explain myself further.&lt;br /&gt;&lt;br /&gt;Me: "You know... An online form... Where you type stuff into it, and it saves it some place... like a database... and then you guys can create your CSV from that instead. It would save me a lot of time."&lt;br /&gt;&lt;br /&gt;Other Guy again: "Well this plan has been laid out for two weeks and it is supposed to go live tomorrow. Don't you think it is a little late in the game to change things?"&lt;br /&gt;&lt;br /&gt;At this point I was annoyed... Here I am two hours into this project, and he is talking down to me like I had been there through out the entire thing?!? WTF?&lt;br /&gt;&lt;br /&gt;Me: "You know you are certainly right _IF_ I had been involved at that point. And I wasn't. So... getting back to my question, can you do it?"&lt;br /&gt;&lt;br /&gt;Other Guy: "Well we would have to get the CTO involved."&lt;br /&gt;&lt;br /&gt;You have got to be f*cking kidding me. You need the CTO to tell you how to make a web form? And you people run a web based business?!?!&lt;br /&gt;&lt;br /&gt;At his point I decided to cut my losses.&lt;br /&gt;&lt;br /&gt;Me: "Okay I will create the CSV and FTP the file. I will need the FTP information as well as the CSV format."&lt;br /&gt;&lt;br /&gt;Other Guy: "Well we have already sent that to Bob."&lt;br /&gt;&lt;br /&gt;Me: [leaning over to Bob] "Did you get that CSV formatting and FTP info from ComapnyB?"&lt;br /&gt;&lt;br /&gt;Bob: "Nope they never sent it."&lt;br /&gt;&lt;br /&gt;Me: "He says you never sent it. So please send it so that I can continue my work."&lt;br /&gt;&lt;br /&gt;That was 3 hours ago. I am still waiting for the CSV file.&lt;br /&gt;&lt;br /&gt;Its no wonder the dotcom bubble burst. If any of the companies Were run this way its a miracle they survived.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/112683282901152595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=15341180&amp;postID=112683282901152595' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/112683282901152595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/15341180/posts/default/112683282901152595'/><link rel='alternate' type='text/html' href='http://www.hostinggeek.com/2005/09/how-is-it-possible.html' title='How Is It Possible?'/><author><name>The Geek</name><uri>http://www.blogger.com/profile/00538642101805222279</uri><email>noreply@blogger.com</email></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-15341180.post-112630763706867895</id><published>2005-09-09T18:07:00.000-05:00</published><updated>2005-09-09T18:13:57.076-05:00</updated><title type='text'>Busy as a One Legged Man in an Ass Kicking Contest</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.hostinggeek.com/uploade