CentOS7基础网络配置

时间:2022-04-10 07:26:38

1、网卡配置

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

DEVICE=eth0
HWADDR=00:0C:29:6C:BB:E6
NM_CONTROLLED="yes"
ONBOOT=yes
PEERDNS=yes
BOOTPROTO=static
IPADDR=192.168.0.8
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
注:重点配置最后4行,静态分配ip,ip地址,子网掩码、网关。


2、DNS配置

vi /etc/resolv.conf
nameserver xxx.xxx.xxx.xxx 

注:xxx.xxx.xxx.xxx是网关ip,可以配置多个。


3、安装源配置

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum update

4、第三方安装源配置

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
此命令安装完成之后就可以使用yum安装nginx、iftop、mysql等第三方包了