OraMatt: YABAOracle

Yet Another Blog About Oracle

Get the IP Addresses of your running Linux Containers

Linux Containers are AWESOME!!!
They’re almost as good as Solaris Zones/Containers…

Here’s a quick script to get the IP Addresses of all your running Linux Containers

#!/bin/bash
#
# Script to get the ip addresses of your running Linux Containers
#
#

# Get a list of Active Linux Containers
# Query for the ip addresses

export RUNTIME=`date +%m_%d_%y_%H%M`
export IPLOG=/tmp/lxc_ipaddr.${RUNTIME}.log

for i in `lxc-ls --active`
do
	echo ${i} 							| tee >>${IPLOG}
	echo "-----------" 					| tee >>${IPLOG}
	sudo lxc-attach -n ${i} -- ifconfig eth0	| grep "inet addr:"| tee >>${IPLOG}
done

# Show the log file
cat ${IPLOG}

Get the file

Leave a comment

Navigation

About

I’m Matt and I do Oracle things.