A brief introduction to yum source configuration and nmcli commands under CentOS8

1. CentOS8 yum source configuration

1、 Mount the CD image to configure the local yum source

Remove the system default repo file first

cd /etc/yum.repos.d/
mkdir repobak
mv *.repo repobak/

Mount local CD image

mkdir /mnt/cdrom
mount -t iso9660 /dev/cdrom /mnt/cdrom

Edit local yum source repo file

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

Of course, you can also use the yum command

2、 Use Alibaba Cloud yum source when you can connect to the Internet

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
or
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 generates cache

3、 Aliyun EPEL source

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 test whether the epel source can be used normally

Two, nmcli command

CentOS8 has no network.service service by default. When you enter service network restart, it will prompt no network.service

You can install traditional network.service through yum install network-scripts, but it will be completely abolished in the next major version of RHEL, so it is not recommended to use network.service. You need to use the nmcli command to restart the network

The default network service in CentOS8 is provided by NetworkManager, which is a daemon that dynamically controls and configures the network. It is used to keep the current network devices and connections in working condition. It also supports traditional ifcfg type configuration files. NetworkManager can be used for the following types of connections: Ethernet, VLANS, Bridges, Bonds, Teams, Wi-Fi, mobile boradband (such as mobile 3G) and IP-over-InfiniBand. For these network types, NetworkManager can configure their network aliases, IP addresses, static routes, DNS, VPN connections and many other special parameters.

You can use the command line tool nmcli to control NetworkManager. The network management command line tool nmcli in CentOS8. Users who often use ifconfig should avoid using ifconfig in CentOS8. The function of nmcli is much more powerful and complicated.

The following briefly introduces nmcli commands

1、 nmcli --help

nmcli device -h
nmcli device status

2、 Add network card and modify network card configuration

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、 Disable and enable network connection down and up

nmcli connection down ens37

nmcli connection up ens37

nmcli device show ens37

4、 Set the network card as a non-default network card DEFROUTE=no

nmcli connection modify ens37  ipv4.never-default yes

Corresponding to the network card configuration item seen in the nmtui command: Never use this network for default route

Recommended Posts

A brief introduction to yum source configuration and nmcli commands under CentOS8
Install svn and configuration through yum under CentOS
CentOS 5 to CentOS 5.8 YUM source
[Introduction to redis] Install redis under Centos
Java-JDK installation and configuration under CentOS
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Installation and configuration of redis under centos7
CentOS 6 add common yum source to transfer
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of rsync server under CentOS 6.5
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
Use Rancher to build a K8s cluster under CentOS7
Environment configuration of JDK, mysql and tomcat under Centos7
Linux firewall related configuration commands and operations (centos and ubuntu)
Detailed explanation of Spark installation and configuration tutorial under centOS7
Basic usage and examples of yum under Liunx (centos8) (recommended)
Introduction to CentOS7 installation process of openjdk, tomcat and mysql
Use Jexus 5.8.2 to deploy and run Asp.net core under Centos
Centos mysql installation and configuration
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
Centos 6.10 reinstall python and yum
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP