centos7靜態網路配置

2021-09-19 13:30:25 字數 1658 閱讀 7857

centos7靜態網路配置

cd /etc/sysconfig/network-scripts

找到當前網絡卡名字

vim ifcfg-ens33

type="ethernet" #

bootproto="static" #網絡卡獲取ip位址的方式,預設是dhcp,這裡改為static,dhcp是動態獲取

defroute="yes"

ipv4_failure_fatal="no"

ipv6init="yes"

ipv6_autoconf="yes"

ipv6_defroute="yes"

ipv6_failure_fatal="no"

ipv6_addr_gen_mode="stable-privacy"

name="ens33" #網絡卡的名字

uuid="ec101075-0264-46c6-8fec-2e9613aebf6d" #網絡卡的uuid

device="ens160"

onboot="yes" #預設我no,這裡改為yes,表示開啟自動重啟網絡卡

ipaddr="192.168.1.237" #要配置的靜態ip位址

prefix="24" #子網掩碼

gateway="192.168.1.1" #閘道器位址

dns1="192.168.1.1"

ipv6_peerdns="yes"

ipv6_peerroutes="yes"

ipv6_privacy="no"

因為新安裝完作業系統以後,網絡卡內部資訊太多太雜亂,此時我們可以直接更改如下:

type=ethernet #配置為網際網路網絡卡

bootproto=static #配置獲取ip位址形式為靜態獲取

ipaddr=192.168.100.112 #配置網絡卡位址

netmask=255.255.255.0 #配置子網掩碼

network=192.168.100.0 #配置網路位址

name=enp0s3 #配置網絡卡名字

device=enp0s3 #網絡卡硬體名字

onboot=yes #開啟自動重啟

dns1=114.114.114.114 #配置dns

gateway=192.168.100.1 #配置閘道器

然後重啟服務執行,即可看到網路已經配好:

systemctl status network

systemctl start network

systemctl stop network

systemctl restart network

此外,網絡卡還可以從這個地方配置:

vim /etc/sysconfig/network

networking=yes

networking_ipv6=no

hostname=localhost.localdomain

gateway=192.168.1.1 #配置閘道器

這個檔案預設為空,只有第一行,我們可配可不配。

然後重啟服務執行,即可看到網路已經配好:

systemctl status network

systemctl start network

systemctl stop network

systemctl restart network

CentOs7 配置網路 靜態IP

配置網路 網路配置內容 檔案 etc sysconfig network scripts ifcfg ens33 新增內容如下 ipaddr 靜態 ip gateway 預設閘道器 netmask 閘道器 dns1 dns1 dns2 dns2 修改內容如下 bootproto static onb...

CentOS 7 配置網路

檢視ip位址 ip addr結果如下,可以看看網絡卡名稱 ens33 1 lo mtu 65536 qdisc noqueue state unknown qlen 1 link loopback 00 00 00 00 00 00 brd 00 00 00 00 00 00 inet 127.0....

centos7 配置網路

如果是虛擬主機環境,則設定centos7的網路連線為 橋接模式,然後登入系統配置網絡卡引數 靜態,固定分配ip vi etc sysconfig network scripts ifcfg en bootproto static static 靜態ip 手動分配 dhcp 動態ip 自動分配 non...