We have requirement to add custom hostname for gateway IP and access the gateway through hostname instead of IP address.
We tried below ways in RDKB RPI
- In case of Raspberry Pi /etc/hosts already contains hostname as "RaspberryPi", we try to rename to custom hostname , we are able to ping in Rpi environment but this hostname is not reachable from any other device in the same network.
Note : Able to ping from IP address.
- we try to set hostname using syscfg command , and restart dhcp service but change is not reflecting and hostname is reset back to "RaspberryPi"
- we tried to modify dnsmasq.conf by adding domain=<custom_hostname> address=/<custom_hostname>/10.0.0.1, the result was same
- we observed that after reboot the change is not persisting in /etc/hosts file.
How to set hostname to gateway ip and persist after reboot?
5 Comments
user-3ffc2
Hi Unknown User (divya.khasnis),
The steps to set the hostname and persist after reboot are as follows:
syscfg set hostname <new-name>
Now the rpi comes up with the new hostname. The same will be reflected in /etc/hosts and in /etc/hostname .
The command to check the hostname on terminal is "hostname".
Please try the above steps and let us know how it works.
Regards,
Priyankaa KVB
Unknown User (divya.khasnis)
Hi Unknown User (priyankaa.kvb)
Thanks for the quick reply . The above steps did not work for us below are screen shot for the output. Kindly let us know if we are missing something
Regards,
Divya.
user-3ffc2
Hi Unknown User (divya.khasnis),
Could you please confirm the below details
Regards,
Priyankaa KVB
Unknown User (divya.khasnis)
Hi Unknown User (priyankaa.kvb)
We tried hostname without .com it works we are able to ping hostname from another device in same network, so we try to add hostname "agent.nagra.com" and following parameters to /etc/dnsmasq.conf and reboot still we are not able to ping from other device. Let us know how to resolve this domain.
/etc/dnsmasq.conf contents
--------------------------------
domain-needed
local =/agent.nagra.com/
address=/agent.nagra.com/10.0.0.1
expand-hosts
domain=agent.nagra.com
Note:
we observed "agent.nagra" as hostname also does not work, only works without dot and .com (example: agent)
Regards,
Divya.
user-3ffc2
Hi Unknown User (divya.khasnis),
Please find the below details for your queries
ps | grep dns
kill -9 <pid>
dnsmasq -u nobody --dhcp-authoritative -P 4096 -C /var/dnsmasq.conf
It depends on the network you are working on. Check your network dns server and configure it. You can check with your ISP for the domain name in dns server. You can also use other DNS server like Google DNS or OpenDNS as an alternative.
C:\Users\priyankaa.kvb>ping agent.nagra.com Pinging agent.nagra.com [10.0.0.1] with 32 bytes of data: Reply from 10.0.0.1: bytes=32 time=1ms TTL=64 Reply from 10.0.0.1: bytes=32 time=3ms TTL=64 Reply from 10.0.0.1: bytes=32 time=6ms TTL=64 Reply from 10.0.0.1: bytes=32 time=3ms TTL=64 Ping statistics for 10.0.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 6ms, Average = 3ms
The configurations of setting hostname, rebooting and nameserver under /etc/resolv.conf should be fine .
Regards,
Priyankaa KVB