Если потребовалось сменить имя хоста в Linux, то сделать это можно следующим образом:
- Проверка текущего имени компьютера:
# uname -n
# hostname -a
# hostname -s
# hostname -d
# hostname -f
# hostname
Configuring /etc/hosts
If your IP address is assigned to you by a DHCP server, then /etc/hosts is configured as follows:127.0.0.1 mybox.mydomain.com localhost.localdomain localhost myboxIf you have a static IP address, then /etc/hosts is configured as follows:
127.0.0.1 localhost.localdomain localhost 192.168.0.10 mybox.mydomain.com mybox
Setting the Host Name using “hostname”
After updating the /etc/hosts file correctly, the “hostname” command should be run as follows to set your hostname:hostname mybox.mydomain.com
Checking /etc/HOSTNAME (if present)
You may or may not have the file /etc/HOSTNAME:mybox.mydomain.com
Checking /etc/sysconfig/network
If you have a static IP address, then /etc/sysconfig/network is configured as follows:NETWORKING=yes HOSTNAME="mybox.mydomain.com" ...If your IP address is assigned to you by a DHCP server, and you wish to update the local DNS server through Dynamic DNS, then /etc/sysconfig/network is configured as follows:
NETWORKING=yes HOSTNAME="mybox.mydomain.com" DHCP_HOSTNAME="mybox.mydomain.com" ...It makes more sense to move this “DHCP_HOSTNAME” variable into /etc/sysconfig/network-scripts/ifcfg-eth0 (or appropriate NIC cfg file). So the above section has been moved, see below. If you have only 1 NIC, then the above struck section works fine, but with more than 1 NIC it makes no sense. Maybe this is true for the “‘HOSTNAME” line too, maybe that line should be moved into /etc/sysconfig/network-scripts/ifcfg-eth0 as well. I will investigate further. By default RHL places HOSTNAME=localhost.localdomain in /etc/sysconfig/network.
Checking /proc/sys/kernel/hostname
This is checked with the following command:cat /proc/sys/kernel/hostnameIf you need to set this file, you can either reboot or set it now with the following command:
echo mybox.mydomain.com > /proc/sys/kernel/hostname
Комментариев нет:
Отправить комментарий