setup basic networking

by yann
25 deployments · 12 still active · last rev. 9 years ago

- sets the hostname of the machine
- sets its private ip (assumes netmask is always

Compatible with: No distros currently supported
# <udf name="privip" label="private ip to install to eth0:0">
# <udf name="hostname" label="hostname">

echo "Setting Hostname to ${HOSTNAME}" >> $logfile
echo ${HOSTNAME} > /etc/hostname
hostname -F /etc/hostname

short=`echo ${HOSTNAME} | cut -d. -f1`
ip=`ip addr show label eth0 | grep 'inet ' | cut -d/ -f1 | awk '{print $2}'`
echo "Setting ip to $ip for $short" >> $logfile
echo -e "\n# our own entry\n${ip} ${HOSTNAME} ${short}" >> /etc/hosts

echo "Setting private interface address to ${PRIVIP}" >> $logfile
cat >>/etc/network/interfaces <<EOF

auto eth0:0
iface eth0:0 inet static
 address $PRIVIP

/etc/init.d/networking restart