Skip to content

Instantly share code, notes, and snippets.

@zachbrowne
Created April 20, 2012 21:02
Show Gist options
  • Save zachbrowne/2431870 to your computer and use it in GitHub Desktop.
Save zachbrowne/2431870 to your computer and use it in GitHub Desktop.
Setup Linode.com static networking.
#!/bin/bash
###############################################################
# Static Networking Setup for Ubuntu 12.04 64bit Web Server #
# by Zach Browne - http://zachbrowne.com #
###############################################################
# Replace these variables with your own
HOSTNAME=apollo # Ex. server, dev or zeus
HOSTNAME_FQDN=zb11.zachbrowne.com # Ex. server.domain.com, dev.domain.com or zeus.domain.com
TIMEZONE=Central # Central, Eastern, Pacific or Mountain
LINODE_PUBLIC_IP=50.116.25.18
LINODE_SERVER_GATEWAY_IP=50.116.25.1
LINODE_PRIVATE_IP=192.168.175.26
LINODE_DNS_RESOLVER1=72.14.188.5
LINODE_DNS_RESOLVER2=72.14.179.5
# Set time & update server
ln -sf /usr/share/zoneinfo/US/$TIMEZONE /etc/localtime
aptitude update && aptitude -y safe-upgrade
# Setup hosts file
rm /etc/hosts
touch /etc/hosts
cat > /etc/hosts <<EOF
127.0.0.1 localhost.localdomain localhost
$LINODE_PUBLIC_IP $HOSTNAME_FQDN $HOSTNAME
EOF
# Setup static IP
rm /etc/network/interfaces
touch /etc/network/interfaces
cat > /etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0 eth0:1
iface eth0 inet static
address $LINODE_PUBLIC_IP
netmask 255.255.255.0
gateway $LINODE_SERVER_GATEWAY_IP
iface eth0:1 inet static
address $LINODE_PRIVATE_IP
netmask 255.255.128.0
EOF
# Remove DHCP
aptitude -y remove dhcpcd
# Add options rotate
rm /etc/resolv.conf
touch /etc/resolv.conf
cat > /etc/resolv.conf <<EOF
search members.linode.com
nameserver $LINODE_DNS_RESOLVER1
nameserver $LINODE_DNS_RESOLVER2
options rotate
EOF
# Install Bind9 to cache Linode's DNS servers.
aptitude -y install bind9
rm /etc/bind/named.conf.options
touch /etc/bind/named.conf.options
cat > /etc/bind/named.conf.options <<EOF
{
directory "/var/cache/bind";
auth-nxdomain no;
forwarders {69.93.127.10;65.19.178.10;75.127.96.10;207.192.70.10;109.74.194.10;};
listen-on-v6 {any;};
};
EOF
# Restart networking
/etc/init.d/networking restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment