CentOS server has no network connection, how to fix it?
When the CentOS server cannot be connected to the network, you can follow the following steps to check: 1. Check the status of the network interface, use ip link show to confirm whether the interface is enabled. If it is not enabled, use sudo ip link set <interface_name> up to start, and use ip addr show to view the IP allocation status; 2. If it is in DHCP mode, run sudo dhclient <interface_name> to obtain the IP. If it is static configuration, check the IP, gateway and DNS settings in /etc/sysconfig/network-scripts/ifcfg-<interface_name> and restart the network service; 3. Check the routing table ip route show to ensure that there is a default gateway. If there is no, add it temporarily or modify GATEWAY= in the configuration file; 4. Check the DNS configuration in /etc/resolv.conf, and manually add public DNS such as 8.8.8.8 for testing; 5. Check the firewalld status, open the port or temporarily close the firewall test connection if necessary; 6. Check the SELinux status. If it is enforcing mode, switch to permissive mode to eliminate interference. Most network problems can usually be solved through the above steps.
If your CentOS server has no network connection, there are a few common culprits—misconfigured settings, downed interfaces, or firewall issues. The good news is that most of these can be diagnosed and fixed quickly with a few basic commands and checks.
Check the Network Interface Status
First things first: make sure the network interface is actually up and recognized by the system. You can use the ip
command to check:
ip link show
Look for an interface like eth0
, ens33
, or something similar. If it says DOWN
, bring it up with:
sudo ip link set <interface_name> up
Also, verify if it received an IP address using:
ip addr show
If there's no IP address assigned, you might have a problem with DHCP or static configuration.
- For DHCP , try restarting the service:
sudo dhclient <interface_name>
- For static setups, double-check
/etc/sysconfig/network-scripts/ifcfg-<interface_name>
for correct IP, gateway, and DNS entries.
Don't forget to restart the network service after any changes:
sudo systemctl restart NetworkManager # or if you're using the older network service: sudo systemctl restart network
Verify DNS and Routing Settings
Even if the interface looks fine, the server might still not be able to reach the outside world due to routing or DNS problems.
Start by checking the routing table:
ip route show
Make sure there's a default route pointing to a valid gateway. If not, add one temporarily:
sudo ip route add default via <gateway_ip> dev <interface_name>
To make this permanent, update the GATEWAY=
line in your interface config file.
For DNS issues, look at /etc/resolv.conf
. It should contain lines like:
nameserver 8.8.8.8 nameserver 8.8.4.4
You can temporarily test different DNS servers by editing this file directly. Just keep in mind that some systems regenerate this file automatically based on other network settings.
Check Firewall and SELinux
Sometimes the system itself blocks outgoing traffic without you realizing it. The main suspects here are firewalld and SELinux.
To see if firewalld is running:
sudo systemctl status firewalld
If it's active, allow specific services or ports as needed:
sudo firewall-cmd --add-port=80/tcp --permanent sudo firewall-cmd --reload
Or temporarily disable it to test connectivity:
sudo systemctl stop firewalld
SELinux doesn't usually block network access outright, but it can interfere depending on what services you're running. To check its status:
sestatus
If it's enforcing, try switching it to permit mode:
sudo setenforce 0
Then test your network again. If it works now, dig into SELinux policies later—you don't want to leave it disabled permanently.
That's a solid starting point for troubleshooting network issues on a CentOS server. These steps cover physical layer problems, IP configuration, routing, DNS, and basic firewall interference. Fixing one or two of these areas often gets things back online.
The above is the detailed content of CentOS server has no network connection, how to fix it?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

ArtGPT
AI image generator for creative art from text prompts.

Stock Market GPT
AI powered investment research for smarter decisions

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Identifythenewdiskusinglsblkorfdisk-ltolocatethecorrectdevicelike/dev/sdb.2.Optionallypartitionthediskwithfdisk/dev/sdb,createaprimarypartitionusingdefaultsettings,andwritechangeswithw,thenrunpartprobetoupdatethekernel.3.Createafilesystemusingmkfs-tx

Make sure the system has loaded the bonding module and confirm that the network card interface is available, use modprobebonding and lsmod to verify; 2. Create /etc/sysconfig/network-scripts/ifcfg-bond0 configuration files, set DEVICE, TYPE, BONDING_MASTER, IP parameters and BONDING_OPTS=mode=active-backupmiimon=100primary=ens33; 3. Configure ifcfg files of physical network cards ens33 and ens34, set MASTER=bond0, SLAVE=yes and remove IP configuration

Uninstall the old version of Docker to avoid conflicts, 2. Install yum-utils and add the official Docker repository, 3. Install DockerCE, CLI and containerd, 4. Start and enable Docker services, 5. Run hello-world image to verify that the installation is successful, 6. Optionally configure non-root users to run Docker.

Installcifs-utilsandoptionallysamba-clientusingyumordnf.2.Createamountpointlike/mnt/windows-share.3.ManuallymounttheWindowsshareusingthemount-tcifscommandwithappropriateoptions,preferablyusingacredentialsfileforsecurity.4.Storecredentialssecurelyin/e

First,checkChrome’sproxysettingsanddisableanymanualproxyorsetupscriptifnotneeded;second,disableextensionsonebyoneortestinIncognitoModetoidentifyproblematicadd-ons;third,clearChrome’snetworksettingsbyflushingsocketpoolsandclearingDNScacheviachrome://n

Usersyncforfullsystembackupsbymountingatargetdriveandrunningrsyncwitharchive,ACL,andextendedattributepreservationwhileexcludingvirtualfilesystems,thenunmountaftercompletion.2.Createcompressedsystembackupswithtarbyexcludingtemporarydirectoriesandcompr

First add the official PostgreSQL repository, then disable the system's own modules and install the PostgreSQL server and client. After initializing the database, start the service and set up the power-on self-start. Then configure the authentication method and network access permissions, and finally restart the service to make the configuration take effect.

To expand the logical volume in CentOS, first confirm that there is available space in the volume group, and use the df-h, lvdisplay, vgdisplay commands to check the current disk and LVM layout; 1. If the volume group has no free space, you must first add the space by adding a new disk or expanding the virtual disk and executing the pvcreate and vgextend commands to add the space to the volume group; 2. Use lvextend-l 100%FREE/dev/centos/root (ext to all free space) or lvextend-L 10G/dev/centos/root (specify the increase in size) to expand the logical volume; 3. After expansion, the file system must be resize, ext4 uses resize
