Do you SSH and/or ping a lot of servers under the same domain name? Ever get tired of typing the same domain name multiple times a day? E.G.:
ssh server1.ourcompanysname.com
ssh server2.ourcompanysname.com
ping merp.ourcompanysname.com
Easily setup your machines to automatically fill it in for you. Instead you’ll be able to:
ssh server1
ssh server2
ping merp
Here’s how on Ubuntu 14.04:
- Edit your /etc/resolvconf/resolv.conf.d/base file with your favorite editor:
sudo vi /etc/resolvconf/resolv.conf.d/base
- Add lines like this and save your changes:
search ourcompanysname.com
- Now update resolvconf with:
sudo resolvconf -u
- That’s it!
Here’s how on Ubuntu (older versions):
- Edit your /etc/network/interfaces file with your favorite editor:
sudo vi /etc/network/interfaces
- Under each interface (if you have more than one) look for a ‘dns-search’ line, and create it if it’s not there. The file should end up looking something like this:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 123.123.123.123 netmask 255.255.255.0 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 8.8.8.8 8.8.4.4 dns-search ourcompanysname.com
- After saving your changes, restart networking:
sudo /etc/init.d/networking restart
- That’s it!
Here’s how on Mac OS X: (I’m using Mountain Lion.)
- Both view and edit your settings with the ‘networksetup’ command.
- First check what network interfaces you have:
sudo networksetup -listallnetworkservices
- If you’re like me, you’ll only need to setup search domains for the ‘Ethernet’ and ‘Wi-Fi’ interfaces.
- Check if there are already any set; you’re likely to see “There aren’t any Search Domains set on [interface].”:
sudo networksetup -getsearchdomains Ethernet
sudo networksetup -getsearchdomains Wi-Fi
- Set a new search domain for each interface you use:
sudo networksetup -setsearchdomains Ethernet ourcompanysname.com
sudo networksetup -setsearchdomains Wi-Fi ourcompanysname.com
- That’s it!