View Full Version : A question about /etc/hosts
pinenut
2006-02-25, 08:02 PM CST
According to the "Fedora Core 4 Linux Installation Notes (http://stanton-finley.net/fedora_core_4_installation_notes.html#Web), I have to put my etra-net (external ) IP address in /etc/hosts.
gedit /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
67.172.236.37 stantonfinley.org stantonfinley
I have a dynamic adress, which gets changed more often than like it to be.
Do I have to update this /etc/hosts file every time my IP address changes?
What does /etc/hosts do?
:confused:
Firewing1
2006-02-25, 08:28 PM CST
I wouldn't. I host a web site and don't have to do this. Just change the hostname:
su -
gedit /etc/hoststhis is the original file:# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost You want to change it to:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 hostname.localdomain localhost.localdomain hostname
Make hostname anything you want, as long as you keep it the same name. For example, if you chose the name "MyName", then the line would look like:
127.0.0.1 MyName.localdomain localhost.localdomain MyName
Remember to keep the .localdomain at the end.
Next, typesu -
gedit /etc/sysconfig/network
Change this line:HOSTNAME=localhost.localdomain
to:
HOSTNAME=hostname.localdomain
Once again, hostname must be the same that you chose before. And, once again, don't forget the .localdomain at the end.
Reboot.
Enjoy.
Firewing1
Sarthan
2006-02-25, 08:29 PM CST
You don't have to add a hostname for dynamic ip-addresses in your /etc/hosts file and may leave that line out without doing anything wrong to your system.
The /etc/hosts file is a way for the system to put a name to an internet address much like a DNS-server would do.
If you're using static ip-addresses you may want to add them to the /etc/hosts file if you're not going to run a DNS-server on that system.
pinenut
2006-02-25, 10:29 PM CST
Thank both of you for clarifying my confusion and making me feel relieved.
I don't know why the frequently referenced notes make such confusing statesments.
Type "ifconfig". Hit enter. This will output the IP address of your machine (the numbers after "inet addr:") or if you are behind a router or gateway go to http://checkip.dyndns.org/ or http://myipaddress.com/ to determine the IP address that the outside world sees for your machine and use that as your IP address in the following.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.