Skip to content

Instantly share code, notes, and snippets.

@simond
Created May 29, 2017 09:01
Show Gist options
  • Save simond/ae28ca7794788dbab684dc544f99bc50 to your computer and use it in GitHub Desktop.
Save simond/ae28ca7794788dbab684dc544f99bc50 to your computer and use it in GitHub Desktop.
#!/bin/bash
hostname=$1
publicIP=$2
privateIP=$3
#change hostname and ip in /etc/sysconfig/network and /etc/hosts
cp -f /etc/hosts.bak /etc/hosts
cp -f /etc/sysconfig/network.bak /etc/sysconfig/network
sed -i "s/xxhostnamexx/$hostname/g" /etc/sysconfig/network /etc/hosts
sed -i "s/xxpublicipxx/$publicIP/g" /etc/hosts
hostname $hostname
#change ip addresses in /etc/sysconfig/network-scripts/ifcfg-eth0 and ifcfg-eth1
cd /etc/sysconfig/network-scripts/
cp -f ifcfg-eth0.bak ifcfg-eth0
cp -f ifcfg-eth1.bak ifcfg-eth1
sed -i "s/xxpublicipxx/$publicIP/g" ifcfg-eth0
sed -i "s/xxprivateipxx/$privateIP/g" ifcfg-eth1
service network restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment