Need help with setting hostname

Hi
Total newbie. First time with openwrt and first time playing around with hostnames =)
I would like to access my gitlabserver by hostname.
This is only to be called inside my home network.
I did check some other posts, but they where not detailed enough.
Sorry if I missed some obvious tutorial/information somewhere.
And sorry for the weird url:s. Cannot post more than 2.

At the static leases I have

Hostname: gitlab.internal.com (temporarily made up name)
MAC-Address: 52:xx:xx:xx:xx:xx (gitlab.internal.com.lan) (I picked item in dropdownlist)
IPv4-Address: 192.168.1.121 (I picked the one already assigned. Should it be outside of dhcp range?)
Lease time: [Empty]
DUID: [Some value from dropdownlist]
IPv6: [Empty]

And then save & apply, no reboot.

I fire up mobaXterm and try to ssh to gitlab. internal. com. Does not work.
Then I try gitlab. internal. com. lan and that works.

When I browse to gitlab gui by IP, it works.
But if I try http : // gitlabrunner . internal . com/, I get 4100 dropped
and if I try with .lan at the end of the url - I get cannot display webpage

I have not set static IP on the gitlabserver.
I want to access my gitlabserver (both ssh and browser), by gitlab.internal.com.
Can you see what did I do wrong, or what have I misunderstood?
Using version: 18.06.4

Br, MrWrt

Easy solution:
Go to Network -> Hostnames and add the name and the IP.

Better add one, otherwise it might change and you'll need to change the hostname again. Or make sure there is the static dhcp lease in place.

1 Like

See post no 1.

The OP states that his static lease isn't working.

@MrWrt, welcome to the community!

This should work:

# in /etc/config/dhcp

config host
	option ip '192.168.1.121'
	option mac '52:xx:xx:xx:xx:xx'
	option name 'gitlab.internal.com'

If not, you can add:

# in /etc/config/dhcp

config domain
	option ip '192.168.1.121'
	option name 'gitlab.internal.com'

He doesn't say that.
He says that gitlab.internal.com doesn't work but gitlab.internal.com**.lan** works, which is expected.
And your suggestion will have the same result, as OpenWrt by default adds the .lan domain suffix.

OH!!!

True. (If referring to config host)

:+1:

Although, when I do a config domain, I don't get the appending .lan problem.

Correct, because the config domain is the same as adding a hostname in my first reply :wink:

1 Like

If you add option dns '1' to that stanza, local DNS resolution is being taken care of as well.

While not strictly necessary, keeping the static DHCP assignments outside the dynamic DHCP pool is a good idea as well.

@trendy
"Go to Network -> Hostnames and add the name and the IP." + add static ip on server.
What if the router is restarted and assigns a new IP?
Then you suggest static dhcp lease.
That is the one Im trying to get to work.

Please let me know if I misunderstood.

@lleachii
This what /etc/config/dhcp looks like (no changes made)

config host
        option name 'gitlab.internal.com'
        option dns '1'
        option mac '52:xx:xx:xx:xx:xx'
        option ip '192.168.1.121'
        option duid '[some id]'

It looks like your suggestion.

Of course I could try and add stuff here: /etc/config/dhcp
But, I still do not understand what I did wrong.

Br, MrWrt

If you have it configured and saved the configuration, it will not change. If on the other hand this server is so important, configure it with static IP, outside of the DHCP pool or at least create an entry in DHCP to make sure that no other host will be assigned this IP.

To achieve what the OP wants, requires to disable the domain option:

Otherwise follow the wiki:
https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#hostnames

Hi

Sorry for the delay.
I tried the easy way: "Network -> Hostnames and add the name and the IP."
At a first glance it seems to work exactly as I want it.

I will play around with this and see if it works in the long run.
It seems that it will based on your comments.
I will make a deeper dive into this if I find later on that it does'nt work when assigning IP:s etc.

Thanks to all of you

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