[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] IP address via DHCP




It's wonderful how an innocent query can spark off such interesting 
discussions.  Not that I understood much of them, of course :-)  Thanks 
to you all for your suggestions.  Just a few wee questions then :-)

home@alexhudson.com wrote

> 
>> This should be a simple one to answer.  I've looked at the man pages for 
>> dhcp etc.  I've looked in /var/state/dhcp and /etc etc. but I haven't 
>> found a good way to get my current IP address. 
> 
> ifconfig ?

right.  thanks Alex, that answered my main concern [tho' I'd hoped for a 
command that would give me just the IP address; of course I can filter 
the output from ifconfig myself though that would be fragile if the 
format changed].

>> On my old system, the hostname was automatically changed to my ipaddress
>> [which wasn't very convenient as I use hostname as part of my prompt
>> string...]
> 
> DHCP has a system whereby the server can suggest a name to a client, among
> other things - you could use this. You can also set specific leases to MAC
> addresses - basically, tying the IP address to a specific client. You can
> then set the hostname manually on the client.

via /etc/mactab I guess.  Presumably only of use to me if I set up a 
home network?

> 
>> pc-62-31-17-212-sh.blueyonder.co.uk
>> 
>> but instead it was set to just pc-62-31-17-212-sh
> 
> 
> The first is the fully-qualified name (FQDN), the second is just the
> hostname. Either are valid. 

Thanks for the explanation.  It isn't a pretty hostname, is it?  I guess 
I am better off not specifying DHCLIENT_SET_HOSTNAME="yes" in 
/etc/rc.config.d/dhcpcd.rc.config [which I think I managed to do via a 
highly complicated invocation under Yast2].  Then, for reasons I don't 
understand, the problems I mention below to do with resolv.conf don't 
arise. Thing is, I quite like the idea of having a fixed hostname of my 
choice (say "linux" for the sake of argument) and then being able to 
telnet to my machine as linux.blueyonder.co.uk; but I don't see any way 
of doing that automatically as it must mean altering some configuration 
in the remote machines I use everytime my home machine is rebooted and 
possibly gets a new IP address via DHCP.  So what I used to do was to 
automatically email the hostname set by DHCP at boot time to myself on 
my work network and use that; it so happens that the hostname was set to 
what you call the FQDN by stuff Gentus did that I didn't understand.  
Now I can just email the results of ifconfig to work instead; not as 
pretty but it works.  Or at least it would...

..if I knew how to do it!  Under Gentus (and I guess, Red Hat 
generally) there was this nice configuration file called 
/etc/rc.d/rc.local into which I inserted the line
mail -n -s `hostname` matt [at] dcs.shef.ac.uk < /etc/rc.d/start.msg
but SuSE doesn't seem to have an equivalent, and although I found plenty 
of files controlling different run levels, I couldn't decide where to start.

Are there any other advantages to setting the hostname via DHCP?

> It's likely that in /etc/resolv.conf you would
> have "domain blueyonder.co.uk", which would indicate that pc-62-31-17-212-sh
> is in the domain blueyonder.co.uk (and hence has the FQDN we see above).

I didn't, but if I add a line "domain blueyonder.co.uk" to 
/etc/resolv.conf then hostname -f gives the full hostname and most 
things seem to work fine after that (such as Gnome, which complains if 
the line is missing).  The only problem is that dhcpcd overwrites 
/etc/resolv.conf, so it seems I should specify the line domain 
blueyonder.co.uk in some other file.  Trouble is, I don't know which 
one.  Of course, an obvious suggestion from reading the comments in 
resolv.conf [below] is to set DHCLIENT_MODIFY_RESOLV_CONF=no; but I have 
no idea what else that might break since I don't understand where the 
nameserver settings come from or whether they might change from one 
invocation of  dhcpcd to another.  here is my /etc/resolv.conf in case 
it helps:

    ### BEGIN INFO
    #
    # Modified_by:  dhcpcd
    # Backup:       /etc/resolv.conf.saved.by.dhcpcd
    # Process:      /sbin/dhcpcd
    # Process_id:   224
    # Script:      
    # Info:         This is a temporary resolv.conf created by dhcpcd.
    #               If you don't like dhcpcd to change your nameserver
    settings,
    #               then either set DHCLIENT_MODIFY_RESOLV_CONF=no in
    #               /etc/rc.config.d/dhcpcd.rc.config, or set
    #               MODIFY_RESOLV_CONF_DYNAMICALLY=no in /etc/rc.config,
    #               or (manually) use dhcpcd with -R.
    #               If you only want to keep your searchlist, set
    #               DHCLIENT_KEEP_SEARCHLIST=yes in
    #               /etc/rc.config.d/dhcpcd.rc.config or (manually) use
    #               the -S option.
    ### END INFO
    
    nameserver 62.30.240.177
    nameserver 62.30.240.178
    search

I get the "search" line by setting DHCLIENT_KEEP_SEARCHLIST="yes" but 
where on earth is it searching?  Anyway, it isn't finding a domain, 
whereever it is looking.

>> which isn't much use as an IP address
> 
> 
> .. because it's not an IP address?

Fair point.  I am confusing domain names with IP addresses.  I find that 
for ftp, telnet purposes etc. that pc-62-31-17-212-sh.blueyonder.co.uk 
works as well as 62.31.17.212 (ok, I admit it is more longwinded and not 
easier to remember...) 

>> same theme, how do I change the hostname to something other than "linux"?
> 
> 
> /etc/hostname, among other methods.

Ok, the others have pointed out this doesn't exist on SuSE.  Never mind.

> 
> 
> These commands you also might find useful:
> 
> hostname -s		; the short host name
> hostname -f		; the FQDN

Yes, I do, thanks very much.

Matt.

-- 
 ------------------------------------------------
| Matt Fairtlough                                |     
| 22 Harley Road                                 |
| Sheffield S11 9SE UK  tel. 0114 236 2067       |
 ------------------------------------------------


---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word 
 "unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.