Skip to content

Instantly share code, notes, and snippets.

@carlsverre
Last active October 22, 2017 01:23
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 carlsverre/9695156bae9cda93870b7e7a07737165 to your computer and use it in GitHub Desktop.
Save carlsverre/9695156bae9cda93870b7e7a07737165 to your computer and use it in GitHub Desktop.

To add a raspberry pi running raspbian jessie to the network add the following lines to the end of /etc/dhcpcd.conf and reboot:

interface eth0
static ip_address=10.110.0.1/24
static routers=10.110.0.1

To add a linux machine to the network run the associate setup_network script:

sudo ./setup_network.sh up

To unconfigure a linux machine run:

sudo ./setup_network.sh down
#!/usr/bin/env bash
# Set this to your ethernet interface name plugged into the switch
ETH0=enp0s31f6
# Set this to the ip you want to have on the network
MYIP=10.110.0.128
# Set this to the static subnet the raspberry pi's are using
SUBNET=10.110.0.0/24
if [[ "${1}" == "up" ]]; then
ip addr add ${MYIP} dev ${ETH0}
ip route add ${SUBNET} dev ${ETH0}
elif [[ "${1}" == "down" ]]; then
ip addr del ${MYIP} dev ${ETH0}
ip route del ${SUBNET} dev ${ETH0}
else
echo "Usage: ${0} {up|down}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment