Posts Tagged ‘ Red Hat

Firewall editing script

Ok, here’s a wee script I threw together to help myself and any other sys admins who have to make a lot of edits to the iptables firewall in Red Hat / CentOS. It basically opens up the /etc/sysconfig/iptables file to allow you to make your edit(s) and then when you close the editor, it’ll ask you if you want to apply the changes straight away, or apply them immediately to allow for testing, then unload the iptables module after a set amount of time (2 minutes as defined on line 2) in case anything broke.

#!/bin/bash
TESTING_MINS=2
vim /etc/sysconfig/iptables
clear
QUESTION1="Do you want to restart the firewall now? (hit 't' to test for $TESTING_MINS min(s)) [y/n/t] "
echo -n $QUESTION1

a=""
while test -z "$a"
do
        read -n1 a
        echo ""

 case "$a" in
  Y|y)
        echo -e "Restarting...\n\n"
		/sbin/service iptables restart
  ;;
  N|n)
        exit 0
  ;;
  T|t)
        echo -e "Time is now `date +%H:%M` -firewall service will be stopped at `date +%H:%M -d "+$TESTING_MINS min"`\nIf your test was successful, you will need to manually start the service again by running:\nservice iptables start"
        echo "/sbin/service iptables stop &> /dev/null" | at now + $TESTING_MINS min &> /dev/null
		echo ""
        /sbin/service iptables restart
  ;;
  *)
        a=""
        echo -n $QUESTION1
  ;;
  esac
done

P.S. Any scripts I write and publish here are © Rob Freeman and released under the GPL unless otherwise stated.

HOWTO: Convert from RHEL 5.3 to CENTOS 5.3

This is actually a lot more simple than I was expecting. Recently our RHEL subscription for a backup server expired and couldn’t really justify the cost to renew it, so I decided to convert it to a CentOS installation by doing the below:

yum clean all
mkdir /usr/src/centos
cd /usr/src/centos
wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-3.el5.centos.1.i386.rpm
wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.3-3.i386.rpm
wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-3.2.19-18.el5.centos.noarch.rpm
wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm
wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
rpm –-import RPM-GPG-KEY-CentOS-5
/bin/rpm -e --nodeps redhat-release
/bin/rpm -e --nodeps rhn-client-tools
/bin/rpm -e --nodeps yum-rhn-plugin
rpm -Uvh --force *.rpm
yum upgrade

How painless was that?!

Certification exams and the like…

Ok, so just this past week I think I’ve gone a bit crazy with the certification exam bookings. I booked myself in for two linux certifications which I was due to take yesterday. I say “due” because when I actually got to the place where the exam was meant to be “Professional Computer College, 85-89 Duke Street, Liverpool, L1 5AP“. The building looked just about abandoned, except through a ground-floor window I could just about see a noticeboard with some clippings about “Nerve”. A wee google later and it appears that they now occupy the building. The left brass placard next to the door had been removed so I only had the street number to go against. I rang the doorbell and what looked like a bodyguard (he had an earpiece with a spring cord) answered the door. I asked him if this building was Pearson Vue, or the computer college, he said no and looked at me rather suspiciously. He didn’t offer any information, or ask if I needed directions. He just closed the door rather quickly. As I was walked away, looking up a number on my phone, I was aware that a silver Range Rover with blacked out windows had pulled up rapidly outside the door I’d just been at. About three people, including the bodyguard guy I’d just spoken to quickly walked out of the building and got into the back of the 4×4 and sped off. That was… interesting.

Anyway, back to the story. I tried contacting Pearson Vue (or “Piss-On-You” as my sister honestly mis-heard on the phone) on three numbers, first off I tried the two numbers they gave for the test-centre both of which just rang out. Next I tried the customer services number which was auto-answered by a recorded message saying that “Due to an incident no-one can answer the phone at the moment. Please try again later”. To say I was thoroughly pissed off was an understatement. I walked up and down Duke Street twice more looking for a building that had anything like “Pearson Vue” of “Professional Computer College” as a placard. No dice. By this time I’d spent about an hour looking for the place. I eventually gave up after all possible routes of contacting Pearson Vue failed. I’m going to have to ring them on Monday and demand a refund.  Watch this space.

So, the exams themselves… these ones are fairly basic but I need to get them out of the way before I can move up to the more difficult (and higher regarded) levels. In case you’re interested, the ones I’m taking are with the LPI and they’re the Level 1 exams. Meanwhile in Windows land, I’m booked in for exam 70-290 at the end of July. I’ve been working with Server 2003 for, well, 6 years now, I’ve been on the course, I’ve read the book, I’m pretty confident I’ll do ok, I just need to keep in mind the “Microsoft way”.