Recently in Linux/Unix Category

FTP Load-Balanced through haproxy

| 0 Comments | 0 TrackBacks
I was asked to explore the possibility of having haproxy balance connections between multiple backend FTP servers. Luckily there is a way to do this without having to play with DNAT on the proxy server and instead setting it up with multiple backends in haproxy.

So lets dive in.

OpenIndiana (Solaris) VLAN Trunk

| 0 Comments | 0 TrackBacks
I recently discovered a need to be able to add multiple VLANs on a single interfaces on Solaris.

This one is really simple! Just make sure you are running as root, not escalating privileges with pfexec.

So, lets start this off. Figure out which of your interfaces you want to use as the trunk, in my case it is atge0.
Make sure that you have setup whichever switchport on your switch to be a dot1q trunk

In this scenario I have my server originally on a switchport just in access mode on VLAN 10. To make it into a trunk (network will drop for around 30 seconds) you can reconfigure the port with the commands below to still be on VLAN 10 if using Cisco.

taiter-sw# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
taiter-sw(config)# interface gi0/5
taiter-sw(config-if)# switchport
taiter-sw(config-if)# switchport trunk encapsulation dot1q
taiter-sw(config-if)# switchport trunk native vlan 10
taiter-sw(config-if)# switchport mode trunk
taiter-sw(config-if)# end

