-
-
Save jtcmedia/0070bd3ff18cdaaf008998263a7d5c96 to your computer and use it in GitHub Desktop.
Script for configuring hostname and static ip of rasbian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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