Skip to content

Instantly share code, notes, and snippets.

@jtcmedia
Forked from kaspernissen/hostname_and_ip.sh
Last active August 24, 2018 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtcmedia/0070bd3ff18cdaaf008998263a7d5c96 to your computer and use it in GitHub Desktop.
Save jtcmedia/0070bd3ff18cdaaf008998263a7d5c96 to your computer and use it in GitHub Desktop.
Script for configuring hostname and static ip of rasbian
#!/bin/sh
hostname=$1 # k8s-node-X
ip=$2 # should be of format: 10.0.0.X
# Change the hostname
sudo hostnamectl set-hostname $hostname
sudo sed -i s/raspberrypi/$hostname/g /etc/hosts
# Set the static ip
sudo cat <<EOT >> /etc/dhcpcd.conf
interface eth0
static ip_address=$ip/24
static routers=10.0.0.1
static domain_name_servers=192.168.2.1
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment