Executing commands on multiple hosts

If you have to execute the same command in multiple hosts, then you can use mussh:

Description : Mussh is a shell script that allows you to execute a command or script
: over ssh on multiple hosts with one command. When possible mussh will use
: ssh-agent and RSA/DSA keys to minimize the need to enter your password
: more than once.

First install mussh with the following command

dnf install mussh

Now to run this for multiple hosts, you can run like this

mussh -h vm{1..2} -c "hostname"

This will run the commands on hosts – vm1 and vm3
Command that will be run is “hostname”
Similarly you can run other commands as well on multiple machines.

Network Manager post-up script (dispatcher script)

Network manager is supposed to be much better than network, how so?

it supports dnsmasq for one…

Dnsmasq with netowrkmanager

Local name resolution

Also Network Manager supports dispatcher scripts. How can that help? For one, I used to send interface up emails. To do so, all I had to do was put the following script in “/etc/NetworkManager/dispatcher.d”


cd /etc/sysconfig/network-scripts
. ./network-functions

[ -f ../network ] && . ../network

# Notify programs that have requested notification


dnsmasq local name resolution with NetworkManager

Network Manager suports starting dnsmasq which helps you have a local cache for DNS thus getting faster resolution for the DNS queries.

Dnsmasq with netowrkmanager

So, one thing that I have been thinking about is having a local name resolution for the VMs. So, I wanted something like this to work:

vm1 => 172.17.42,1

vm2 => 172.17.42,2

and so on …

To achieve this and reverse dns to work, we will add the entries in file “/etc/NetworkManager/dnsmasq.d/hostnames“. Just one more problem, adding so many entries manually? So, to help you with that, I created this small script:

#!/bin/bash -
#          FILE: add-dnsmasq.sh
#         USAGE: ./add-dnsmasq.sh
#       OPTIONS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka), 
#      REVISION:  ---

for i in {1..250}
    echo "address=/vm$i/$IPPRE$i" >> /etc/NetworkManager/dnsmasq.d/hostnames
    echo "ptr-record=vm$i,$IPPRE$i" >> /etc/NetworkManager/dnsmasq.d/hostnames

Just run this script to add all the entries and restart dnsmasq by killing the already running instance. :)