一、CentOS8 yum源配置
1、挂载光盘镜像配置本地yum源
先移走系统默认的repo文件
cd /etc/yum.repos.d/
mkdir repobak
mv *.repo repobak/

挂载本地光盘镜像
mkdir /mnt/cdrom
mount -t iso9660 /dev/cdrom /mnt/cdrom

编辑本地yum源repo文件
vi CentOS-LocalMedia.repo
cat CentOS-LocalMedia.repo
[local-BaseOS]
name=CentOS-BaseOS
baseurl=file:///mnt/cdrom/BaseOS
gpgcheck=0
enabled=1
[local-AppStream]
name=CentOS-AppStream
baseurl=file:///mnt/cdrom/AppStream
gpgcheck=0
enabled=1

dnf clean all
dnf makecache
dnf install lrzsz -y

当然也可以用yum命令
2、可以联网的情况下使用阿里云yum源
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 https://mirrors.aliyun.com/repo/Centos-8.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum makecache 生成缓存


3、 Aliyun EPEL源
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
yum install ncdu 测试epel源是否可以正常使用


二、nmcli命令
CentOS8默认无network.service服务,当输入service network restart时会提示无network.service


可以通过yum install network-scripts来安装传统的network.service,不过在下一个RHEL的大版本里将彻底废除,因此不建议使用network.service 需要使用nmcli命令来重启网络
CentOS8 中默认的网络服务由NetworkManager 提供,这是动态控制及配置网络的守护进程,它用于保持当前网络设备及连接处于工作状态,同时也支持传统的ifcfg 类型的配置文件。NetworkManager可以用于以下类型的连接:Ethernet,VLANS,Bridges,Bonds,Teams,Wi-Fi,mobile boradband(如移动3G)以及 IP-over-InfiniBand。针对与这些网络类型,NetworkManager可以配置他们的网络别名,IP 地址,静态路由,DNS,VPN连接以及很多其它的特殊参数。
可以用命令行工具 nmcli 来控制 NetworkManager。在CentOS8中网络管理命令行工具nmcli。经常使用ifconfig的用户应该在CentOS8中避免使用ifconfig了,nmcli的功能要强大、复杂的多
下面简单介绍nmcli命令
1、nmcli --help
nmcli device -h
nmcli device status


2、添加网卡及修改网卡配置
nmcli connection add type ethernet con-name ens37 ifname ens37
nmcli connection modify ens37 ipv4.addresses 172.16.10.1/24
nmcli connection modify ens37 ipv4.gateway 172.16.10.254
nmcli connection modify ens37 ipv4.dns 172.16.10.254
nmcli connection modify ens37 ipv4.method manual
nmcli connection modify ens37 +ipv4.dns 223.5.5.5
nmcli connection modify ens37 connection.autoconnect yes


3、停用与启用网络连接 down与up
nmcli connection down ens37
nmcli connection up ens37
nmcli device show ens37

4、设置网卡为非默认网卡DEFROUTE=no
nmcli connection modify ens37 ipv4.never-default yes

对应nmtui命令中看到网卡配置项:Never use this network for default route
