liunx下修改ip和dns

2021-06-18 01:28:22 字數 937 閱讀 5385

檢視當前linux伺服器的ip是多少:

命令下輸入:ifconfig

輸出結果如下:

修改對應網絡卡的ip位址的配置檔案

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

device=eth0 #描述網絡卡對應的裝置別名,例如ifcfg-eth0的檔案中它為eth0

bootproto=static #設定網絡卡獲得ip位址的方式,可能的選項為static,dhcp或bootp,分別對應靜態指定的 ip位址,通過dhcp協議獲得的ip位址,通過bootp協議獲得的ip位址

broadcast=192.168.0.255 #對應的子網廣播位址

hwaddr=00:07:e9:05:e8:b4 #對應的網絡卡實體地址

ipaddr=12.168.1.2 #如果設定網絡卡獲得 ip位址的方式為靜態指定,此字段就指定了網絡卡對應的ip位址

ipv6init=no

ipv6_autoconf=no

netmask=255.255.255.0 #網絡卡對應的網路掩碼

network=192.168.1.0 #網絡卡對應的網路位址

onboot=yes #系統啟動時是否設定此網路介面,設定為yes時,系統啟動時啟用此裝置

centos 修改dns

修改對應網絡卡的dns的配置檔案

# vi /etc/resolv.conf

修改以下內容

nameserver 8.8.8.8 #google網域名稱伺服器

nameserver 8.8.4.4 #google網域名稱伺服器

修改閘道器:

執行命令   vi /etc/sysconfig/network 

裡面新增 gateway=192.168.101.254

重啟網路服務:

# service network restart 

Centos修改網路IP和DNS

第一種 臨時修改ip,重啟失效!root localhost ifconfig eth0 192.168.1.108 第二種 永久修改ip root localhost vi etc sysconfig network scripts ifcfg eth0 下面是進入了ifcfg eth0 的內容 ...

linux 修改IP,閘道器,DNS

一 修改ip位址 1 修改對應網絡卡的ip位址的配置檔案 vi etc sysconfig network scripts ifcfg eth0 修改以下內容 device eth0 描述網絡卡對應的裝置別名,例如ifcfg eth0的檔案中它為eth0 bootproto static 設定網絡卡...

Linux修改IP 閘道器 DNS

重啟網路服務 etc rc.d init.d network restart ip位址 子網掩碼 編輯 etc sysconfig network script ifcfg eth0 device eth0 bootproto static 靜態還是動態 broadcast 192.168.1.25...