cancel
Showing results for 
Search instead for 
Did you mean: 

TG585 - setting DHCP hostname and same IP address

starfry
Rising Star
Posts: 303
Thanks: 23
Fixes: 2
Registered: ‎14-09-2007

TG585 - setting DHCP hostname and same IP address

I have the Plusnet router (TG585 v7, 8.2.6.5)  and I want to set up some devices so they are always served the same IP address from DHCP and I would like to give them a meaningful hostname so I can access them over my lan using a sensible name.
I've been trying to use the browser gui to change a device from a name like "Unknown-00-16-e8-1f-8e-4e" to something more meaningful (like "mydevice"). I also check the "Always use the same IP address" box. The changes seem to work until the device is powered off - then the router forgets what I have done. When the device is next powered on you get the old "unknown... name back and the IP checkbox is cleared.
Am I doing this wrong, or can't the router work as I hope ? All i want to do is define usable names for some devices and have then always have the same address.
If the way to do this is via telnet, that is fine - I can do that.
Any help much appreciated.
11 REPLIES 11
jelv
Seasoned Hero
Posts: 26,785
Thanks: 971
Fixes: 10
Registered: ‎10-04-2007

Re: TG585 - setting DHCP hostname and same IP address

I've assigned my PCs static IP addresses in the same subnet but outside the DHCP range. I've then added entries to C:\Windows\System32\drivers\etc\lmhosts
I can access all machines by name.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£14.40/month)
Mobile: iD mobile (£4/month)
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: TG585 - setting DHCP hostname and same IP address

Quote from: starfry
I've been trying to use the browser gui to change a device from a name like "Unknown-00-16-e8-1f-8e-4e" to something more meaningful (like "mydevice"). I also check the "Always use the same IP address" box. The changes seem to work until the device is powered off - then the router forgets what I have done. When the device is next powered on you get the old "unknown... name back and the IP checkbox is cleared.

The DHCP server adds the device name to a working copy of the router's hosts file so that the device can be reached by name provided the router is used for DNS lookup. However as you have found a fresh working copy of the hosts file is created when the router is restarted and the previous association is lost.
If you allocate static IPs to your computers (use IPs below the start of the DHCP range at 192.168.1.64), then telnet into the router and run…

dns server host add name = <string> [addr = <ip-address>] [ttl = <number>]
where:
  name = <string>
    The name of an IP host to add.
  [addr = <ip-address>]
    The IP address of the host.
  [ttl = <number>]
    The lifetime of the host
for each computer followed by
saveall
For reference
dns server host list
will list known hosts

… I know one can use the name to reach the computer; I'm hoping 'saveall' will retain the table across restarts (though not across a factory reset).
David
helix
Dabbler
Posts: 12
Registered: ‎04-08-2007

Re: TG585 - setting DHCP hostname and same IP address

Quote from: spraxyt

If you allocate static IPs to your computers (use IPs below the start of the DHCP range at 192.168.1.64), then telnet into the router and run?

dns server host add name = <string> [addr = <ip-address>] [ttl = <number>]
where:
   name = <string>
     The name of an IP host to add.
   [addr = <ip-address>]
     The IP address of the host.
   [ttl = <number>]
     The lifetime of the host
for each computer followed by
saveall
For reference
dns server host list
will list known hosts

? I know one can use the name to reach the computer; I'm hoping 'saveall' will retain the table across restarts (though not across a factory reset).

Yes, 'saveall' will retain the table across restarts. A factory reset will erase it.
starfry
Rising Star
Posts: 303
Thanks: 23
Fixes: 2
Registered: ‎14-09-2007

Re: TG585 - setting DHCP hostname and same IP address

Thanks for this information, and the delay in responding - I've been working on something else. I have already got static hosts working fine using commands similar to what you have suggested. What I am trying to do is set host names for DHCP hosts that, for whatever reason, don't send their host name to the DHCP server (hosts that do, for example, would have a 'send host-name' entry in their DHCP client config). Certain devices (especially non-computer devices) tend not to do this and end up being identified as 'Unknown' + their MAC address. It is that name for those kinds of devices that I want to modify.

In the web GUI, you can change a device's name via Home>Home Network>Devices>Configure and I b
elieve the CLI command area for this is "hostmgr" as in:

{admin}[hostmgr]=>help add
Add host device
Syntax : add mac_addr = <hardware-address>
            [host_type = <{Generic|Desktop|Laptop|STB|PDA|GS|Phone|GSM|
                          Printer|MassStorage|None}>]
            [host_name = <string>] [user_friendly_name = <quoted string>]
            [dns_name = <string>]
            [type = <{Unknown|L2-FXS|L2-USB|L2-BT|L3-IP|L7-UPNP|L2-PPPOERELAY|
                    L2-WLAN}>]
            [interface = <string>] [ip_intf = <string>]
Parameters :
  mac_addr = <hardware-address>
    Host MAC address
  [host_type = <{Generic|Desktop|Laptop|STB|PDA|GS|Phone|GSM|Printer|
                MassStorage|None}>]
    Host type
  [host_name = <string>]
    Host name
  [user_friendly_name = <quoted string>]
    Host user friendly name
  [dns_name = <string>]
    Host DNS name
  [type = <{Unknown|L2-FXS|L2-USB|L2-BT|L3-IP|L7-UPNP|L2-PPPOERELAY|L2-
          WLAN}>]
    Host connection type
  [interface = <string>]
    Host Ethernet interface XREF
  [ip_intf = <string>]
    Host IP interface XREF

Although the CLI guide lists all of the commands it isn't much good in understanding what the parameters and outputs are.  There doesn't seem to be a way to update a record - you instead have to overwrite with a new one, specifying all the parameters. I've tried 'hostmgr add mac_addr = 34:f9:e3:fe:41:4a host_name = myname' but this just overwries the original record with an incomplete one, which is shortly overwritten with what was there before. I imagine using 'hostmgr add' is the wrong way to do this.
If anyone knows the proper way to change the name of a DHCP host in the router configuration it would be a great help. If the GUI can do it, so there surely must be a way...?
(yes, I know I could just edit /etc/hosts but I don't want to for a number of reasons - including the fact that it's then distributed across several machines and also that some nodes can see their IP addresses change. I know I can lock a specific IP but that shouldn't be necessary if name resolution works).
pengbo
Grafter
Posts: 104
Registered: ‎15-01-2013

Re: TG585 - setting DHCP hostname and same IP address

Quote from: starfry
Although the CLI guide lists all of the commands it isn't much good in understanding what the parameters and outputs are.  There doesn't seem to be a way to update a record - you instead have to overwrite with a new one, specifying all the parameters.

Many routers/managed switches are like this.  Cisco OS is a PITA like this but on the command line you just have to live with it.  Copy and paste become your friend.  If you are using telnet from a windows OS make sure the CMD window has the advanced editing features turned on.
ejs
Aspiring Hero
Posts: 5,442
Thanks: 631
Fixes: 25
Registered: ‎10-06-2010

Re: TG585 - setting DHCP hostname and same IP address

Looking at the CLI reference, there's "hostmgr update" which looks like an edit version of "hostmgr add".
Edit: wrong CLI guide.
PeeGee
Pro
Posts: 1,217
Thanks: 84
Fixes: 3
Registered: ‎05-04-2009

Re: TG585 - setting DHCP hostname and same IP address

Open a telnet session and use the commands (insert host name, MAC and IP as required):
dhcp server lease add clientid=01:4c:72:b9:25:c4:82 pool=LAN_private leasetime=0 expirytime=0 addr=192.168.1.62 macaddr=4c:72:b9:25:c4:82 allocation=manual
hostmgr add mac_addr=4c:72:b9:25:c4:82 ip_addr=192.168.1.62 name=laptop type=laptop_computer ipintf=LocalNetwork
dns server host add name=laptop addr=192.168.1.62 ttl=1200
Note that this method allows you to define MAC addresses that do not start "00:" as well (which the GUI does not).
Edit: The clientid is the MAC address preceded by "01:"  - if you had not spotted it  Roll_eyes
Edit 2: type can take the values: {generic_device|desktop_computer|laptop_computer|set_top_box|pda|gaming_console|phone|mobile_phone|printer|mass_storage_device}
Plusnet FTTC (Sep 2014), Essentials (Feb 2013); ADSL (Apr 2009); Customer since Jan 2004 (on 28kb dial-up)
Using a TP-Link Archer VR600 modem-router.
starfry
Rising Star
Posts: 303
Thanks: 23
Fixes: 2
Registered: ‎14-09-2007

Re: TG585 - setting DHCP hostname and same IP address

Quote from: PeeGee
dhcp server lease add clientid=01:4c:72:b9:25:c4:82 pool=LAN_private leasetime=0 expirytime=0 addr=192.168.1.62 macaddr=4c:72:b9:25:c4:82 allocation=manual
hostmgr add mac_addr=4c:72:b9:25:c4:82 ip_addr=192.168.1.62 name=laptop type=laptop_computer ipintf=LocalNetwork
dns server host add name=laptop addr=192.168.1.62 ttl=1200

Thanks for this, it does just what I need. However... nothing is ever easy. When I add  a server lease (the first line) my router often spontaneously reboots. It's also happened when deleting leases. I don't know why this is. I wanted to create a second DHCP pool for statically allocated addresses (just to keep them separate) but it keeps crashing whenever I try to add leases. Any ideas?
Also can you explain what the 'hostmgr' does ? I understand the dhcp server lease and the dns server but not the hostmgr.
What version of the CLI document should I be using? I found the commands that I needed were slightly different to what you wrote (and also different to the CLI v6 (r8.2) guide that I have):

dhcp server lease add clientid=01:00:12:21:1f:81:4e pool=dynamic_pool leasetime=0 expirytime=0 addr=10.0.2.222 macaddr=00:16:e8:1f:8e:4e
hostmgr add mac_addr=00:12:21:1f:81:4e host_type=MassStorage host_name=myhost ip_intf=LocalNetwork
dns server host add name=myhost addr=10.0.2.222 ttl=1200

starfry
Rising Star
Posts: 303
Thanks: 23
Fixes: 2
Registered: ‎14-09-2007

Re: TG585 - setting DHCP hostname and same IP address

I've been looking into this a little more.
If I simply state the requirement as having the router supply a host name on its DNS for a DHCP client that did not send its host name, I think this should be achievable by mapping a host name with the host's MAC address. I believe this is done in the hostmgr with the following:

hostmgr add mac_addr=01:00:12:21:1f:81:4e host_name=myhost ip_intf=LocalNetwork

When the host connects and obtains an IP address from DHCP, that address is added to the hostmgr by the DHCP server and the host gets that  address. You can see this with "hostmgr list". What doesn't happen is the entry into the DNS for the IP address and host name. What also happens, and I don't know why, is the hostmgr entry will shortly thereafter change to another dynamic IP address.
The only way to make this happen (although I've been unable to get it to work) is to have the DHCP server give out a pre-determined IP address and manually enter that into the DNS, as per PeeGee's earlier reply:

dhcp server lease add clientid=01:00:12:21:1f:81:4e pool=dynamic_pool leasetime=0 expirytime=0 addr=10.0.2.222 macaddr=00:12:21:1f:81:4e allocation=manual
hostmgr add mac_addr=01:00:12:21:1f:81:4e host_name=myhost ip_intf=LocalNetwork host_type=MassStorage
dns server host add name=myhost addr=10.0.2.222 ttl=1200

(there is no ip_addr option to 'hostmgr')
I have found that doing anything manually with a DHCP lease (adding one, or deleting one) will sometimes (not always, but more often than not) cause the router to reboot. I don't know if that's a fault with mine or a common problem.
With the manual lease in place the host gets the expected IP address as specified when the lease was created. The hostmgr entry shows a different IP address though. Despite setting up DNS with the required IP address it is the one in hostmgr that gets returned to a DNS query (a ping from another computer). However flushing the dns on that computer caused the correct ip to show in hostmgr and the dns queries (pings) to start working.
All very strange and confusing and for such a simple requirement I have wasted far too long. Perhaps the firmware is just flawed ?
PeeGee
Pro
Posts: 1,217
Thanks: 84
Fixes: 3
Registered: ‎05-04-2009

Re: TG585 - setting DHCP hostname and same IP address

My reference manual is for the TG585v7 - CLI guide 7.4
I use a Linux system and copy/paste the update commands from a text file to a telnet session. Each line is actioned in sequence and I do not recall reboots. I last used the 8.2.6.5 firmware as well, but no longer use the 585 (except as backup).
Now you have some entries set, save the configuration file and edit that before reloading. Unfortunately, that guarantees a reboot  Sad
To add a new pool (which may cause a reboot), you can use the commands:
#
#  [ dhcspool.ini ]  Setup additional DHCP pools
#
dhcp server pool add name=LAN_wifi
#
#  [ dhcs.ini ]  Configure the pools to restrict connections
#
dhcp server pool config name=LAN_wifi state=enabled intf=LocalNetwork poolstart=192.168.1.50 poolend=192.168.1.53 netmask=24 gateway=192.168.1.40 server=192.168.1.40 primdns=192.168.1.40 secdns=208.67.222.222 localgw=enabled leasetime=0
or edit the ini file to add in the sections identified above:
pool add name=LAN_wifi
pool config name=LAN_wifi state=enabled allocation=dynamic intf=LocalNetwork poolstart=192.168.1.50 poolend=192.168.1.53 netmask=24 gateway=192.168.1.40 server=192.168.1.40 primdns=192.168.1.40 secdns=208.67.222.222 localgw=enabled
You can, I believe, set pools for 192.168 and 10.0 addresses, but have not tried that.
Edit: I note in you first reply that the clientid did not match the mac address in hostmgr add
ip_addr option is listed in the 7.4 manual
Phil
Plusnet FTTC (Sep 2014), Essentials (Feb 2013); ADSL (Apr 2009); Customer since Jan 2004 (on 28kb dial-up)
Using a TP-Link Archer VR600 modem-router.
starfry
Rising Star
Posts: 303
Thanks: 23
Fixes: 2
Registered: ‎14-09-2007

Re: TG585 - setting DHCP hostname and same IP address

I too have the CLI 7.4 guide but it is definately out of date in relation to the "I Plusnet 8.2.6.5.IU" firmware that I have.
I have taken the route of performing a backup, editing the ini file and the  doing a restore to upload it. I have got the router to do what I want this way.
I found it to really random whether a restore would work or not. On some occasions I ended up having to completely reset the router to get back onto it after loading a restore. I must say I don't find the router reliable enough when performing admin tasks on it. It's fine when running if you just leave it well alone but, as soon as you need to make any changes, your chances of success appear to be somewhat random.
I uploaded a config file today, one I'd uploaded before without issue, and I was effectively locked out of the router (and so my users lost their internet!!!). After about a dozen attempts with the same file over about an hour, it eventually loaded but the upshot is that i have little confidence to make other changes.
Time to buy another better router perhaps.... any suggestions?
Before resorting to the ini-file approach, I did knock together a python script that I used to allow me to write scripts of telnet commands. It connects to the remote device over telnet, reads commands from a script  and executes them across the telnet session. If anyone might find it of use: https://raw.github.com/johnlane/random-toolbox/master/usr/bin/telscript. It's a shame the router's CLI interface is so c**p!!!
One other thing I wondered about the TG585... is there any difference between a "saveall" and a "config save" ...?