CentOS修改主機名和網路資訊

2021-07-10 06:47:08 字數 1185 閱讀 1997

[root@centos ~]# vim /etc/sysconfig/network

開啟檔案,修改以下內容並儲存

networking=yes      #使用網路

hostname=centos      #設定主機名稱

[root@centos ~]# hostname centos        #立即生效

[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

開啟檔案,修改以下內容並儲存

device=eth0         #對應第一張網絡卡

type=ethernet

onboot=yes          #是否啟動時執行

nm_controlled=yes

bootproto=static       #使用靜態ip,而不是由dhcp分配ip

defroute=yes

ipv4_failure_fatal=yes

ipv6init=no

name="system eth0"      #名稱

hwaddr=00:50:56:94:04:3c  

#必須對應etho是的mac位址(/etc/udev/rules.d/70-persistent-net.rules)

peerdns=yes

peerroutes=yes

ipaddr=192.168.1.128    #指定本機ip位址

netmask=255.255.255.0    #指定子網掩碼

gateway=192.168.1.2     #指定閘道器

dns1=192.168.1.2

[root@centos ~]# vim /etc/resolv.conf

開啟檔案,修改以下內容並儲存

nameserver 8.8.8.8      #google的dns伺服器

nameserver 192.168.1.2    #指定經路由器上指定的dns伺服器

頂0

CentOS修改主機名和網路資訊

1.修改主機名稱 root centos vim etc sysconfig network 開啟檔案,修改以下內容並儲存 networking yes 使用網路 hostname centos 設定主機名稱 root centos hostname centos 立即生效 2.修改網絡卡 root...

CentOS修改主機名

1.修改配置檔案 設定centos主機名稱的檔案為 etc sysconfig network,修改其中hostname後的名稱為想要的名稱 root centos vi etc sysconfig network networking yes hostname centos.localdomain...

CentOS 修改主機名

顯示主機名 oracle localhost hostname localhost 修改主機名 oracle localhost sudo hostname orcl1 oracle localhost hostname orcl1 2.永久修改主機名 以上的修改只是臨時修改,重啟後就恢復原樣了。步...