CentOs7靜態ip設定

2021-08-08 21:40:00 字數 768 閱讀 4680

修改網絡卡配置檔案(操作前先備份一下該檔案),/etc/sysconfig/network-scripts/ifcfg-ens33 ,如下:

注:ifcfg-ens33 對應自己的網絡卡名稱,不同網絡卡這個檔案字尾是不同的,如:ifcfg-***xx
type=ethernet

bootproto=static #dhcp改為static表示靜態分配位址

onboot=yes #表示開機啟用本配置

ipaddr=192.168.9.111 #靜態ip

netmask=255.255.255.0 #子網掩碼

gateway=192.168.0.1 #閘道器

name=ens33 #這裡對應自己的網絡卡名稱

device=ens33 #這裡對應自己的網絡卡名稱

dns1=8.8.8.8 #dns 對應自己的dns配置

預設該檔案中其他配置,可以都刪除或注釋。

修改閘道器配置檔案,/etc/sysconfig/network,如下:

# created by anaconda

networking=yes

networking_ipv6=no

hostname=localhost.localdomain

gateway=192.168.0.1

重啟服務

systemctl restart network

Centos 7 靜態IP設定

在做專案時由於公司區域網採用自動獲取 的方式,導到每次伺服器重啟主機 都會變化。為了解決這個問題,我參考了的文章然後根據自己的情況設定靜態ip解決了這個問題,處理方式如下 device eth0 描述網絡卡對應的裝置別名,例如ifcfg eth0的檔案中它為eth0 bootproto static...

Centos7設定靜態IP

bootproto static dhcp改為static 修改 onboot yes 開機啟用本配置,一般在最後一行 修改 ipaddr 192.168.1.132 靜態ip 增加 netmask 255.255.255.0 子網掩碼 增加 nm controlled no表示該介面將通過該配置檔...

centos7設定靜態ip

1 編輯 ifcfg eth0 檔案,vim 最小化安裝時沒有被安裝,需要自行安裝不描述。eth0為本例使用的,你的不一定是eth0 plain view plain copy vim etc sysconfig network scripts ifcfg eth0 2 修改如下內容 plain v...