Skip to content

Instantly share code, notes, and snippets.

Created Mar 22, 2012
What would you like to do?
ifconfig eth1 with fixed IP address on Amazon-VPC ENI(Elastic Network Interface)
# set IP address with Amazon-VPC ENI(Elastic Network Interface) address and other.
# get eth0/1 MAC addresses
MACADDR0=`cat /sys/class/net/eth0/address`
MACADDR1=`cat /sys/class/net/eth1/address`
# get eth0/1 IP addresses on ENI
IPADDR0=`/usr/bin/curl -s${MACADDR0}/local-ipv4s/`;
IPADDR1=`/usr/bin/curl -s${MACADDR1}/local-ipv4s/`;
# ifconfig on eth1 (ENI)
/sbin/ifconfig eth1 inet ${IPADDR1} netmask 2>&1 >> /tmp/seteth1.log
# write hostname in /etc/hosts
echo " localhost localhost.localdomain" > /etc/hosts
echo "${IPADDR0} ${SYS_HOSTNAME}" >> /etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment