The URL for my printer generated by hp-makeuri looks like this:

hp:/net/Officejet_6500_E710n-z?ip=192.168.178.30

But the printer is on a dhcp enabled wifi network and so its IP-address does and could change. On the other hand my wifi router seems smart enough to have some sort of DNS:

$ ping hp-6500a
PING hp-6500a.fritz.box (192.168.178.30) 56(84) bytes of data.
64 bytes from hp-6500a.fritz.box (192.168.178.30): icmp_req=1 ttl=255 time=11.3 ms

I tried to use the hostname in the CUPS URL/DeviceUID but it failed, any suggestions if this is possible and the correct format?

up vote 3 down vote accepted

I think you can make use of ZeroConf here to dynamically find your printer. The syntax is like:

hp:/net/Officejet_6500_E710n-z?zc=printer

There, zc stands for ZeroConf, the mDNS implemented by avahi. On setting that URI, you may see some multicast network traffic to query the printer as can be seen in the partial tcpdump below.

root@ubuntu:/etc/avahi# tcpdump -vvvvvn -i wlan0 host 224.0.0.251
tcpdump: listening on wlan0, link-type EN10MB (Ethernet), capture size 65535 bytes
11:20:49.783337 IP (tos 0x0, ttl 255, id 0, offset 0, flags [DF], proto UDP (17), length 59)
    172.25.197.98.5353 > 224.0.0.251.5353: [udp sum ok] 0 A (QM)? printer.local. (31)
11:20:49.787975 IP (tos 0x0, ttl 255, id 44750, offset 0, flags [none], proto UDP (17), length 69)
    172.25.197.160.5353 > 224.0.0.251.5353: [udp sum ok] 0*- [0q] 1/0/0 printer.local. (Cache flush) [4m] A 172.25.197.160 (41)

DNS A records like printer.anintranet.example can be added to a dynamic zone by the DHCP server. The original domain name (anintranet.example) is discarded -- possibly because it is in the "search" directive of /etc/resolv.conf?-- and .local is added as part of the mDNS query.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.