Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old November 5th, 2004   #1
FLeiXiuS
Extra Foam Sugar Free Ubuntu
 
FLeiXiuS's Avatar
 
Join Date: Oct 2004
Location: Binary Land, Maryland
Beans: 635
Send a message via AIM to FLeiXiuS
HOWTO: Editing /etc/hosts

Here is a quick how to, to edit your /etc/hosts file.
The $ represents a line of code you may enter in a terminal.

Open /etc/hosts with your favorite text editor. Remember to use sudo.

Code:
Format:
<IP> <HOSTNAME>.<DOMAIN> <ALIAS>

Example:
127.0.0.1 localhost.localdomain localhost
IP
Replace the <IP> with the IP of your system. If your running DHCP do not worry about editing this file. To detect your IP address run
Code:
$ lsconfig
Then browse for the connected interface (eth0, wlan0, etc)

Hostname
Replace the <HOSTNAME> to your systems hostname.
Code:
To view current hostname:
$ hostname

To change hostname:
$ sudo hostname 'enterhostname'
(without quotes)
Domain Name
The domain name can be anything you like unless it must be resolv, which then you must use /etc/resolv.conf. But thats another issue i'll cover later!

Alias
Alias are simply another way to combine a set of arguments. When you create a hosts file, its simply creating a list of hosts on the network, or locally. Its much easier to understand if you kept the alias the same as the hostname. It saves a lot of trouble with debugging and troubleshooting. But you are free to use whatever you like.


That should help you out. Please comment!
__________________
Regards,
FL-ei-|X|-iu-S
][ My Blog ][
FLeiXiuS is offline   Reply With Quote
Old November 6th, 2004   #2
diebels
Way Too Much Ubuntu
 
diebels's Avatar
 
Join Date: Oct 2004
Location: Arendal, Norway
Beans: 317
Re: HOWTO: Editing /etc/hosts

Nice. You can make shortcuts for webpages with alias
Code:
216.239.37.99 www.google.com g
Type ctrl+L,g,enter in firefox to go to google.
diebels is offline   Reply With Quote
Old December 1st, 2004   #3
hayalci
5 Cups of Ubuntu
 
hayalci's Avatar
 
Join Date: Nov 2004
Location: Ankara, Turkey
Beans: 42
Re: HOWTO: Editing /etc/hosts

you can do the same more practically by giving a keyword to a bookmark, in firefox.
Just go to bookmars->manage bookmarks
and open the bookmark's properties, entering the keyword and
clicking OK.

this link describes more, quick searches, which in my opinion are great:
http://www.mozilla.org/products/fire...-keywords.html
hayalci is offline   Reply With Quote
Old February 23rd, 2007   #4
victorbrca
Quad Shot of Ubuntu
 
victorbrca's Avatar
 
Join Date: Dec 2006
Location: Mississauga, ON, CA
Beans: 450
Ubuntu 9.04 Jaunty Jackalope
Send a message via ICQ to victorbrca Send a message via MSN to victorbrca Send a message via Skype™ to victorbrca
Re: HOWTO: Editing /etc/hosts

Would anyone know why this would not work on Edgy?

I'm trying to access my webserver in my LAN, however due to my firewall I cannot use the external address, I have to use my internal address to my DMZ.

I'd like to have my translation done like this HOST.DOMAIN = DMZ IP. It's very useful when looking at information posted on the web with the source on ur webserver.

Code:
victor@victor-laptop:~$ cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       victor-laptop
10.10.0.2     www.mysite.dyndns.org    home
72.14.203.99    www.google.ca   g

# 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
ff02::3 ip6-allhosts
The alias for google is also not working.

I also restarted my network and logged out and back in, but no doughnut..

Code:
sudo /etc/init.d/networking restart

Thanks,


Vic.
__________________
Your verbose output has been redirected to /dev/null
---------------------------------------------------------------------------------------
User 437407 with the Linux Counter -- My Site -- My Blog -- Backgrounds
victorbrca is offline   Reply With Quote
Old July 7th, 2009   #5
meonkeys
Just Give Me the Beans!
 
Join Date: Oct 2005
Beans: 47
Cool Re: HOWTO: Editing /etc/hosts

Related links:
What I can't find is a simple, complete best/standard practices guide on how to set the hostname for a laptop and for a box with a static IP and FQDN.
meonkeys is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:36 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry