Free Static Networking Script to Setup Your Linode Server
#!/bin/bash
# Static Networking Setup for Ubuntu Web Server
# by Zach Browne - http://zachbrowne.com
# Replace these variables with your own
HOSTNAME=zeus # Ex. server, dev or zeus
HOSTNAME_FQDN=zeus.browne.cm # Ex. server.domain.com, dev.domain.com or zeus.domain.com
TIMEZONE=Central # Central, Eastern, Pacific or Mountain
LINODE_PUBLIC_IP=96.126.124.64
LINODE_SERVER_GATEWAY_IP=96.126.124.1
LINODE_PRIVATE_IP=192.168.147.82
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="" cat="">/etc/network/interfaces < <eof auto="" lo="" iface="" inet="" loopback="" eth0="" eth0:1="" static="" address="" $linode_public_ip="" netmask="" 255.255.255.0="" gateway="" $linode_server_gateway_ip="" $linode_private_ip="" 255.255.128.0="" eof="" #="" remove="" dhcp="" aptitude="" -y="" dhcpcd="" add="" options="" rotate="" rm="" etc="" resolv.conf="" touch="" cat="">/etc/resolv.conf < <eof search="" members.linode.com="" nameserver="" $linode_dns_resolver1="" $linode_dns_resolver2="" options="" rotate="" eof="" #="" install="" bind9="" to="" cache="" linode's="" dns="" servers.="" aptitude="" -y="" rm="" etc="" bind="" named.conf.options="" touch="" cat="">/etc/bind/named.conf.options <</eof></eof></eof>
5 Replies
@zachbrowne:
aptitude update && aptitude -y safe-upgrade aptitude -y remove dhcpcd aptitude -y install bind9
Is "aptitude" a CentOS command? Gentoo? Ubuntu only?
James
timezone in a static networking script? and US only?
rm and touch are redundant if you do cat >
hostname should be taken out of fqdn automatically:
HOSTNAME=`echo $HOSTNAME_FQDN | awk -F"." '{print $1}'`
@zunzun:
Is "aptitude" a CentOS command? Gentoo? Ubuntu only?
James
The "for Ubuntu Web Server" in the very first comment of the script seems pretty clear to me…
That said, I'm not sure that this script is the greatest idea. A static IP setup requires you to merely update a few config files, not to update packages or uninstall dhcpcd or install bind…