Linux修改主机名+主机IP

时间:2021-12-30 13:36:59

//Linux修改主机名

1.修改network
cd /etc/sysconfig

 vi network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server1.group1

2.修改hosts
 cd /etc/
 vi hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               server1.group1 server1
::1             localhost6.localdomain6 localhost6

3.修改IP

 cd /etc/sysconfig/network-scripts

 vi ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:0c:29:fa:df:7a

 vi ifcfg-eth1
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:0c:29:fa:df:84
IPADDR=192.168.10.121
NETMASK=255.255.255.0


编辑完成后,重启服务即可。

service network restart