Then issue the following commands (substituting your NIC for where I've put atge0):

root@taiter:~# dladm create-vnic -l atge0 -v 30 atge0.30

The argument for the VLAN is -v VLANID and then you can call your new virtual interface whatever you like. I tend to like the INTERFACE.VLAN naming.

Now we can give an IP to the new VNIC.

root@taiter:~# ifconfig atge0.30 plumb 10.1.1.5/24 up

I've just shown an example, but obviously change 10.1.1.5/24 to your IP and mask that is on that VLAN.

Console Redirection with XEN and Linux for Sun iLOM/IPMI

| 0 Comments
Having a working IPMI/ILOM card is pretty much essential when rolling out a new system to a remote location or lights-out data center. There were some issues in getting the onboard Sun IPMI card on a Sun Fire X4100 (this should work for X4140 X4200 X4600 etc) to print to both the graphical console as well as the serial when using Xen.

One of the issues is that Xen wants to grab by default ttyS0 which is what the Sun IPMI serial port is and as I understand it, have the wrong serial port settings.

So here is the configuration to get it working and sending to both the serial and regular system console (VGA, IPMI redirection via web):

1. Change /etc/grub.conf to have something similar to the following:

title CentOS (xen) root (hd0,0) kernel /xen.gz com1=9600,8n1 module /vmlinuz-xen ro root=LABEL=/ console=ttyS0,9600n8 console=tty0 module /initrd-xen.img

On the Xen kernel line there is one argument:

com1=9600,8n1 : This is the line to make the Xen console play nice with the Sun. Please note that if your IPMI console is set to another speed you will have to change 9600 to match the speed you are using.

On the system kernel line there are a few more added arguments:

console=ttyS0,9600n8 : Adding this will activate the IPMI serial console, remember that if your serial port settings are different you will need to change the 9600n8 part to whatever will match with yours.

console=tty0 : This just ensures that the output will be redirected to the default console (VGA etc.)

2. Edit /etc/inittab and add the below line:

co:2345:respawn:/sbin/agetty ttyS0 9600 vt100-nav

3. Add ttyS0 to /etc/securetty

[root@tclarrltp ~]# echo "ttyS0" >> /etc/securetty

Now you should be able to see everything in the serial console via the IPMI as if it were on a monitor infront of you.

Rename KVM Virtual Machine with virsh

| 0 Comments
Decided to play around with virsh today to see if I could rename some VMs that changed their hostname and purpose. It's actually quite simple!

I am using Fedora 14 for this but I assume it will work for Ubuntu and CentOS as well.

You must have elevated privileges for this to work so either become root or use sudo.

Power off the virtual machine and export the machine's XML configuration file:

[root@tclarrltp ~]# virsh dumpxml name_of_vm > name_of_vm.xml


Next, edit the XML file and change the name between the <name></name> tags (should be right near the top). As an added step you could also rename the disk file to reflect the change of the name and change the name of it in the <devices> section under <source file='/path/to/name_of_vm.img'>.

Save the XML file and undefine the old VM name with:

[root@tclarrltp ~]# virsh undefine name_of_vm


Now just import the edited XML file to define the VM:

[root@tclarrltp ~]# virsh define name_of_vm.xml


And that should be it! You can now start up your vm either in the Virtual Machine Manager or with virsh using:

[root@tclarrltp ~]# virsh start name_of_vm


Hope this was helpful!

Sun ILOM Remote Console Linux

| 0 Comments
Quick entry here, but if you want to have the ILOM remote console launch automatically from the web browser have the file that gets downloaded automatically opened by "/usr/bin/javaws".

nVIDIA GT210 - HDMI Audio

| 0 Comments
Recently my Shuttle HTPC started having issues when booting into Gnome using any sort of hardware video acceleration. I would turn it on and watch it boot until it got to the login screen, at this point it would either let me login and then power off or just power off before it got to the graphical login screen.

I decided to pick up a new video card with HDMI so I wouldn't have to switch my speaker input to direct each time I wanted to use my PC. I grabbed the EVGA GeForce 210 from Tiger Direct and after some power setting changes in the BIOS, the computer booted and automatically started using the newly plugged in HDMI cable!

Now all I had to do was get the sound working.

Postfix - SMTP Relay Authentication with SASL

| 0 Comments
Last night I decided that I wanted to make my home server able to send out Logwatch and yum-updatesd emails to my work email so I can keep on top of updates and changes to my system.

Since I have been testing with Postfix lately I have found that it is much easier to configure than sendmail so I installed postfix, removed sendmail and made sure that postfix was my default mailer. If you don't know how to do this, do some google searching for switching to postfix in your distro.

As Rogers will surely freak out if I started running a local SMTP/IMAP server due to their Terms and Conditions, I decided to use an existing email service that I have through godaddy.com and figure out how to get postfix to authenticate to the SMTP server that I use there. This means it will also work if your ISP gives you an email address that uses SMTP to send but has a username and password.

Before starting this you need the following information from your SMTP server or ISP:

- User name
- SMTP Server address
- SMTP Server port (if it is something other than the default port, 25)

You will also need:

- Root access
- Postfix installed and set as the default mailer


Recently I set up Openfire as a corporate messaging service, if you haven't heard about Openfire I highly suggest checking it out. It can be forced to be SSL encrypted and allows you to tie into Active Directory to pull users and information. I might be writing an entry soon regarding adding specific users and groups to Openfire from Active Directory and populating the "Vcards" with information from Active Directory.

The problem I ran into was that since our VPN server and Openfire server both have external access and are in the same address space, the VPN server would try to send the Openfire traffic out the external gateway but couldn't reach the server because of some ACLs that were set in place.

So what I did was take the traffic from the VPN tunnel that is going to the Openfire ports and route it through our internal network.

LVM Migration to smaller disk

| 0 Comments
Recently I purchased an SSD (OCZ Agility 60GB) to put into my Asus EEEPC-1000HE and wanted to migrate everything from my default 160GB drive to the new SSD. This required resizing of the LVM prior to copying the partitions across to the SSD.

It is also very important that your logical volumes you wish to resize and migrate aren't filled with more data than the destination drive will hold!

For example my root LV (called lv_root) had 9GB in use so it was alright for me to resize and transfer to the new system.

Also, you will probably need to remove your swap LV (if your swap is configured as an LV), there will be an example of how to do that.

Required Items:
  • USB Drive or Blank CDROM
  • liveusb-creator (if using USB method)
  • (Optional)Fedora LiveCD Iso
    • You can also get liveusb-creator to download the image over the internet
  • USB SATA II connector or secondary SATA port on your motherboard
Now you can create the LiveUSB or LiveCD of Fedora. Do this now!

Have all the above items? Lets get started.

Xen CentOS 5.x domU kickstart install

| 0 Comments

Today I realized that trying there is a much easier way to create custom updated paravirtualized domUs that can be rolled out in a matter of minutes than copying a 20GB image file from an NFS mount.

With kickstart it is really a no brainer; from the config file you can set absolutely everything for your domU... eg. IP, hostname and many more options (way too many to list here, but if you want you can check out the kickstart manual, there is a link provided at the end of the howto).

I will be providing a basic kickstart install script that installs a few extra packages and then updates the entire installation.

SSH Menu - Encrypted VNC

| 0 Comments
Recently I decided that I wanted to be able to connect to my PC at home from my office using a secure connection. This also allowed me to keep my single open port for SSH open.

I am using sshmenu and gnome-applet-sshmenu version 3.15-6.fc11 on Gnome in Fedora 11. The following guide will show you how to very easily add an entry to the sshmenu that will allow you to use SSH to connect to your already running VNC server.

This guide will not show you how to setup a VNC server, but there are a lot of those how-tos available around the internet.

Electricsheep - Gnome Screensaver and Fedora

| 10 Comments
For a while now I have tried to get the electricsheep screensaver working properly under Fedora and Gnome without using Xscreensaver. The main issue I was having was that the screensaver would only show up in a tiny box in the top left corner and no matter what I changed in the config files.

I started searching again because I just installed Fedora 11 (which came out today) on my EEE-PC and thought I might want to have a kickass screensaver running on it.

EDIT: Updated script for new changes made and compatibility with Fedora 12. Change made November 18th 2009. The script may error out on downloading a package, but disregard unless there is a problem compiling.

EDIT 2: The script is working with Fedora 13 as well, a big thanks to Michael Ayers (ayersm@ayerhead.net) for letting me know of some differences for Fedora 13! :)

EDIT 3: It is confirmed as working for Fedora 14, another thanks to Canin who noted a difference involving SELinux. To fix this you can run execstack -c /usr/lib/libxvidcore.so.4.2 and it should work properly

After searching very briefly I came across a script on an electricsheep forum post made by the team that pushed me in the right direction.

OpenSolaris 2008.11 - Adding Disks to the rpool

| 0 Comments
Alright, so recently we got some new hardware to build a cheap NAS device and since we didn't want to have a hardware RAID handling the root drives, we needed to add a drive to the rpool.

This is a pretty simple procedure, well not so simple when I first started as there were tons of errors about disk labels being wrong etc.

OpenSolaris 2008.11 Paravirtualized domU on Xen 3.1.2

| 0 Comments
After scouring the internet for a definite solution, I found many. Here is another to add to the list. This is for a paravirtualized Opensolaris 2008.11 domU 64bit.

The system I am using is the most recently updated CentOS 5.2 X86_64 running the CentOS xen package which is v3.1.2 (even though it still says 3.0.4 in the RPM name.. gg CentOS)