1.登入配置檔案目錄
執行命令:cd /etc/sysconfig/network-scripts
2.檢視網絡卡資訊
執行命令:ll
-rw-r--r--. 1 root root 320 12月 10 15:35 ifcfg-eno16777728
-rw-r--r--. 1 root root 254 9月 16 2015 ifcfg-lo
lrwxrwxrwx. 1 root root 24 12月 10 15:27 ifdown ->
../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root 627 9月 16 2015 ifdown-bnep
-rwxr-xr-x. 1 root root 5817 9月 16 2015 ifdown-eth
-rwxr-xr-x. 1 root root 6196 11月 20 2015 ifdown-ib
-rwxr-xr-x. 1 root root 781 9月 16 2015 ifdown-ippp
-rwxr-xr-x. 1 root root 4201 9月 16 2015 ifdown-ipv6
lrwxrwxrwx. 1 root root 11 12月 10 15:27 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root 1642 9月 16 2015 ifdown-post
-rwxr-xr-x. 1 root root 1068 9月 16 2015 ifdown-ppp
-rwxr-xr-x. 1 root root 837 9月 16 2015 ifdown-routes
-rwxr-xr-x. 1 root root 1444 9月 16 2015 ifdown-sit
-rwxr-xr-x. 1 root root 1599 4月 2 2015 ifdown-team
-rwxr-xr-x. 1 root root 1556 4月 2 2015 ifdown-teamport
-rwxr-xr-x. 1 root root 1462 9月 16 2015 ifdown-tunnel
lrwxrwxrwx. 1 root root 22 12月 10 15:27 ifup ->
../../../usr/sbin/ifup
-rwxr-xr-x. 1 root root 12631 9月 16 2015 ifup-aliases
-rwxr-xr-x. 1 root root 859 9月 16 2015 ifup-bnep
-rwxr-xr-x. 1 root root 11721 9月 16 2015 ifup-eth
-rwxr-xr-x. 1 root root 10145 11月 20 2015 ifup-ib
-rwxr-xr-x. 1 root root 12039 9月 16 2015 ifup-ippp
-rwxr-xr-x. 1 root root 10430 9月 16 2015 ifup-ipv6
lrwxrwxrwx. 1 root root 9 12月 10 15:27 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root 642 9月 16 2015 ifup-plip
-rwxr-xr-x. 1 root root 1043 9月 16 2015 ifup-plusb
-rwxr-xr-x. 1 root root 2609 9月 16 2015 ifup-post
-rwxr-xr-x. 1 root root 4154 9月 16 2015 ifup-ppp
-rwxr-xr-x. 1 root root 1925 9月 16 2015 ifup-routes
-rwxr-xr-x. 1 root root 3263 9月 16 2015 ifup-sit
-rwxr-xr-x. 1 root root 1755 4月 2 2015 ifup-team
-rwxr-xr-x. 1 root root 1876 4月 2 2015 ifup-teamport
-rwxr-xr-x. 1 root root 2682 9月 16 2015 ifup-tunnel
-rwxr-xr-x. 1 root root 1740 9月 16 2015 ifup-wireless
-rwxr-xr-x. 1 root root 4623 9月 16 2015 init.ipv6-global
-rw-r--r--. 1 root root 15322 9月 16 2015 network-functions
-rw-r--r--. 1 root root 26134 9月 16 2015 network-functions-ipv6
可以看到網絡卡配置檔案ifcfg-eno16777728
type=
"ethernet"
bootproto=
"dhcp"
defroute=
"yes"
peerdns=
"yes"
peerroutes=
"yes"
ipv4_failure_fatal=
"no"
ipv6init=
"yes"
ipv6_autoconf=
"yes"
ipv6_defroute=
"yes"
ipv6_peerdns=
"yes"
ipv6_peerroutes=
"yes"
ipv6_failure_fatal=
"no"
name=
"eno16777728"
uuid=
"c93b2e5c-93ff-443f-8583-69717f317a28"
device=
"eno16777728"
onboot=
"no"
可以看出bootproto="dhcp"
表示系統自動獲取ip
4.修改配置檔案
修改bootproto="dhcp"
為bootproto="static"
修改onboot="no"
為onboot="yes"
新增一下配置資訊
ipaddr=192.168.0.1 #ip位址
netmask=255.255.255.0 #子網掩碼
gateway=192.168.0.2 #預設閘道器
dns1=186.76.76.76 #dns網域名稱解析伺服器
dns2=8.8.8.8
設定dns
執行命令:vi /etc/resolv.conf
nameserver 186.76.76.76
nameserver 8.8.8.8
修改內容如上所示或者其他的dns伺服器均可
5.重啟網路服務(重啟網絡卡)
執行命令:service network restart
6.檢視系統ip配置
執行命令:ip addr
1: lo: mtu 65536 qdisc noqueue state unknown
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777728:
mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:0c:29:68:6f:8a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.134/23 brd 192.168.1.255 scope global dynamic eno16777728
valid_lft 82719sec preferred_lft 82719sec
inet6 fe80::20c:29ff:fe68:6f8a/64 scope link
valid_lft forever preferred_lft forever
3: virbr0: mtu 1500 qdisc noqueue state down
link/ether 52:54:00:9b:94:5d brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic:
mtu 1500 qdisc pfifo_fast master virbr0 state down qlen 500
link/ether 52:54:00:9b:94:5d brd ff:ff:ff:ff:ff:ff
可以看到網絡卡eno16777728已被修改 配置靜態IP
一 安裝centos虛擬機器 二 檢查防火牆是否開啟,如果開啟我們把它關了並設定禁止開機自啟動 service firewalld status 檢查防火牆服務狀態 systemctl stop firewalld 停止執行防火牆 systemctl disable firewalld 禁用開機自啟...
linux配置靜態IP
vi etc sysconfig network scripts ifcfg eth0針對特定的網絡卡進行設定 type ethernet bootproto static 啟動型別 靜態 預設dhcp defroute yes ipv4 failure fatal yes ipv6init no ...
redhat靜態Ip配置
依次修改以下三個檔案 etc sysconfig network etc sysconfig network scripts ifcfg eth0 etc resolv.conf 1.etc sysconfig network networking yes networking ipv6 no ho...