Last active
July 6, 2018 19:06
-
-
Save fabiogomezdiaz/1bcd8badb72c8acb2bab0aabdd76682e to your computer and use it in GitHub Desktop.
Ubuntu: Assign IP
This file contains hidden or 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/bash | |
# Become root | |
sudo su | |
# Update /etc/network/interfaces | |
NEW_IP=$(ip route get 8.8.8.8 | awk '{print $NF; exit}') | |
sed -i 's/dhcp/static/g' /etc/network/interfaces | |
echo " address ${NEW_IP}" >> /etc/network/interfaces | |
echo " netmask 255.255.0.0" >> /etc/network/interfaces | |
echo " broadcast 172.16.255.255" >> /etc/network/interfaces | |
echo " gateway 172.16.255.250" >> /etc/network/interfaces | |
echo " dns-nameservers 172.16.0.11 172.16.0.17" >> /etc/network/interfaces | |
echo " dns-search csplab.local" >> /etc/network/interfaces | |
# Restart | |
shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment