Initial Commit

main
Graham Helton 1 year ago
commit 199144feaf

@ -0,0 +1,5 @@
# SetNet
A quick tool for automatically setting a static IP on an ubuntu machine using the `netplan` command.
# Usage
Set the IP for your gateway and DNS server inside the `setnet.sh`. SetNet will then grab the IP your ubuntu machine is currently using and set up a file in `/etc/netplan/` called `1-network-manager-all.yaml` with the configuration needed to assign your current IP as a static IP. It then runs `sudo netplan apply` to apply the changes.

@ -0,0 +1,26 @@
#!/bin/bash
PURPLE=`tput setaf 5`
GREEN=`tput setaf 2`
BLUE=`tput setaf 4`
RED=`tput setaf 1`
address=$(ip a | grep "2: " -A 2 | grep inet | awk '{print $2}')
dns="your.dns.server.ip"
gateway="your.gateway.ip"
echo -e $BLUE"Creating$PURPLE /etc/netplan/1-network-manager-all.yaml with the following settings$BLUE"
echo "network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses: [$address]
gateway4: $gateway
nameservers:
addresses: [$dns]" | tee /etc/netplan/1-network-manager-all.yaml
echo -e $GREEN"Applying Netplan settings"
sudo netplan apply
Loading…
Cancel
Save