A fusion of technology, music, and geekyness.
Currently Browsing: Software

Forward Network Traffic With Iptables

From time to time I come across something truly amazing that I just must share no matter how tired I am. Even though they are typically very simple it helps me remember in the future and I hope it also helps others out wfhen they have the same problems that I do. I recently migrated a server from Slicehost to Linode and I wanted to find a quick and easy way to forward web traffic on various ports to the new server while DNS caught up. The answer was simple… iptables. I found this in an article here.

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 1.2.3.4:80
iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to-destination 1.2.3.4:3306
iptables -t nat -A POSTROUTING -j MASQUERADE

Linux Disk Imaging with Clonezilla and PXE

Now that I finally have a file server at home I got curious again with disk imaging solutions. After doing some research I found a pretty awesome tool called Clonezilla. After downloading the live CD and playing around for a while the first thing I wanted to do was test it out in a PXE boot fashion. Here was my quick and hackish approach. My test run was on a VirtualBox VM in Xubuntu 10.04 with a bridged adapter.

1. Install TFTP server

sudo apt-get install tftpd-hpa
sudo start tftpd-hpa

Ensure /var/lib/tftpboot exists. If it does not:

mkdir -p /var/lib/tftpboot

Ensure that the values in /etc/defaults/tftpd-hpa match.

2. Install DHCP server

sudo apt-get install dhcp3-server
sudo vim /etc/dhcp3/dhcpd.conf

Add something similar to the following…

default-lease-time 86400;
max-lease-time 604800;
authoritative;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.10 192.168.1.15;
        filename "pxelinux.0";
        next-server 192.168.1.121;
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.1.255;
        option routers 192.168.1.1;
}
sudo service dhcp3-server start

The next-server option needs to be the IP of the TFTP server. Everything else should be self explanatory.

Before proceeding verify both services are listening.

sudo netstat -upan | awk  '{print $6}'
2008/dhcpd3
582/dhclient
3627/in.tftpd

3. Install syslinux if it is not already (it should be). Copy over pxelinux.0 into the appropriate location.

sudo apt-get install syslinux
sudo cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot

4. Download latest clonezilla zip from SourceForge.

sudo unzip clonezilla-live-*.zip
sudo cp live/vmlinuz /var/lib/tftpboot/
sudo cp live/initrd.img /var/lib/tftpboot/
sudo cp live/filesystem.squashfs /var/lib/tftpboot/
cd /var/lib/tftpboot
sudo touch boot.txt
sudo mkdir pxelinux.cfg
sudo touch pxelinux.cfg/default

Your tree should end up looking something like this in the end:

├── boot.txt
├── filesystem.squashfs
├── initrd.img
├── pxelinux.0
├── pxelinux.cfg
│   └── default
└── vmlinuz

5. Create configs

sudo vim boot.txt

I made my menu look something like the following…


========================================================================

 .d8888b.  888                                    d8b 888 888
d88P  Y88b 888                                    Y8P 888 888
888    888 888                                        888 888
888        888  .d88b.  88888b.   .d88b. 88888888 888 888 888  8888b.
888        888 d88""88b 888 "88b d8P  Y8b   d88P  888 888 888     "88b
888    888 888 888  888 888  888 88888888  d88P   888 888 888 .d888888
Y88b  d88P 888 Y88..88P 888  888 Y8b.     d88P    888 888 888 888  888
 "Y8888P"  888  "Y88P"  888  888  "Y8888 88888888 888 888 888 "Y888888 

======== Boot Options: ================================================

>> clonezilla ......... Regular Boot
>> clonezilla_safe .... Failsafe Mode

=======================================================================

And finally the pxe config…

sudo vim pxelinux.cfg/default

Looked something like this:

DISPLAY boot.txt

LABEL clonezilla
	kernel vmlinuz
	append initrd=initrd.img boot=live union=aufs noswap noprompt vga=788 fetch=tftp://192.168.1.121/filesystem.squashfs

LABEL clonezilla_safe
	kernel vmlinuz
	append initrd=initrd.img boot=live union=aufs noswap noprompt vga=normal nomodeset nosplash fetch=tftp://192.168.1.121/filesystem.squashfs

PROMPT 1
TIMEOUT 0

Please note that the IP address should be the IP of the TFTP server!

Now testing with a Dell Latitude E6410 I hit F12 on the BIOS screen, Select Network Adapter, and SUCCESS! You should see your boot.txt with a “boot:” prompt. Please share your experiences and alternative implementations on how you solved this issue. I would love to hear them!

My Test results:
250 GB (239.9 GB after formatting)
67.7 GB in use
175.2 GB free
Transfer Rate: Started at 900 MB/min at first, peaked at 1.91 GB/min, ended at 1.72GB/min, average 1.7 GB/min
Time elapsed: 37 minutes, 41 seconds


Possible Migration from Ubuntu to Gentoo Linux (Nope, Arch!)

I have been giving it a lot of thought recently. I have been using Ubuntu for a couple years now and I think I am ready to move on. I haven’t tried Gentoo since college and I thought that tonight was a good night to check in on it. I was worried that it may be somewhat dead and that no one used it anymore so I decided to see if they had a chat room on irc.freenode.net – boy was I suprised! The channel was booming! I am currently installing a test drive VM right now. The installation process is so refreshing. Tonight made me realize that I have really let myself go since college. I am sick of Ubuntu and how it constantly wipes my ass for me, but fails sometimes anyway. I currently am running Ubuntu 9.10 with Gnome and the plan is to migrate to Gentoo and Xfce. The following information illustrates my reasons for wanting to switch. Ones that weigh more for me are in bold.

Ubuntu 9.10 Pros:
Just works
Apt package management is speedy
Well supported
Attractive
I know it

Ubuntu 9.10 Cons:
Does too much
Gnome is bloated
Deb package dependencies are crazy sometimes
Can be slow at times

Gentoo Pros:
Very trim and lightweight
Forces you to learn and maintain general linux knowledge
Very flexible

Gentoo Cons:
Takes FOREVER to compile packages and dependencies
Emerge can have issues
Not for lazy people (and im pretty lazy)

As I write this post I am on step 9/10 of the install. I will provide updates as time goes on.


Update 1:
I encountered three problems and got them all resolved. I am currently installing Xfce and xdm right now. The problems I faced:
1. Changed password for root user for install, not chrooted gentoo environment.
2. The install CD loads out of date drivers so hard drives show up as hda during install but sda during initial boot. This screwed up both GRUB and /etc/fstab.
3. I forgot to compile my network card drivers into the kernel so my eth0 device didn’t exist.

I also found this quite interesting and hilarious (click on it to read):
gentoo_lol


Update 2:
Gentoo compiles are taking WAY too long and the installation takes 4+ hours to complete. This is just not an option these days, especially for my work laptop. I decided to give Arch + Xfce a shot and it was a breeze. I still feel like I get way more control than I did in Ubuntu without all of the bloat. I am going to try this out for a while and see how I like it. If for whatever reason I dislike it, I will be switching to Xubuntu and call it a day.

Selling points on Arch:
The Arch Build System – Amazing!
The Arch User Repositories, for must haves like my beloved google-chrome!
Minimalistic approach

Kris I hope you are happy…


Startup Script for Rails with WEBrick

I finally started playing with rails again. I decided to play around and start the basics of a billing application. I was initially debating web app versus a desktop app (rails vs ruby-gtk). I wanted a reason to finally start using rails so I decided to make it a web app. I then realized I may be able to simulate a desktop app with rails. I pulled in the base ruby packages, manually compiled RubyGems and installed necessary gems, and decided to script a startup routine so I could create a launcher on my desktop. This solution is far from perfect but it manages to fulfill my needs. My “desktop rails app” uses the built in standalone webserver WEBrick and sqlite3 for its backend.

#!/bin/bash
cd /home/jesse/rails/billing

if [ ! -f tmp/pids/server.pid ]; then
	script/server -d
fi

while [ `netstat -tan | grep 0.0.0.0:3000 | wc -l` != 1 ]; do
	echo "Server not started yet..."
	sleep 1
done

