©2015 - 2022 Chad’s Technoworks. Disclaimer and Terms of Use

Chad’s TechnoWorks My Journal On Technology

HOW TO CONFIGURE DHCP HOSTNAME IN LINUX

Information Technology

I rarely would install Linux OS. But if I do, quite often I am stuck on trying to remember how I did it the last time when I set the hostname of a DHCP assigned IP. The following are my notes whenever I build a fresh Linux instance in my VMware environment. Note that my reference OS is Oracle Linux. The procedures may also work on Fedora Linux other Red Hat Linux variants.


USING COMMAND LINE

As root,


1. Set your desired hostname.


# hostname <my new hostname>


2. Add or replace the existing hostname entry of your network by editing the /etc/sysconfig/network


# cd /etc/sysconfig

# vi network


Set the following variable:

HOSTNAME=<my new hostname>


3.  Add the DHCP Hostname to your ethernet interface by modifying the /etc/sysconfig/network-scripts/ifcfg-eth0


# cd /etc/sysconfig/network-scripts

# vi ifcfg-eth0


Set the following variable:

DHCP_HOSTNAME=<my new hostname>


4. Restart the network service


# service network restart


5. Optionally you may add your hostname and ip in your /etc/hosts file.




USING THE GRAPHICAL TOOL


As root,


1. run system-config-network tool.


# system-config-network

2. From the Devices tab, highlight or select your device (eth0), then click edit. An Ethernet Device window will appear.

    Enter your DHCP hostname. In my case, the hostname is pacificnfs.

3. Save all your changes and restart the network service.