View previous topic :: View next topic |
Author |
Message |
Braempje l33t
Joined: 31 Jan 2003 Posts: 748
|
Posted: Sun Jan 09, 2005 9:33 am Post subject: Setting hostname and domainname when using DHCP |
|
|
Most manuals regarding hostnames require a fixed IP. When going dynamic this doesn't work anymore...
Files you should change:
- /etc/hostname
- /etc/hosts
- /etc/dnsdomainname
- /etc/nisdomainname
In this howto we shall use gentoo as our hostname and localnetwork as our domainname
1) make sure /etc/hostname contains only your hostname:
Code: | echo gentoo > /etc/hostname |
2) /etc/hosts should contain:
Code: | 127.0.0.1 gentoo.localnetwork gentoo localhost | Do mind the order, it's important!
3) /etc/dnsdomainname should contain localnetwork
Code: | echo localnetwork > /etc/dnsdomainname |
4) make /etc/nisdomainname a symlink to dnsdomainname:
Code: | cd /etc
ln -s dnsdomainname nisdomainname |
5) make sure domainname is start at boot
Code: | rc-update add domainname default |
(If it's already there it will give a warning)
6) start domainname
Code: | /etc/init.d/domainname start |
7) check your configuration:
Code: | # hostname
gentoo
# domainname
localnetwork
# hostname --fqdn
gentoo.localnetwork |
Some people reported a reboot is necessary to make settings permanent. That's not the linux way of doing things, but it might be necessary. _________________ Dictionary of the Flemish Sign Language - Woordenboek Vlaamse Gebarentaal |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Sun Jan 09, 2005 6:53 pm Post subject: |
|
|
Newer (~) baselayouts (and etc) have the dnsdomainname and nisdomainname in /etc/conf.d/domainname and the hostname in /etc/conf.d/hostname. Upgrading will just give warnings if you are not setting it there though and still use the old values. |
|
Back to top |
|
|
comprookie2000 Retired Dev
Joined: 25 Jul 2004 Posts: 925 Location: Sun City Center, Florida
|
|
Back to top |
|
|
Azerix Guru
Joined: 19 Dec 2004 Posts: 346 Location: NL
|
Posted: Sun Jan 09, 2005 10:45 pm Post subject: |
|
|
i am trying to use gentoo as router, but dhcpd is not starting, do you i think i have do that too, do you think i have to setup dnsdomein, hostanme en localnetwork? |
|
Back to top |
|
|
Braempje l33t
Joined: 31 Jan 2003 Posts: 748
|
Posted: Mon Jan 10, 2005 6:56 am Post subject: |
|
|
comprookie2000 wrote: | Thanks Braempje,If I'm using a static will this way be O.K? | Static IP users can use the following format for /etc/hosts:
Code: | 127.0.0.1 localhost
1.2.3.4 gentoo.localnetwork gentoo |
where 1.2.3.4 should be replaced by your static IP. _________________ Dictionary of the Flemish Sign Language - Woordenboek Vlaamse Gebarentaal |
|
Back to top |
|
|
Braempje l33t
Joined: 31 Jan 2003 Posts: 748
|
Posted: Mon Jan 10, 2005 6:57 am Post subject: |
|
|
Azerix wrote: | i am trying to use gentoo as router, but dhcpd is not starting, do you i think i have do that too, do you think i have to setup dnsdomein, hostanme en localnetwork? | hostname etc don't matter for dhcp, at least not for starting it _________________ Dictionary of the Flemish Sign Language - Woordenboek Vlaamse Gebarentaal |
|
Back to top |
|
|
mattheweast Tux's lil' helper
Joined: 17 Sep 2004 Posts: 121 Location: London, UK
|
Posted: Tue Jan 11, 2005 1:58 pm Post subject: |
|
|
EDITED:
Hi there, thanks for the guide, although I have had some slight problems. Although I originally posted my reply here, I've now moved it to a support forum, realising the error of my ways
It is at https://forums.gentoo.org/viewtopic.php?p=1966528
Thanks again!
Matt |
|
Back to top |
|
|
Tolstoi l33t
Joined: 20 May 2004 Posts: 678
|
Posted: Sat Jan 15, 2005 9:59 am Post subject: |
|
|
Thanks, that worked. Searched a long time for such a guide. |
|
Back to top |
|
|
comprookie2000 Retired Dev
Joined: 25 Jul 2004 Posts: 925 Location: Sun City Center, Florida
|
Posted: Tue Feb 01, 2005 8:17 pm Post subject: |
|
|
Braempje wrote: | comprookie2000 wrote: | Thanks Braempje,If I'm using a static will this way be O.K? | Static IP users can use the following format for /etc/hosts:
Code: | 127.0.0.1 localhost
1.2.3.4 gentoo.localnetwork gentoo |
where 1.2.3.4 should be replaced by your static IP. |
I still had to add Code: | 127.001 gentoo.localnetwork gentoo localhost | for hostname --fqdn to give me the correct reply;
Mine is like this now Code: | 127.0.0.0 gentoo.localnetwork gentoo
1.2.3.4 gentoo.localnetwork |
Is this O.K. _________________ http://dev.gentoo.org/~dabbott/ |
|
Back to top |
|
|
Braempje l33t
Joined: 31 Jan 2003 Posts: 748
|
|
Back to top |
|
|
wildcart n00b
Joined: 19 Oct 2004 Posts: 11
|
Posted: Sat Oct 29, 2005 12:44 am Post subject: |
|
|
This works fine... but I still have a problem that someone might be able to solve.
Your method assumes that the dns domainname is set using /etc/init.d/domainname but it does not consider that the dns domainname might be changed by the dhcp client. Does anyone have any ideas how to solve this problem? I cannot set the dns domainname statically on my laptop because I travle between to locations requiring me to have the domainname of the location I am at.
Right now I create the
Code: | 127.0.0.1 gentoo.localnetwork gentoo localhost |
line in the /etc/conf.d/net postup function using sed but there might be a better way.
While I am asking: I have the same problem with nis / yp. What I do right now is calling /bin/domainname `grep domain /etc/yp.conf|awk '{print $2}'` in the postup function like its suggested in /etc/init.d/domainname. Again there should be something better solution. Also why do I have to run domainname <DOM> anyways? The /etc/yp.conf file is setup by the dhcp client and /etc/init.d/ypbind is started after the network interface is set up. Since ypbind is supposed to use /etc/yp.conf as its config file I wonder why it reads the yp server but not the yp domainname from that file.
Don't I see the obvious??? |
|
Back to top |
|
|
|