術語

術語

術語

S1我有一台在雲端中運行的伺服器(我稱之為),但它行為異常。我還有另一台伺服器 ( ) 在同一雲端網路中運行,透過單獨的網路 ( )S2連接。S1eth1

伺服器S1透過 與內部網路相連eth1,並透過 直接與網路連接eth0

S1正在運行 Debian Jessie,透過更改/etc/apt/sources.list.

S2運行完美,運行的是 Debian Wheezy。和S1升級前一樣乾淨的 Debian Wheezy 。

情況

  • S1我可以從網路外部透過 SSH 連接
    • 透過界面eth0
  • S1我可以透過 SSH 從另一台伺服器連接( S2)
    • 透過界面eth1
  • 我可以連接S1到其他伺服器 ( S2)
    • 透過界面eth1
  • 我可以不是連結S1到外部世界
    • 不通過eth0
    • 不通過eth1
    • 我無法透過 SSH 連接到其他伺服器;我無法 ping 通8.8.8.8(同時S2 );我無法解析主機(8.8.8.8在 中 使用/etc/resolv.conf

問題與嘗試

對於為什麼我無法與外界聯繫,我沒有任何奇怪的想法。

iptables

$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

解析設定檔

$ cat /etc/resolv.conf
nameserver 10.147.234.1
nameserver 8.8.8.8
nameserver 8.8.4.4

介面

$ cat /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# The one directly connected to the web
auto eth0
iface eth0 inet dhcp

# The one connected to the internal network
auto eth1
iface eth1 inet dhcp

Ping 請求

$ ping -I eth0 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from (MY_IP) eth0: 56(84) bytes of data.
From (MY_IP) icmp_seq=1 Destination Host Unreachable
From (MY_IP) icmp_seq=2 Destination Host Unreachable
From (MY_IP) icmp_seq=3 Destination Host Unreachable

$ ping -I eth1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from (INTERNAL_IP) eth0: 56(84) bytes of data.
From (INTERNAL_IP) icmp_seq=1 Destination Host Unreachable
From (INTERNAL_IP) icmp_seq=2 Destination Host Unreachable
From (INTERNAL_IP) icmp_seq=3 Destination Host Unreachable

路線-n

$ route -n
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.147.234.0    0.0.0.0         255.255.255.0   U     0      0        0  eth1
(SUBNET_MY_IP (ends 0))    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.169.254 85.222.226.153  255.255.255.255 UGH   0      0        0 eth0

ip轉發

$ cat /proc/sys/net/ipv4/ip_forward
0

ifconfig-a

$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr fa:16:3e:d9:ab:b0  
      inet addr:(MY_IP)  Bcast:(MY_IP_BUT_ENDS_WITH_255)  Mask:255.255.255.0
      inet6 addr: (MY_v6_IP) Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:75300 errors:0 dropped:0 overruns:0 frame:0
      TX packets:689 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:9905366 (9.4 MiB)  TX bytes:86792 (84.7 KiB)

eth1      Link encap:Ethernet  HWaddr fa:16:3e:2c:d7:80  
      inet addr:10.147.234.6  Bcast:10.147.234.255  Mask:255.255.255.0
      inet6 addr: (MY_INTERNAL_6_IP) Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:177 errors:0 dropped:0 overruns:0 frame:0
      TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:11626 (11.3 KiB)  TX bytes:1346 (1.3 KiB)

lo        Link encap:Local Loopback  
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:135 errors:0 dropped:0 overruns:0 frame:0
      TX packets:135 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:22168 (21.6 KiB)  TX bytes:22168 (21.6 KiB)

答案1

根據 ICMP 請求結果,您的路由有問題,請向我們顯示: route -ncat /proc/sys/net/ipv4/ip_forwardifconfig -a

更新後:您的路由表中沒有預設路由,您可以透過以下方式新增它: route add default gw x.x.x.x,您應該將結果與工作機器進行比較並蒐索包含以下內容的行: Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 x.x.x.x 0.0.0.0 UG 1024 0 0 eth0

作為蓋斯達夫達薩克正確指出這不是持久的解決方案。

相關內容