Created
March 22, 2012 23:14
-
-
Save utaani/2165376 to your computer and use it in GitHub Desktop.
ifconfig eth1 with fixed IP address on Amazon-VPC ENI(Elastic Network Interface)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 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 http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MACADDR0}/local-ipv4s/`; | |
IPADDR1=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MACADDR1}/local-ipv4s/`; | |
# ifconfig on eth1 (ENI) | |
/sbin/ifconfig eth1 inet ${IPADDR1} netmask 255.255.255.0 2>&1 >> /tmp/seteth1.log | |
# write hostname in /etc/hosts | |
SYS_HOSTNAME=`hostname` | |
echo "127.0.0.1 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