Posts Tagged ‘task’

How to add a range of virtual IPs to a CentOS and Fedora Linux server

Monday, July 18th, 2011

Recently I had the task to add a range of few IP addresses to as a virtual interface IPs.

The normal way to do that is of course using the all well known ifconfig eth0:0, ifconfig eth0:1 or using a tiny shell script which does it and set it up to run through /etc/rc.local .

However the Redhat guys could omit all this mambo jambo and do it The Redhat way TM 😉 by using a standard method documented in CentOS and RHEL documentation.
Here is how:

# go to network-script directory[root@centos ~]# cd /etc/sysconfig/network-scripts
# create ifcfg-eth0-range (if virtual ips are to be assigned on eth0 lan interface[root@centos network-scripts]# touch ifcfg-eth0-range

Now inside ifcfg-eth0-range, open up with a text editor or use the echo command to put inside:

IPADDR_START=192.168.1.120
IPADDR_END=192.168.1.250
NETMASK=255.255.255.25
CLONENUM_START=0

Now save the /etc/sysconfig/network-scripts/ifcfg-eth0-range file and finally restart centos networking via the network script:

[root@centos network-scripts]# service network restart

That’s all now after the network gets reinitialized all the IPs starting with 192.168.1.120 and ending in 192.168.1.250< will get assigned as virtual IPs for eth0 interface
Cheers 😉

Runing sudo command simultaneously on multiple servers with SSHSUDO

Tuesday, June 21st, 2011

ssh multiple server command execute
I just was recommended by a friend a nifty tool, which is absoutely nifty for system administrators.

The tool is called sshsudo and the project is hosted on http://code.google.com/p/sshsudo/.

Let’s say you’re responsible for 10 servers with the same operating system let’s say; CentOS 4 and you want to install tcpdump and vnstat on all of them without logging one by one to each of the nodes.

This task is really simple with using sshsudo.
A typical use of sshsudo is:


[root@centos root]# sshsudo -u root \
comp1,comp2,comp3,comp4,comp5,comp6,comp7,comp8,comp9,comp10 yum install tcpdump vnstat

Consequently a password prompt will appear on the screen;
Please enter your password:

If all the servers are configured to have the same administrator root password then just typing one the root password will be enough and the command will get issued on all the servers.

The program can also be used to run a custom admin script by automatically populating the script (upload the script), to all the servers and issuing it next on.

One typical use to run a custom bash shell script on ten servers would be:


[root@centos root]# sshsudo -r -u root \
comp1,comp2,comp3,comp4,comp5,comp6,comp7,comp8,comp9,comp10 /pathtoscript/script.sh

I’m glad I found this handy tool 😉