Archive for the ‘-’ Category.

How to install Java for Chromium

Download the correct version of Java to your computer.

Java Download URL

Run the binary

./jre-6u27-linux-x64.bin

Move the files to a better location.
This step is optional, but in my opinion it sort of “feels” better.

mv jre1.6.0_27/ /usr/lib/jvm/

And now link it to Chromium.

ln -sf /usr/lib/jvm/jre1.6.0_27/lib/amd64/libnpjp2.so /usr/lib/chromium-browser/plugins/

And now restart your browser, voila!

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

IIS 7.5 bug in “IP Address and Domain Restrictions” module

I came across this today when a customer called in and asked why he could browse to a website that we’ve yet to make available to the public.

Our scenario today is that we allowed 4 specific IP-address and then chose “Deny” under “Edit Feature Settings”, but then I also added localhost, and I added it as a range using a prefix.
Adding 127.0.0.0 with 8 as prefix makes IIS discard the rule you set in “Edit Feature Settings”.

If you write /8 instead of just 8, it gives you this text in the error message:

'/8' is an invalid subnet mask. It must be a valid IP address or an integer value between 0-32 for IPv4 and 0-128 for IPv6"

So obviously you’re supposed to be able to write 8 and get a proper mask (255.0.0.0).
On the other hand, if you add the mask 255.0.0.0 instead of the prefix, it works as intended.

Hopefully this will be fixed sooner or later.

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

Windows batchscript (.bat) to show current terminalsessions in cluster

A smaller batchscript to show current logged on remote users using ‘query session’ in Windows, I suspect it’s quite self explanatory.
This is set for three servers named server-01, server-02 and server-03.

@ECHO OFF
setlocal EnableDelayedExpansion
 
:: PRINT SESSION OUTPUTS FROM TERMINAL SERVERS TO TEMPORARY SESSION FILES
FOR /L %%G IN (1,1,3) DO query session /server:server-ts0%%G > sess.tmp%%G
 
:: COUNTING MATCHING ROWS FOR "tcp-rdp" IN TEMPORARY SESSION FILE
FOR %%G IN (1,2,3) DO (
	set "cmd=findstr /R /N "^.*rdp-tcp.*$" sess.tmp%%G | FIND /C ":""
	FOR /F %%B in ('!cmd!') DO (echo SERVER-TS0%%G: %%B)
)
 
:: DELETE TEMPORARY SESSION FILES
DEL sess.tmp*
 
PAUSE

Output will be

SERVER-01: 35
SERVER-02: 48
SERVER-03: 12
  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

Regular expressions for networking

A few regular expressions proven quite handy in day-to-day work, creds to kll at http://labs.spritelink.net/

Matching IPv4:
for example: 192.0.2.1

(((2(5[0-5]|[0-4][0-9])|[01]?[0-9][0-9]?)\.){3}(2(5[0-5]|[0-4][0-9])|[01]?[0-9][0-9]?))

Matching IPv4 CIDR slash-notation:
for example: 192.0.2.1/32

(((2(5[0-5]|[0-4][0-9])|[01]?[0-9][0-9]?)\.){3}(2(5[0-5]|[0-4][0-9])|[01]?[0-9][0-9]?)(/(3[12]|[12]?[0-9])))

Matching IPv6:

