To change the ip-address along with the hostname, follow the steps shown below.
In this example, we’ll change the hostname from dev-server to prod-server.
hostname command by default will display the current hostname as shown below:
# hostname dev-server
The following will change the hostname to prod-server.
# hostname prod-server
Once the hostname is changed, verify that it has changed the hostname successfully. As you see below, it has changed the hostname to prod-server
# hostname prod-server
If you have entries in the /etc/hosts file with the old hostname, you should modify it.
For example, the entry for 127.0.0.1 line in the /etc/hosts file will still show the old hostname. In this example, it shows as dev-server.
$ cat /etc/hosts 127.0.0.1 dev-server localhost.localdomain localhost
Modify this file, and set the new hostname here. For example, change dev-server to prod-server as shown below.
$ cat /etc/hosts 127.0.0.1 prod-server localhost.localdomain localhost
The /etc/sysconfig/network file also has an entry for HOSTNAME. Change the value here as shown below.
# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=prod-server
Restart the network service, if you want any other services that are using the hostname to pickup the changes.
# service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ]
If this is not a production system, you can also reboot the system to make sure the hostname is changed properly, and the system is picking it up properly during startup.
If you have desktop related utilities installed on your system, you can change the hostname from the GUI.
Execute system-config-network from the command line.
# system-config-network
This will display the “Network Configuration” GUI. Go to the “DNS” tab and change the hostname from here as shown below.

You can change the ip-address of the server using ifconfig command as we discussed earlier. For example, the following changes the ip-address of the server on eth0 interface to 192.168.1.2
# ifconfig eth0 192.168.1.2
Under the /etc/sysconfig/network-scripts directory, you’ll see file for every network interface on your system. For example, if your interface is “eth0″, you’ll see ifcfg-eth0 file under this directory.
Modify the ifcfg-eth0 file and change the IPADDR field accordingly as shown below to change the ip-address.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO=none NM_CONTROLLED="yes" ONBOOT=yes TYPE="Ethernet" UUID="11111-2222-3333-4444" IPADDR=192.168.1.2 PREFIX=24 GATEWAY=192.168.1.1 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System em1" HWADDR=DD:BB:DD:AA:11:55
If you’ve defined the ip-address in the /etc/hosts file, make sure to change those also. For example, if you have a FQDN that was pointing to the old ip-address in the /etc/hosts file, change it to the new ip-address. Depending on how you’ve configured your system, you might not have to do this step.
$ vi /etc/hosts 127.0.0.1 prod-server localhost.localdomain localhost 192.168.1.2 prod-server.mydomain.com
Finally, restart the network service, for the system to pick-up the changes.
# service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ]
If this is not a production system, you can also reboot the system to make sure the hostname and ip-address is changed properly, and the system is picking it up properly during startup.
آموزش نصب و کانفیگ مجازی ساز kvm
آموزش نصب VNC در Centos
آشنایی با 5 پلاگین کاربردی Nginx در وردپرس
آموزش نصب و فعالسازی SSL در سرورهای Cpanel
آموزش دانلود یک پوشه از یک سرور Remote
آموزش افزایش و بالا بردن امنیت WHMCS
آموزش ساخت صفحات اضافی در WHMCS
آشنایی با 15 دستور کاربردی در آنتی شل maldet
آموزش نصب و کانفیگ ftp سرور در CentOS 7
آموزش نصب phpmyadmin در nginx
آموزش نصب کلود لینوکس CloudLinux
آموزش تغییر IP و Hostname در Centos
آموزش شناسایی و حذف CryptoPHP PHP malware
آموزش افزایش امنیت سایت های جوملا Joomla
آموزش نصب Virtualizor روی centos 6.5
آشنایی با انواع Raid در سرور
آموزش نصب و کانفیگ php-fpm در دایرکت ادمین directadmin
آموزش نصب Spamassassin در دایرکت ادمین
آموزش خاموش کردن brute force notification
آموزش تنظیم mysql remote در دایرکت ادمین
سرویس کانفیگ ویژه امنیتی سرور
دستورالعمل جديد فعاليت سايت هاي چت روم
درباره پی سی سرور
تعطیلی 4 روزه بخش پشتیبانی
فروش ویژه سرورهای مجازی قدرتمند مختص چت روم های پربازدید
فروش ویژه سرور مجازی VPS بصورت مدیریت شده
خدمات مانیتورینگ و نگهداری و رفع اشکال سرور
کانفیگ سرورهای دایرکت ادمین
کانفیگ سرورهای سی پنل
اطلاعیه مهم: مدیران سایت های چت روم بخوانند
سیستم مدیریت محتوای سایت های عکس
راه اندازی سامانه پشتیبانی آنلاین پی سی سرور
سوء استفاده افراد کالاه بردار سود جو از نام پی سی پارسی
شروع بکار مجدد بخش پشتیبانی
تعطیلی 1 هفته ای بخش پشتیبانی بدلیل تغییر مکان شرکت
سیستم مدیریت محتوای سایت های تفریحی
سوء استفاده گروه سود جو "TopazVPS" گول نخورید
قوانین سرویس دهی پی سی سرور
طراحی چت روم
حفره امنیتی خطرناک در wordpress