Most servers and workstations have their own hostname or computer names. If your company has its own domain.com , and you are not the one managing your company? DNS servers, you can quickly configure and change your hostname using /etc/hosts.
This /etc/hosts file contains the list of IP addresses and their corresponding system host names.
Even servers have their own hostnames besides from their own web-known fully qualified domain names. Basically, for any DNS queries, your linux system check this file first before referencing further DNS queries with your /etc/resolv.conf DNS IPs. If the queried hostname is already found with a corresponding IP address then any further DNS queries is not anymore needed.
Say a sample /etc/hosts file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127.0.0.1 localhost
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you try to ping localhost
# ping localhost
you get
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.056 ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adding more host aliases to /etc/hosts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127.0.0.1 localhost
192.168.50.35 vertito
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ping vertito
would give your
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64 bytes from vertito (192.168.50.35): icmp_seq=1 ttl=127 time=3.26 ms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adding more host aliases to /etc/hosts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127.0.0.1 localhost localhost.localdomain
192.168.50.35 vertito vertito.yourdomain.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ping vertito.yourdomain.com
# ping vertito
Issuing the above commands would give your pretty same results, the same goes
# ping localhost
# ping localhost.localdomain
Now, knowing how hostnames are being traversed is really handy at times. You will see more samples below t get more overview of how hostnames are being traversed and looked up.
Below sample are not advisable:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192.168.50.35 vertito tito.yahoo.com
192.168.50.35 vertito tito.yourdomain.com
192.168.50.35 vertito vertito.yourdomain.com tito.yourdomain.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You may be able to ping them, but it would not be publicly available outside from web since outside DNS servers would be able to traverse them.
Another host name misuse:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192.168.50.35 vertito1
192.168.50.35 vertito2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192.168.50.35 vertito1.yourdomain.com
192.168.50.35 vertito2.yourdomain.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You could ping them locally, but doing reverse lookup from your workstation for that IP or hostname would still fail.
Moreover, setting your hostname via "hostname" linux command would be
# hostname vertito.yourdomain.com # SETS HOST NAME TO vertito.yourdomain.com
# hostname # DISPLAYS CURRENT HOSTNAME
Wrong!
# hostname vertito.yahoo.com
Doing hostname via CLI is not permanent.
Another way to permanently set your hostname is to append them to your /etc/sysconfig/network file :
# echo "HOSTNAME=vertito.yourdomain.com" >> /etc/sysconfig/network
# less /etc/sysconfig/network # should show you something like
HOSTNAME=ver.yourdomain.com
Now, if you eth0 IP address is given dynamically, that is via DHCP, you can set your hostname by having the below line into /etc/sysconfig/network-scripts/ifcfg-eth0
DHCP_HOSTNAME=ver.yourdomain.com
and restart your network service to renew your IP address from network DHCP server
# service network restart
Pretty nice.
Now, let us say your eth0 public IP address is 213.255.201.254 and vertito.domain.com is its
reverse DNS name delegated by your network DNS servers.
From your own system, adding the below into your /etc/hosts
213.255.201.100 vertito.otherdomain.com
Noticed the change of IP address and hostname which is not equal to your delegated reverse and forward DNS names from your DNS servers. Now
# ping 213.255.201.100
# ping vertito.mydomain.com
would be successful, this is pinging immediately without using /etc/resolv.conf and DNS, but
# nslookup vertito
# nslookup vertito.mydomain.com
# host vertito
would definitely fail using your DNS since your system doesn know its forward/reverse name so it asks your DNS server to do this for you.
Well, you find this long but interesting too!
Have a nice host day!
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
July
(107)
- AMSN messenger install howto
- firefox browser - yum update howto
- kopete messenger install howto
- Gaim pidgin messenger install howto
- xmms - multimedia player install howto
- UltraDMA - speedup your harddisk howto
- sabayon - user profile manager howto
- 50 quick linux command tips part 3
- No negotiations with Microsoft in progress
- connect SamSung D820 mobile to linux howto
- yum from ISO image or CD install howto
- missing portmap reinstall howto
- 50 quick linux command tips part 2
- 50 quick linux command tips part 1
- desktop wiki install howto
- NASA tests Linux for spacecraft control
- warzone 2100 strategy 3d game install howto
- motd - message of the day
- more with kernel name version howto
- stop and start networking service howto
- change network proxy preference howto
- alexa firefox toolbar plugin install howto
- reboot / halt system via CLI howto
- gparted partitioning install howto
- google picasa install howto
- pine and pico install howto
- adobe/macromedia flash player test and install howto
- realplayer install howto
- Microsoft's TrueType core fonts install howto
- Why Choose Fedora? (Fedora vs. Ubuntu)
- Microsoft vs Opensource
- the df command
- linux possessed by monsterz
- change display setting howto
- NTP clock synchronization howto
- qtparted partitioning magic install howto
- host name and host aliases explained
- IP aliasing - virtual IP howto
- viruskiller on linux
- change keyboard language setting
- changing ethernet card settings howto
- TIP: WiFi with chillispot and linux
- play tennis the linux way
- sudoku game install howto
- my linux box talked to me
- CD/DVD burning software install howto
- A SYSAD BLOG - LINUX: list out active host connect...
- list out active host connection howto
- more with linux command named history
- GnuPG and enigmail thunderbird add-ons
- PDF file readers install howto
- digikam - KDE photo management install howto
- gnome floppy formatter
- f-spot Gnome photo manager install howto
- VLC media player install howto
- ping IP subnet block howto
- TIP: find and delete files recursively
- list out opened host ports howto
- TIP: linux process priority scheduling management
- TIP: spammer sending email using squid
- remount partition as read only howto
- additional swap file howto
- CrossOver install howto
- system-config-securitylevel-tui and lokkit howto
- format a windows partition from linux hadrdisk
- TIP: monitoring while mounting USB devices
- zero-sized a file without permission / ownership c...
- TIP: auto create mail spool when adding user
- md5sum checksum howto
- IP address to country lookup howto
- gnome mail notification install howto
- add new harddisk to existing linux system
- TIP: block an IP address
- disk space report
- more trace route command alternatives
- changing your hardware / software clock howto
- other interesting ping commands
- send email via CLI howto
- adding static route howto
- send message to all logged in users
- unzip zip untar tar bzip2 bunzip2 gzip gunzip file...
- format of /etc/passwd, /etc/shadow and /etc/group
- remove user's cron jobs howto
- find the user's files howto
- passphraseless + passwordless ssh howto
- passwordless ssh howto
- X11 Forwarding via ssh howto
- skype install howto
- disable IPv6
- lsusb - list all USB devices
- make yum faster
- lspci - list all PCI devices
- kill a process
- beginners CLI guide for static ip address
- the pidof command
- retrieve data from mysql using bash script
- VirtualBox install howto
- call bash script inside php web page
- alternative linux browsers
- last / currently logged in users
-
▼
July
(107)
Saturday, July 21, 2007
host name and host aliases explained
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment