Need help with hostnames setup

I navigated to the page with the hostnames and entered both static IPs from my raspi web server and from the router itself. Neither of these have a static DHCP lease (yet) but both are configured to always have the same IP.

I was assuming that if I type something along the lines of

ping -c4 raspi-server-web

on my laptop, where "raspi-server-web" is the given hostname that should work but it doesn't. I also tried raspi-server-web.lan and it doesn't work either. I have also already restarted the device to no avail.

I had this working before but with a local conf in /etc/hosts on my laptop (before I had my router with OpenWrt), so there shouldn't be any obstacles that I am not aware of.

Thank you for any help!

Please post the following in preformatted text </>
uci show network; uci show dhcp

# uci show network
network.loopback=interface
network.loopback.ifname='lo'
network.loopback.proto='static'
network.loopback.ipaddr='127.0.0.1'
network.loopback.netmask='255.0.0.0'
network.globals=globals
network.globals.ula_prefix='fd3c:14cc:0ffe::/48'
network.lan=interface
network.lan.type='bridge'
network.lan.ifname='eth1.1'
network.lan.proto='static'
network.lan.ipaddr='192.168.1.1'
network.lan.netmask='255.255.255.0'
network.lan.ip6assign='60'
network.wan=interface
network.wan.proto='dhcp'
network.wan.ifname='eth0'
network.wan6=interface
network.wan6.ifname='eth0'
network.wan6.proto='dhcpv6'
network.@switch[0]=switch
network.@switch[0].name='switch0'
network.@switch[0].reset='1'
network.@switch[0].enable_vlan='1'
network.@switch_vlan[0]=switch_vlan
network.@switch_vlan[0].device='switch0'
network.@switch_vlan[0].vlan='1'
network.@switch_vlan[0].ports='1 2 3 4 0t'

And:

# uci show dhcp
dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].domainneeded='1'
dhcp.@dnsmasq[0].boguspriv='1'
dhcp.@dnsmasq[0].filterwin2k='0'
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].rebind_protection='1'
dhcp.@dnsmasq[0].rebind_localhost='1'
dhcp.@dnsmasq[0].local='/lan/'
dhcp.@dnsmasq[0].domain='lan'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].nonegcache='0'
dhcp.@dnsmasq[0].authoritative='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.auto'
dhcp.@dnsmasq[0].nonwildcard='1'
dhcp.@dnsmasq[0].localservice='1'
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='100'
dhcp.lan.limit='150'
dhcp.lan.leasetime='12h'
dhcp.lan.dhcpv6='server'
dhcp.lan.ra='server'
dhcp.lan.ra_management='1'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.maindhcp='0'
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'
dhcp.@domain[0]=domain
dhcp.@domain[0].name='raspi-server-web'
dhcp.@domain[0].ip='192.168.1.10'
dhcp.@domain[1]=domain
dhcp.@domain[1].name='netgear-wnr2200-openwrt-router'
dhcp.@domain[1].ip='192.168.1.1'
dhcp.@domain[2]=domain

Do you get / use IP4 dhcp adresses?

1 Like

Yes, IP4. 192.168.1.1 and 192.168.1.10

//edit
Pinging with these raw IPs works.

Mhm, I think this could be a local config issue on my laptop. If I ssh into the router and try to ping the raspi server from there via hostname that works. Also if I ssh into the rapsi and try to ping the router with the hostname, that works too.

Nevertheless, ideas are welcome :stuck_out_tongue_winking_eye:

Any reason not to use static leases?
What DNS is your laptop using?

1 Like

If your lan devices use the OpenWrt router as NameServer they will be able to resolve internal names into IPs, as you have configured them properly.
To verify that, run the following:
nslookup raspi-server-web.lan 192.168.1.1

Only reason for not using static leases so far is that I only run this OpenWrt router since a week and now I basically know how the internet works and have my web server set up and running. I was yet too busy to bother changing a working setup.

When I do the

nslookup raspi-server-web.lan 192.168.1.1

both resolve fine so I think, as eduperez has also pointed out, it has something to do with how my laptop performs DNS resolving. I have upgraded this thing through from 14.04 so god help me please but I'll find it out.

Okay, it seems Ubuntu 18.04 uses 127.0.0.53, an internal DNS for resolving hostnames. Disabled it and manually configured my OpenWrt router as DNS and now it works :grinning:
Thank you for all your help!

This is most likely assigned by the Network Manager and points to some dnsmasq running on the Ubuntu.
It's possible that NetMan will overwrite the resolv.conf, so it's better if you make the change in NetMan rather than edit the resolv file.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.