google-chrome http://localhost:3000/customers &
tail -f log/development.log

# Server can be killed with:
# kill -INT `cat tmp/pids/server.pid`

I then created a launcher simliar to this:

launcher

When I double click on the icon the first time it pauses for about 5-6 seconds while WEBrick initializes and binds to port 3000. As soon as it detects the webserver listening, I launch google-chrome to the default view. Each time I click the icon there after, the webserver is already running so the google-chrome tab kicks off instantly.


World of Warcraft in Ubuntu 9.10

wow-ubuntu2
wow-ubuntu2

Wine and Ubuntu have really come a long way. These days it is very easy to get World of Warcraft to smoothly run in Linux. I felt the need to write this guide for two reasons: one as a mark of my triumphant achievement, and two as a helpful guide for those looking to do the same. This walk through assumes the following.

  • You do not have wine currently installed. If you do and it is not the wine1.2 package then World of Warcraft probably won’t run very well, if at all.
  • You currently have the restricted drivers installed for your video card
  • Your system is up to date.
  • You are running Ubuntu 9.10
  • The WoW current patch is not too far past 3.3.3
  • You have basic knowledge of Linux and understand how to use a terminal

Warning: This configuration worked great for my hardware. Other hardware configurations may need additional tweaking.

1. Before you start you must verify that your graphics card had DRI enabled.

glxinfo | grep rendering

If it returns “Yes” then you are all set. If it returns no I am not sure if you should continue with this guide.

2. Install Wine via apt

sudo apt-get install wine1.2

3. Download the Visual C++ Patch From Microsoft at www.microsoft.com/downloads/en/confirmation.aspx?familyId=200b2fd9-ae1a-4a14-984d-389c36f85647&displayLang=en.

wine /home/username/Downloads/vcredist_x86.exe

Follow the prompts to install it and it will close when it has finished. This patch is needed to successfully download patches at a certain point for WoW to run.

4. Install World of Warcraft. There are several means available to do this. You can install from the CDs/DVDs you bought or if you are like me you will need to download the entire installation from Blizzard. I had to download the downloader at https://www.worldofwarcraft.com/account/download_wow.html. For other methods of installation see the sources at the end of this article.

wine /home/username/Downloads/InstallWoW.exe

Choose Wrath of The Lich King when it prompts and keep going through the wizards. The downloader will eventually begin and you will have several hours (depending on your connection) to wait while it finishes.

5. Once the installation is complete, you will most likely want to edit the configuration to start WoW in OpenGL mode.

vim /home/username/.wine/Program\ Files/World\ of\ Warcraft/WTF/Config.wtf

Press the i key on your keyboard to go into insert mode. Add the following line to the bottom of the file.

SET gxAPI “OpenGL”

Press escape, type :wq, and press enter to save and exit the file.

6. Wine currently has permission issues with the World of Warcraft folder. If you ever notice WoW not starting after the launcher loads it is probably because the permissions somehow got screwed up on the folder. I have chosen to completely bypass the loader and I have also written a launcher script to make sure that WoW loads every time. Execute the following commands to start WoW for the first time.

chmod 755 /home/username/.wine/drive_c/Program\ Files/World\ of\ Warcraft/
wine "C:\Program Files\World of Warcraft\WoW.exe"

After some patience World of Warcraft will successfully load up. Get your initial video / audio configuration out of the way before the next step.

7. The endless loop: Login and it will force you to download a patch. You will have to complete this step approximately 5 or 6 times until all the patches have downloaded.

8. After all the of the patches have downloaded you should be good to go! Install all mods to /home/username/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Interface/AddOns/. Keep in mind that by default in Gnome that your keyboard is configured to automatically repeat keys when held down by default. This will make your mounts and characters running seem strange. You can disable this temporarily by going to System -> Preferences -> Keyboard and unchecking “Key presses repeat…”

I hope this quick guide has helped you get World of Warcraft installed and running beautifully in Ubuntu. If you have additional issues with your installation and need help please see the following sources for additional assistance.

Sources


« Previous Entries Next Entries »

Powered by Wordpress | Designed by Elegant Themes