在 CentOS 中“删除域名”通常有以下几种常见场景,你可以按需选择:
如果你在 /etc/hosts 里手动绑定过域名:
vi /etc/hosts
找到类似:
192.168.1.100 example.com
删除该行,保存退出即可。
hostname
hostname -f
hostnamectl set-hostname your-hostname
例如:
hostnamectl set-hostname centos
如果是通过网卡配置设置的域名(如 search example.com):
vi /etc/sysconfig/network-scripts/ifcfg-eth0
删除或注释:
DOMAIN=example.com
然后重启网络:
systemctl restart network
(CentOS 8 可用 nmcli 或 NetworkManager)
vi /etc/resolv.conf
删除:
search example.com
⚠️ 注意:若由 NetworkManager 管理,resolv.conf 可能被自动覆盖。
rm -f /etc/nginx/conf.d/example.com.conf
systemctl restart nginx
rm -f /etc/httpd/conf.d/example.com.conf
systemctl restart httpd
一般防火墙不直接“绑定域名”,若你是指端口或富规则:
firewall-cmd --list-all
firewall-cmd --remove-service=http --permanent
firewall-cmd --reload
如果你能具体说明:
我可以给你更精确的命令。