ContOS
1、启用网络
配置网络随服务启动而启用
路径
cd /etc/sysconfig/network-scripsts/
修改
vi ifcfg-ens33
然后重启网络

sudo systemctl restart network
2、修改yum源
1、备份yum源
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载阿里yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、清空yum源
yum clean all
4、生成yum源缓存
yum makecache
5、查看yum源
yum repolist
6、更新yum软件包
yum -y update
阿里源内容
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
3、更新系统时间,配置时区
1、同步时间
yum install ntp # 安装 ntp
ntpdate ntp3.aliyun.com # 同步时间,这里以阿里云3号服务器为例,你可以根据需要选择其他服务器
date # 查看时间
2、修改时区
查看可用时区列表:
timedatectl list-timezones
找到您想要设置的时区,然后使用以下命令进行设置:
sudo timedatectl set-timezone your_time_zone
将 your_time_zone 替换为您从列表中选择的时区,例如 Asia/Shanghai。
验证更改是否成功,使用以下命令查看当前时区:
timedatectl status
这是一个示例,如果您想将时区设置为 Asia/Shanghai:
sudo timedatectl set-timezone Asia/Shanghai
4、安装ifconfig
sudo yum install net-tools
5、防火墙配置
暂时关闭防火墙。重启失效
sudo systemctl stop firewalld
永久关闭防火墙
sudo systemctl disable firewalld
放开端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
关闭端口
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
查看已经放开的端口
firewall-cmd --zone=public --list-ports
重新加载防火墙以应用更改:
sudo firewall-cmd --reload
查看防火墙作用再那个网卡
firewall-cmd --get-active-zones
6、设置静态IP
/etc/sysconfig/network-scripts
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPADDR=192.168.1.111
NETMASK=255.255.254.0
GATEWAY=192.168.1.254
DNS1=114.114.114.114
DNS2=8.8.8.8
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=dc06c90b-46b2-404d-9858-7cf57f3e3f6d
DEVICE=ens33
ONBOOT=yes