how to change dns domain name from command line

Does anyone know how to change the DNS domain name from command line?

I attempted to use YAST2 > Network Devices > Network Settings but the machine still has the old DNS domain name when I run “hostname --fqdn” or “dnsdomainname”

Any help will be appreciated.

Thanks you in advance.

Regards,
j

Did you logout/login before checking? That may only show in its updated
form after doing so (or, because it does the same thing plus more, rebooting).


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Thank you for the reply.

I actually rebooted the machine before checking.

Regards,
j

Hi
Not getting an ip address via DHCP and dhcp is giving out the FQDN, and/or the checkbox is set for the hostname via dhcp in Network Settings?

Also,
Check your Hosts file.

TSU

Here are my updates on you comment.

  1. The machine is getting its IP address from DHCP.
  2. I would like to update the FQDN from this machine kinda like using DHCP_HOSTNAME= in Fedora.
  3. Hostname via DHCP is currently disabled. Enabling this does not seem to update DNS Domain Name.

Regards,
J

I am getting the the new DNS domain name after this change using the dnsdomainname command but other machines are still connecting to it using the old FQDN.

Thanks.

Regards,
j

Yes,
The Hosts file will only modify your <local> hostname resolution… In other words, only on your local machine.
How other machines will identify and connect to your machine may have nothing to do with how you see your machine locally.

We need to know more about your network environment… Is this your home network or an AD/LDAP network run by whoever owns and manages your network like a business or school? If this is your home network, then you likely have control over all parts and can make these kinds of changes. If you’re operating in a large network managed by a school or business, you’ll need special permissions and tools to make network changes like how other machines see your machine.

TSU

Does this mean that OpenSUSE does not have a directive DHCP_HOSTNAME in the network config file that allows it to update DNS? The reason I ask is because I have Fedora machines that are able to update DNS entries using the DHCP_HOSTNAME in the network config file.

Regards,
j

Hi
I would have thought the DHCP server issues a static ip address, hostname, dns etc?

Maybe the transition from sysvinit to systemd?
http://www.freedesktop.org/software/systemd/man/systemd.network.html

As far as I know openSUSE by default sends hostname (i.e. it always behaves as if DHCP_HOSTNAME is set). You can trace DHCP transaction to check it. But it does not have any control over what DHCP server actually does with this hostname (and whether it does anything at all). What DHCP server do you use?

I think the DHCP server is working properly in my case. I am just looking for the similar capability of a directive DHCP_HOSTNAME in the network startup script like Fedora. They have had this even before they changed to Systemd.

Regards,
j

If openSUSE sends its hostname, then how do I change the hostname to the FQDN. I have tried doing this via yast2 but it will not allow me to put “.” in the hostname field. The only time I have seen the FQDN correctly is when I run “hostname -f”.

I think we have a Windows DHCP server.

Regards,
j

Hi
In the YaST -> Network Settings -> Hostname/DNS, left box is hostname, right box is domain name?

http://thumbnails114.imagebam.com/44060/1b4ebf440596162.jpg](http://www.imagebam.com/image/1b4ebf440596162)

I apologize for not providing a bit more background. I hope that it is not too late. :slight_smile:

Here is what I am trying to do. My machine is named opensuse1.example.com (had to change the actual name due to anonimity). Due to the application that I am running, I need to change it to opensuse1.test.example.com. As a result, I used the utility you have quoted above to change the Hostname and the Domain Name.

From…
Hostname: opensuse1
Domain Name: example.com

To…
Hostname: opensuse1
Domain Name: test.example.com

By making the change above, my machine now provides the following output. This is fine and looks good. However, the DNS record was not updated. Hence, machines that are accessing my SUSE still connect to it using opensuse1.example.com. This is a problem because the application running will only answer if it is referred to as opensuse1.test.example.com.


# hostname
opensuse1
# hostname -f 
opensuse1.test.example.com
# dnsdomainname
test.example.com

In my attempt to force the change in DNS, I tried putting opensuse1.test in the Hostname field but Yast2 will not allow this(it does not like “.” in that field). I was hoping to use the DHCP_HOSTNAME directive like i do in Fedora to force DNS to change the record but I am not sure if this will work with openSUSE. Hence, I asked this forum. :slight_smile:

Help.

Regards,
j

Hi
Thought it might be the case with an extra name in there :wink:

So are the dns machines local to resolve the address (reverse lookup)?


nslookup opensuse1.test.example.com

Did you look at the systemd options (from the link provided) to see if it can be added here?

dnsdomainname resolves your (short) host name using getaddrinfo and returns result. Domain part of host name you set in YaST is not relevant here. If you have permanent IP (e.g. DHCP reservation) you can set it in /etc/hosts. If your IP may change, your DHCP server needs to update you DNS server with “correct” name or use DDNS to update it yourself. openSUSE strips domain part from hostname when sending to DHCP server; and I do not see how it can work differently.

Thank you all. The URL helped. I wasn’t sure what about it would help me but it led me to the correct path. Here is what I did to get the outcome I wanted.

  1. Used yast2 > Network Devices > Network Settings and specified the new domain name as well as add it to the new domain search.
  2. Edited the /etc/sysconfig/network/ifcfg-eth0 to include the directives below.
    DHCLIENT_HOSTNAME_OPTION=
    DHCLIENT_SET_HOSTNAME=
  3. Added a host file entry with the new FQDN
  4. Reboot

Simply bouncing NetworkManager does not work. I didn’t go deep enough in the init script to determine why.

'Hope this helps another soul. :slight_smile:

Regards,
j

Whether a directive like that exists or not,
You still need to start with the fundamental question what your network security is (DNS in an LDAP or AD Domain is very different than an “ordinary” DNS server) which would determine <what> and <who> is authorized to make DNS changes. If your DNS is “ordinary” then the security picture is simpler and different and you might then with sufficient permissions alter DNS records…

Otherwise,
In openSUSE, I’ve seen both the HOSTS and HOSTNAME variables which can be set(Those would be broadcast in a Workgroup and not guaranteed to be used in a Domain), but of course when you set those, they are purely local settings which may or may not be used by other machines depending on the scenario.

TSU