2021-05-12 14:32:11
Red Hat Enterprise Linux 7(RHEL7)設定靜態IP地址
Red Hat Enterprise Linux 7(RHEL7)設定靜態IP地址
1.驗證網路管理器狀態,Active: active (running)表示正在執行,一般RHEL7都預設安裝了。
[root@localhost ~]# systemctl status NetworkManager.service
NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
Active: active (running) since 一 2015-06-22 18:50:22 CST; 26min ago
Main PID: 895 (NetworkManager)
CGroup: /system.slice/NetworkManager.service
└─895 /usr/sbin/NetworkManager --no-daemon
2.檢視網路裝置以及狀態
[root@localhost ~]# nmcli dev
裝置 型別 狀態 CONNECTION
enp0s3 ethernet 連線的 enp0s3
lo loopback 未管理 --
我只關心型別為ethernet(乙太網)的裝置,如果該裝置狀態不是連線的,則啟用它
[root@localhost ~]# nmcli con up id enp0s3
3.檢視目錄/etc/sysconfig/network-scripts下是否有該裝置的組態檔,ifcfg-enp0s3,如果沒有就新建一個
[root@localhost ~]# ls /etc/sysconfig/network-scripts
ifcfg-enp0s3 ifdown-ppp ifup-eth ifup-sit
ifcfg-lo ifdown-routes ifup-ippp ifup-Team
ifdown ifdown-sit ifup-ipv6 ifup-TeamPort
ifdown-bnep ifdown-Team ifup-isdn ifup-tunnel
ifdown-eth ifdown-TeamPort ifup-plip ifup-wireless
ifdown-ippp ifdown-tunnel ifup-plusb init.ipv6-global
ifdown-ipv6 ifup ifup-post network-functions
ifdown-isdn ifup-aliases ifup-ppp network-functions-ipv6
ifdown-post ifup-bnep ifup-routes
4.編輯這個組態檔
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
重點是這幾個設定
TYPE=Ethernet
BOOTPROTO=static
NAME=enp0s3
ONBOOT=yes
IPADDR=地址
NETMASK=掩碼
GATEWAY=閘道器
DNS1=你的DNS
5.重新啟動網路服務
[root@localhost ~]# systemctl restart network
6.設定ok了,ping www.linuxidc.com試試吧。
相關文章