/((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))
|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:
[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:
[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:
[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:
[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})
|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?/

The regex matches the following IPv6 address forms. Note that these are all the same address:

fe80:0000:0000:0000:0204:61ff:fe9d:f156 // full form of IPv6
fe80:0:0:0:204:61ff:fe9d:f156 // drop leading zeroes
fe80::204:61ff:fe9d:f156 // collapse multiple zeroes to :: in the IPv6 address
fe80:0000:0000:0000:0204:61ff:254.157.241.086 // IPv4 dotted quad at the end
fe80:0:0:0:0204:61ff:254.157.241.86 // drop leading zeroes, IPv4 dotted quad at the end
fe80::204:61ff:254.157.241.86 // dotted quad at the end, multiple zeroes collapsed

In addition, the regular expression matches these IPv6 forms:

::1 // localhost
fe80:: // link-local prefix
2000:: // global unicast prefix

One could optionally append the following to match on a slash-notation style prefix.

(/[0-9][0-9]?|1([01][0-9]|2[0-8]))?
  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

How to manage and monitor your raid using mdadm

After an upgrade to Ubuntu 11.04 on my computer at work I noticed one of my SSD drives were dead in my RAID1 (mirror) and this is how I fixed the problem as well as adding some monitoring to being noticed next time around something breaks.

I managed to get the drive working merely by physically plug it out and in again, but my RAID were still obviously screwed so I had to sync the drives.

First, I checked the current status, and this can be done in two ways.

mdadm --detail /dev/md0
cat /proc/mdstat

And, as the output stated my second drive (/dev/sdb2) were not in sync.

First I removed it from the RAID altogether.

mdadm /dev/md0 --remove /dev/sdb2

Then I re-added it as such

mdadm /dev/md0 --re-add /dev/sdb2

You’ll see in syslog that the RAID is being rebuilt, but I’ll rather do this for some more information

watch cat /proc/mdstat

You’ll see this: [U_] if one of the disks is faulty, and [UU] if both are up.

Now to the next step.
I noticed this mainly because I rebooted the computer, and with a >100 day uptime this could’ve been broken for ages, and of course this is quite dangerous if the other disk were to fail.
So I used mdadm’s built-in monitoring to send me an e-mail as soon as something would go wrong.
I run postfix locally and this is how I start the process.

/sbin/mdadm --monitor --pid-file /var/run/mdadm/monitor.pid --daemonise --scan --syslog --mail=your@email.here

You can actually try this out by breaking your RAID on purpose using these commands, but don’t forget to rebuild it as explained above!

mdadm /dev/md0 --fail /dev/sdb2
mdadm /dev/md0 --remove /dev/sdb2

This will send you an e-mail with the output from /proc/mdstat as well as a short explanation of what mdadm think is wrong.

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

Disable CRL (Certificate Revocation List) on IIS 7.5

A topic I don’t know too much about, so if you have a better way of doing this I’d very much appreciate you taking the time to comment below.

Info on CLR can be found on Wikipedia.

Start with opening up cmd and type:

netsh http show sslcert

You should see “Verify Client Certificate Revocation : Enabled”

Start up regedit and change “DefaultSslCertCheckMode” to “1″, path follows:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\SslBindingInfo\0.0.0.0:443

Reboot the machine and rerun the netsh-command and you’ll see it says “Disabled” instead.

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

Expand disk size in KVM/qemu

At the office, I run my workstation on the latest Ubuntu with fluxbox as WM, but since I also need Windows for some of the tasks I run a KVM instance with a Windows 7 machine I’m controlling over RDP.
And of course you’ll eventually run out of disk space so this is what I did to double its size.

Shut down your guest (Win7 machine in my case) and back up the disk image, also rename your original image.

mkdir bak
cp win7_ent_x64_ws.img bak/win7_ent_x64_ws.img.bak
mv win7_ent_x64_ws.img win7_ent_x64_ws.img.save

Next step, create a raw file with the size you want to expand with, I had 30G earlier and decided to add another 30G
You can obviously do this with dd or any other similar software but qemu-img seemed fitting to me.

qemu-img create -f raw extended.raw 30G

Then merge the two.

cat win7_ent_x64_ws.img.save extended.raw >> win7_ent_x64_ws.img

If you do ls -alh you’ll see your win7_ent_x64_ws.img has double the size and all you have to do is to boot up the machine and partion the drive accordingly.

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

Set NTP in Windows

Probably the easiest way of syncing a Windows OS using NTP

net time /setsntp:1.1.1.1
net stop w32time && net start w32time

1.1.1.1 in this case is your NTP server.

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

Dell MD3000i performance monitoring

Just thought I’d share this with you, a little gem we came across at the Office.
Dell Tech Center, MD3000i Performance Monitoring

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr

How to log and join session of Cisco TAC

Put this in your screen.rc

deflog on
logfile log/screen%n-%Y-%m-%dT%c:%s.log
logfile flush 2
startup_message off
msgwait 0

And change shell for that user to /usr/bin/screen in /home/passwd and you’ll have a full log on what they’re doing aswell as you can join their session with screen -x

  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • LinkedIn
  • RSS
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • email
  • MySpace
  • PDF
  • Print
  • Reddit
  • Tumblr