Friday, October 15, 2010

Generate IPV6 Addresses with BASH

A fast way to generate some IPV6 addresses via BASH, with tool called "wcalc" that will help generating hexadecimal values.
First make sure "Wcalc" package is installed on your system:

root@paul-laptop:~# rpm -qa Wcalc
Wcalc-1.6.2-1


Next, using bash "for" loop let's generate some addresses (values selected randomly):

root@paul-laptop:~# for i in $(seq 600 610) ;do echo -n '2001:fade:28e1:3712::1'; echo ${i} |wcalc -h|awk -F x '{print $2}';done

Output:

2001:fade:28e1:3712::1258
2001:fade:28e1:3712::1259
2001:fade:28e1:3712::125a
2001:fade:28e1:3712::125b
2001:fade:28e1:3712::125c
2001:fade:28e1:3712::125d
2001:fade:28e1:3712::125e
2001:fade:28e1:3712::125f
2001:fade:28e1:3712::1260
2001:fade:28e1:3712::1261
2001:fade:28e1:3712::1262

Tuesday, October 12, 2010

Reinstall MBR with GRUB stage1

Creating a dual-boot Linux system such as the Red Hat/Debian is a neat way to experiment with both distributions another advantage is  having a fallback point.
A small downside is that the GRUB stage1 information in the MBR can be overwritten by the second install. In our example, Red Hat is installed on the first disk, and Debian is installed on the second. After Debian is installed, however, the Debian GRUB menu is displayed instead of the Red Hat menu that we are used to and that has been customized for our installation.

Let's see how we can solve this issue -

step 1 
Boot to grub CLI

step 2
The root (hd0,0) command sets the (hd0,0) partition as the location of the boot directory. This command tells GRUB in which partition the stage2 and grub.conf or menu.lst files are located.

step 3
The find /boot/grub/stage1 command returned the first stage1 entry it found.
Both disks should have this file. In this instance, GRUB shows the stage1 file from the second disk.Because we want GRUB to format the MBR on the first disk, /dev/hd0 is used.

step 4
The setup (hd0) command writes the MBR of the selected disk or partition.

That's it! The whole process should look like this :

Saturday, October 9, 2010

SAMBA - QUICK HOWTO part 2

In this short tutorial I will show you how to create a user based share on a samba server.

First, Install samba server:

apt-get install samba


Start the samba service:

/etc/init.d/samba start

Check service is running and bound to port 139:

lsof -i :139

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
smbd    14942 root   23u  IPv6  18189      0t0  TCP *:netbios-ssn (LISTEN)


Add a samba user that will access the shared folder (you'll be prompted for password):

smbpasswd -a tango

The main configuration file sits at:

/etc/samba/smb.conf

Open it with your favourite text editor

We will add a share for the user tango, the share is located at:

/usr/srv/www/tangodomain

The share will look like this:
[tango share]
comment =tango's stuff
writeable = yes
path = /usr/srv/www/tangodomain
 
valid users = tango

Hup samba so changes take effect:

killall -HUP samba


Now, you can access the samba server from any Windows station as tango.

\\samba-serv\tango


You can map a network drive from Windows to make access more comfortable, from your Windows machine run:

C:\net use x: \\samba-serv\tango

Saturday, October 2, 2010

Howto: Tkdiff - a great comperation tool

Tkdiff is very useful small tool that's based on the original Unix "diff" command but much more "eye friendly".
Imagine a situation where you have to compare 2 huge files/XML templates/ router configurations etc... well you got the point, the process can be much more smoother using this great tool, let's see how to install it and some basic usage:

In my case I used CentOS 5.4 virtual machine, but any Unix/Linux flavor will do.
Tkdiff has a dependency of "tk" package which is an addon for TCL scripting language which allows to create GUI apps.

So first we shall install tk package:

#yum install tk

Download the "tkdiff" RPM package from any repository you chose, like this one:

#\wget http://www.dil.univ-mrs.fr/linux/dil/centos/5/tkdiff-6.3-1.noarch.rpm

And install it:
#rpm -ivh tkdiff-6.3-1.noarch.rpm

If you want to compare 2 files named file1 file2, the usage is as follows:

#tkdiff file1 file2















Here we can see that "123" is same on both files, while the difference is at line contains string "456" ,which  exists only in file2.

A sure great tool for any admin, engineer, developer.

Have fun.