≡ Menu

configuration file

RHEL: Linux Bond / Team Multiple Network Interfaces (NIC) Into a Single Interface

Finally, today I had implemented NIC bounding (bind both NIC so that it works as a single device). Bonding is nothing but Linux kernel feature that allows to aggregate multiple like interfaces (such as eth0, eth1) into a single virtual link such as bond0. The idea is pretty simple get higher data rates and as well as link failover. The following instructions were tested on:

  1. RHEL v4 / 5 / 6 amd64
  2. CentOS v5 / 6 amd64
  3. Fedora Linux 13 amd64 and up.
  4. 2 x PCI-e Gigabit Ethernet NICs with Jumbo Frames (MTU 9000)
  5. Hardware RAID-10 w/ SAS 15k enterprise grade hard disks.
  6. Gigabit switch with Jumbo Frame

[click to continue…]

Configure Ubuntu Linux GRUB to load FreeBSD

Recently my friend emailed me an interesting scenario. He installed FreeBSD 6.0 / 7.0 in the first primary partition (10G). One day he installed Ubuntu Linux. He can boot into Linux but not able to boot into FreeBSD. Now, my friend wanted to boot both FreeBSD and Ubuntu Linux via Grub boot loader.

It is not that hard to configure grub to boot FreeBSD. You just need to add following three lines to grub configuration file (/boot/grub/menu.lst). Boot into Ubuntu Linux and use text editor to edit the file /boot/grub/menu.lst ( Red hat and friends [ Fedora / CentOS ] try /etc/grub.conf file) :
$ gksudo gedit /boot/grub/menu.lst
$ gksudo vi /boot/grub/menu.lst
Append FreeBSD boot Configuration:

title  FreeBSD 7.0
root   (hd0,a)
kernel /boot/loader

Save and close the file. To see changes or to boot into FreeBSD reboot Ubuntu Linux box.

  • title FreeBSD 7.0 : Start a new boot entry. User always sees this title and hit enter key to boot os.
  • root (hd0,a) : Actual part is to select the correct root partition. The root option set the current root device to the device, then attempt to mount it to get the partition size. In above example - hd0 is your first hard disk i.e. hda in Linux. In grub hda is hd0. Likewise your first, second partition on the first hard disk – hda1, hda2, becomes hd0,0 hd0,1 in Grub. In short, you are asking to use first hard first partition (remember FreeBSD use a,b,c names to represent partition names). If you have installed FreeBSD on third partition then you need to use following root statement:
    root (hd0,2,a)
  • kernel /boot/loader : Use to load the primary boot image. FreeBSD use /boot/loader to load rest of kernel and os.

Increase productivity with FTP autologin and macros

You may use many macros under office packages. However, your ftp client also supports macros. You can use ~/.netrc - user configuration file. The .netrc file contains login and initialization information used by the auto-login process and stores macros information. It resides in the user's home directory.

Turn on FTP client auto login

You need to add username and password to file ~/.netrc. Open config file using a text editor such as vi:
$ vi ~/.netrc
Append or add following lines to it:
machine ftp.myserver.com login USERNAME password PASSWORD
Save file and exit to shell prompt. Make sure, only owner can read the file:
$ chmod 0600 ~/.netrc
To connect type command:
$ ftp ftp.myserver.com

FTP Macros

Now let us say every time you connected to ftp server you would like to switch to binary mode and turn off prompt as well as go to directory /pub/data/backup/rdbms/dump/. You can create a macro to automate all these three steps:

i) Open ~/.netrc ftp configuration file:
$ vi ~/.netrc
ii) Define a macro
You need to use the following syntax:

macdef macro-name1
macdef macro-name2

Please note that each macro definition ends with a null line (consecutive new line characters in a file or carriage returns from the terminal). There is a limit of 16 macros and 4096 total characters in all defined macros. Macros remain defined until a close command is executed.

Append following text to .netrc file:

macdef FOO
cd  /pub/data/backup/rdbms/dump/

Save and close the file. Now connect to ftp server:
$ ftp ftp.myserver.com

Connected to ftp.myserver.com
220 ftp.myserver.com NcFTPd Server (licensed copy) ready.
Remote system type is UNIX.
Using binary mode to transfer files.

To execute a macro FOO type the command:

ftp> $ FOO


200 Type okay.
Interactive mode off.
cd /pub/data/backup/rdbms/dump/
250 "/pub/data/backup/rdbms/dump/" is new cwd.
ftp> ls

Further readings:

=> ftp command man page

HowTo: Recovering Linux Grub Boot Loader Password

If you have, a password protected grub boot loader and you forgot both root and grub password, then you can recover grub-boot loader password using the following method/procedure:

* Use Knoppix cd
* Remove the password from Grub configuration file
* Reboot the system
* Change the root password
* Setup new Grub password if required (optional)
[click to continue…]

How Do I Run a Firewall Script As Soon As eth0 Interface Brings Up?

I use ADSL at home via ISP modem. As soon as my eth0 comes up I would like to have my firewall script get executed and setup the iptables firewall rules for me.
[click to continue…]

FreeBSD: Becoming Super User (su) or Enabling su Access For User Account

The superuser is a privileged user with unrestricted access to all files and commands. The superuser has the special UID (user ID) 0. You need to become super user (root) only when tasks need root permissions. Here is how to become a super user:
[click to continue…]