Ubuntu

Ubuntu 伺服器:嘗試使用 Postfix 設置電子郵件伺服器後,Ping 8.8.8.8 僅導致目標主機無法訪問

  • February 9, 2021

今天早上連接和所有的東西都工作正常,直到我按照一些線上教程,安裝了Postfix並更改了**/etc/hostname/etc/hosts**。現在 ping 到本地路由器:198.168.3.1 工作正常,但當我嘗試到達防火牆外的任何地方時卻不行:

ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.3.46 icmp_seq=1 Destination Host Unreachable

ping 192.168.3.1
PING 192.168.3.1 (192.168.3.1) 56(84) bytes of data.
64 bytes from 192.168.3.1: icmp_seq=1 ttl=64 time=8.62 ms

我解除安裝了Postfix,更改了**/etc/hostname/etc/hosts**,但問題仍然存在。

我將使用 example.com 來覆蓋真實的域。這是我的實例的ifconfig :

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.3.46  netmask 255.255.255.0  broadcast 192.168.3.255
       inet6 fe80::bacb:29ff:fea3:a598  prefixlen 64  scopeid 0x20<link>
       ether b8:cb:29:a3:a5:98  txqueuelen 1000  (Ethernet)
       RX packets 4377  bytes 708162 (708.1 KB)
       RX errors 0  dropped 28  overruns 0  frame 0
       TX packets 875  bytes 62510 (62.5 KB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
       device interrupt 17

這是我的**/etc/netplan**:

# This is the network config written by 'subiquity'
network:
 version: 2
 renderer: networkd
 ethernets:
   eno1:
     addresses: [192.168.3.46/24]
     gateway4: 192.168.3.254
     nameservers:
       addresses: [8.8.4.4,8.8.8.8]

這是**/etc/hosts**:

127.0.0.1 localhost
127.0.0.1 example.com
127.0.1.1 www.example.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

這是**/etc/hostname**:

example.com

伺服器仍接受請求,但無法通過 LAN 發送任何內容:

traceroute 8.8.8.8 traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets  
1  example.com (192.168.3.46)  2325.811 ms  2325.800 ms   2325.793 ms 

我重置了防火牆並儘我所能,請有人幫忙…

感謝@icarus,只需意識到網關和路由器應該共享處理所有傳入和傳出流量的相同地址。之前有 2 個路由器為不同的目的工作,這就是為什麼今天才出現問題,因為另一個路由器的規則已更改。

引用自:https://unix.stackexchange.com/questions/633417