Created
March 1, 2016 08:35
-
-
Save jorgecasas/64b122b7d63253e208f2 to your computer and use it in GitHub Desktop.
Linux - Change hosts file automatically depending on WiFi
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 | |
# Script to change hosts file when your router does not allow ip loopback | |
# | |
# Save it in /etc/NetworkManager/dispatcher.d | |
wifi=`iwgetid -r`; | |
if [ $wifi = 'ESSID_WIFI' ]; | |
then | |
cat /etc/hosts.common /etc/hosts.in > /etc/hosts | |
else | |
cat /etc/hosts.common /etc/hosts.out > /etc/hosts | |
fi |
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
127.0.0.1 localhost | |
127.0.1.1 my-laptop | |
# The following lines are desirable for IPv6 capable hosts | |
::1 ip6-localhost ip6-loopback | |
fe00::0 ip6-localnet | |
ff00::0 ip6-mcastprefix | |
ff02::1 ip6-allnodes | |
ff02::2 ip6-allrouters | |
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
# Host LAN | |
192.168.1.5 server.domain.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment