UP | HOME

CentOS设置静态IP

查看机器网卡配置文件列表

$ ls /etc/sysconfig/network-scripts/ifcfg-*

命令行中设置静态IP

$ vi /etc/sysconfig/network-scripts/ifcfg-enp0s0
    BOOTPROTO="static"
    IPADDR="1.1.1.2"
    NETMASK="255.255.255.0"
    GATEWAY="1.1.1.1"
$ systemctl restart network.service

使用网络管理器

$ yum install NetworkManager-tui
$ nmtui edit enp0s0
$ systemctl restart network.service

修改DNS设置

$ vi /etc/resolv.conf
    nameserver 8.8.8.8
    nameserver 8.8.4.4
$ vi /etc/sysconfig/network-scripts/ifcfg-enp0s0
    DNS1="8.8.8.8"
    DNS2="8.8.4.4"

Date: 2019-03-26 Tue 23:10

Author: shixiongfei

Created: 2020-09-05 Sat 14:40

Emacs 27.1 (Org mode 9.3)