兩台 Ubuntu 修改 /etc/hosts 後無法互 ping,但改回原樣又能通。
ip addr show 或 ifconfig,查看 inet 地址與子網遮罩 (如 192.168.1.100/24)。192.168.1.100 master192.168.1.101 slave210.0.2.15 (NAT 模式),hosts 寫 192.168.x.x 自然不通。ufw status / iptables -L,確保允許 ICMP (ping)。# 兩台均執行
ip addr show eth0 # 確認 IP/網段
ping -c 3 192.168.1.101 # 直接 ping IP,排除 DNS/hosts
cat /etc/hosts # 確認對應關係
原詢問者需提供 ifconfig 輸出才能進一步診斷,**hosts 只是名稱解析,底層通訊仍靠真實 IP 與路由**。