Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Setting hostname and domainname when using DHCP
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Braempje
l33t
l33t


Joined: 31 Jan 2003
Posts: 748

PostPosted: Sun Jan 09, 2005 9:33 am    Post subject: Setting hostname and domainname when using DHCP Reply with quote

Most manuals regarding hostnames require a fixed IP. When going dynamic this doesn't work anymore...
Files you should change:

  1. /etc/hostname
  2. /etc/hosts
  3. /etc/dnsdomainname
  4. /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
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Sun Jan 09, 2005 6:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
comprookie2000
Developer
Developer


Joined: 25 Jul 2004
Posts: 901
Location: Pompano Beach, Florida

PostPosted: Sun Jan 09, 2005 7:18 pm    Post subject: Reply with quote

Thanks Braempje,If I'm using a static will this way be O.K?
_________________
http://dev.gentoo.org/~dabbott/
Back to top
View user's profile Send private message
Azerix
Guru
Guru


Joined: 19 Dec 2004
Posts: 346
Location: NL

PostPosted: Sun Jan 09, 2005 10:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
Braempje
l33t
l33t


Joined: 31 Jan 2003
Posts: 748

PostPosted: Mon Jan 10, 2005 6:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Braempje
l33t
l33t


Joined: 31 Jan 2003
Posts: 748

PostPosted: Mon Jan 10, 2005 6:57 am    Post subject: Reply with quote

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
View user's profile Send private message
mattheweast
Tux's lil' helper
Tux's lil' helper


Joined: 17 Sep 2004
Posts: 121
Location: London, UK

PostPosted: Tue Jan 11, 2005 1:58 pm    Post subject: Reply with quote

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 http://forums.gentoo.org/viewtopic.php?p=1966528

Thanks again!

Matt
Back to top
View user's profile Send private message
Tolstoi
l33t
l33t


Joined: 20 May 2004
Posts: 644

PostPosted: Sat Jan 15, 2005 9:59 am    Post subject: Reply with quote

Thanks, that worked. Searched a long time for such a guide.
Back to top
View user's profile Send private message
comprookie2000
Developer
Developer


Joined: 25 Jul 2004
Posts: 901
Location: Pompano Beach, Florida

PostPosted: Tue Feb 01, 2005 8:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Braempje
l33t
l33t


Joined: 31 Jan 2003
Posts: 748

PostPosted: Wed Feb 02, 2005 2:18 pm    Post subject: Reply with quote

I wouldn't do it but if it works that's fine.
_________________
Dictionary of the Flemish Sign Language - Woordenboek Vlaamse Gebarentaal
Back to top
View user's profile Send private message
wildcart
n00b
n00b


Joined: 19 Oct 2004
Posts: 11

PostPosted: Sat Oct 29, 2005 12:44 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum