[linux] CentOS 7 reports an error: the yum command reports an error "Cannot find a valid baseurl for repo: base/7/x86_6" or cannot access the Internet

1. Error reporting

fe1a9a38c11834585d147b18d6e2b6b.png

2. The reason for the error

The system cannot parse the yum source for the following reasons

  1. The virtual machine cannot access the Internet! You need to check the network configuration to confirm that you can access the Internet and then look at the second situation
  • Check if you can access the Internet: ping a public network pi
ping 114.114.114.114

image.png
image.png

  1. DNS configuration problem! Check if there is a problem with the DNS configuration You can do thisnslookup www.baidu.com

image.png

  1. If the above two situations are normal, but the yum source still cannot be parsed, you can try another yum source

3. Solutions

  1. The network adapter of VMware can be set to NAT or bridge mode

image.png

  1. Create network card file
    1. Table of contents:cd /etc/sysconfg/network-scripts/
    2. Check if there is: ifcfg-ens33or ifcfg-ens32, if no file is created (no suffix)
  2. Modify the content of the ifcfg-ens33/ ifcfg-ens33file, open it for editing through the vim command
vim/vi ifcfg-ens33

image.png
bridge mode

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp" #如果是桥接模式dhcp自动获取,如果是NAT:static
DEFROUTE="yes"
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="784d0f02-9840-411b-afc1-9d65850bd9dd"
DEVICE="ens33"
ONBOOT="yes"
  • BOOTPROTO="dhcp"#If it is bridge mode, dhcpit will be obtained automatically, if it is NAT:static
  • ONBOOT="yes"turn on

If it is NATa model, you need to add these

DNS1=8.8.8.8
DNS2=223.5.5.5
GATEWAY=192.168.1.2  # 查看自己的参数最后配2,用来转发
NETMASK=255.255.255.0 
IPADDR=192.168.1.180# 查看自己的参数
  • IPADDR: The last three digits of IP+ are randomly selected from 0 to 155
  • GATEWAY: gateway
  • DNS: DNS configuration (used to solve problem 2)

Parameter view:
input:ip a
1679449292114.png

  1. restart network service
systemctl restart network.service
  1. Enter the command to view the IP address:ip a

This is my network card configuration (NTA mode)
image.png
reference article: 1. https://blog.csdn.net/weixin_43232955/article/details/108290006
2. https://blog.csdn.net/qq_39720249/article/details/ 84065760

Guess you like

Origin blog.csdn.net/AAIT11/article/details/129703370