Excellent software and practical tutorials
How to access GitHub on Alibaba Cloud Server
Alibaba Cloud Server(Domestic area)No access GitHub.com is a common problem, usually associated withNetwork restrictions,DNS resolutionorFirewallThe following is an analysis and solution to this problem, which is applicable to most cases:
Cause
Network restrictions:
The network environment in mainland China has access restrictions on some overseas websites (such as GitHub), which may be caused by operators or firewalls.
Alibaba Cloud domestic servers are affected by these restrictions, especially unregistered domain names or IPs.
DNS resolution failed:
The default DNS server may not correctly resolve the IP address of GitHub.com, causing Could not resolve host: github.com mistake.
GitHub uses HTTPS(port 443) or SSH(Port 22) may be used by Alibaba CloudSecurity GroupOr blocked by server firewall.
Server configuration issues:
Local network configuration (such as Hosts File)oractingThe setting may cause access exceptions.
Solution
Method 1: Modify DNS configuration
View the current DNS configuration
cat /etc/resolv.conf
If the default DNS (such as 100.100.100.100 provided by Alibaba Cloud) cannot resolve GitHub, replace it with a public DNS:
Google DNS: 8.8.8.8 and 8.8.4.4
Cloudflare DNS: 1.1.1.1 and 1.0.0.1
Edit /etc/resolv.conf
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf echo "nameserver 1.1.1.1" | sudo tee -a /etc/resolv.conf
Test access to see if ping is successful
ping github.com
If the above method doesn't work and you still can't access GitHub, then the problem should be with the website domain name resolution.
Method 2: Manually add hosts file
Get GitHub's IP address:
Run locally (in an environment without network restrictions):
ping github.com
This gets the latest IP address of github.com. Of course, you can also ping github.com on different servers to get some different addresses.
- 20.205.243.166
- 140.82.114.3
- 140.82.112.3
- 140.82.113.3

sudo vi /etc/hosts
After editing, save and exit! Ping again
The IP address you just filled in has been successful! Now the server can access GitHub.
GitHub uses multiple IPs, which may change due to load balancing and need to be updated regularly.
Suitable for temporary solutions, cannot handle all GitHub related domains (such as raw.githubusercontent.com).