

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 對 Juniper JunOS 客戶閘道裝置的 AWS Site-to-Site VPN 連線進行故障診斷
<a name="Juniper_Troubleshooting"></a>

當您對 Juniper 客戶閘道裝置的連線問題進行故障診斷時，請考量四件事：IKE、IPsec、通道和 BGP。您可依任何順序故障診斷這些區域，但建議您從 IKE 開始 (網路堆疊底部的)，一路向上。

## IKE
<a name="IKETroubleshooting"></a>

使用下列 命令。回應顯示客戶閘道裝置的 IKE 設定正確。

```
user@router> show security ike security-associations
```

```
Index   Remote Address  State  Initiator cookie  Responder cookie  Mode
4       72.21.209.225   UP     c4cd953602568b74  0d6d194993328b02  Main
3       72.21.209.193   UP     b8c8fb7dc68d9173  ca7cb0abaedeb4bb  Main
```

您應該會看到一或多行包含通道中所指定的遠端閘道遠端地址。`State` 應為 `UP`。缺少項目或任何項目處於其他狀態 (例如 `DOWN`)，都表示 IKE 未正確設定。

如需進一步故障診斷，請如範例組態檔案中所建議，啟用 IKE 追蹤選項。然後執行下列命令，在螢幕中顯示各種除錯訊息。

```
user@router> monitor start kmd
```

從外部主機，您可以使用下列命令擷取整份日誌檔案。

```
scp username@router.hostname:/var/log/kmd
```

## IPsec
<a name="IPsecTroubleshooting"></a>

使用下列 命令。回應顯示客戶閘道裝置的 IPsec 設定正確。

```
user@router> show security ipsec security-associations
```

```
Total active tunnels: 2
ID      Gateway        Port  Algorithm        SPI      Life:sec/kb Mon vsys
<131073 72.21.209.225  500   ESP:aes-128/sha1 df27aae4 326/ unlim   -   0
>131073 72.21.209.225  500   ESP:aes-128/sha1 5de29aa1 326/ unlim   -   0
<131074 72.21.209.193  500   ESP:aes-128/sha1 dd16c453 300/ unlim   -   0
>131074 72.21.209.193  500   ESP:aes-128/sha1 c1e0eb29 300/ unlim   -   0
```

特別是，每個閘道地址 (對應至遠端閘道) 至少應該看到兩行。每行開頭的插入號 (< >) 指出特定項目的流量方向。在輸出中，傳入流量 (「<」，從虛擬私有閘道到此客戶閘道裝置的流量) 和傳出流量 (「>」) 各有不同的行。

如需進一步故障診斷，請啟用 IKE 追蹤選項 (詳細資訊請參閱上一節 IKE 內容)。

## 通道
<a name="TunnelTroubleshooting"></a>

首先，請再次檢查您有沒有必要的防火牆規則。如需規則清單，請參閱[AWS Site-to-Site VPN 客戶閘道裝置的防火牆規則](FirewallRules.md)。

如果您的防火牆規則設定正確，則繼續使用下列命令來進行故障診斷。

```
user@router> show interfaces st0.1
```

```
 Logical interface st0.1 (Index 70) (SNMP ifIndex 126)
    Flags: Point-To-Point SNMP-Traps Encapsulation: Secure-Tunnel
    Input packets : 8719
    Output packets: 41841
    Security: Zone: Trust
    Allowed host-inbound traffic : bgp ping ssh traceroute
    Protocol inet, MTU: 9192
      Flags: None
      Addresses, Flags: Is-Preferred Is-Primary
      Destination: 169.254.255.0/30, Local: 169.254.255.2
```

確定 `Security: Zone` 正確，而且 `Local` 地址符合客戶閘道裝置通道內部地址。

接著，使用下列命令，以您虛擬私有閘道的內部 IP 地址取代 `169.254.255.1`。您的結果看起來應該類似此處顯示的回應。

```
user@router> ping 169.254.255.1 size 1382 do-not-fragment
```

```
PING 169.254.255.1 (169.254.255.1): 1410 data bytes
64 bytes from 169.254.255.1: icmp_seq=0 ttl=64 time=71.080 ms
64 bytes from 169.254.255.1: icmp_seq=1 ttl=64 time=70.585 ms
```

如需進一步故障診斷，請檢閱組態。

## BGP
<a name="BGPTroubleshooting"></a>

執行下列命令。

```
user@router> show bgp summary
```

```
Groups: 1 Peers: 2 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0                 2          1          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...
169.254.255.1          7224          9         10       0       0        1:00 1/1/1/0              0/0/0/0
169.254.255.5          7224          8          9       0       0          56 0/1/1/0              0/0/0/0
```

如需進一步故障診斷，請使用下列命令，以您虛擬私有閘道的內部 IP 地址取代 `169.254.255.1`。

```
user@router> show bgp neighbor 169.254.255.1
```

```
Peer: 169.254.255.1+179 AS 7224 Local: 169.254.255.2+57175 AS 65000
  Type: External    State: Established    Flags: <ImportEval Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Export: [ EXPORT-DEFAULT ] 
  Options: <Preference HoldTime PeerAS LocalAS Refresh>
  Holdtime: 30 Preference: 170 Local AS: 65000 Local System AS: 0
  Number of flaps: 0
  Peer ID: 169.254.255.1    Local ID: 10.50.0.10       Active Holdtime: 30
  Keepalive Interval: 10         Peer index: 0   
  BFD: disabled, down
  Local Interface: st0.1                            
  NLRI for restart configured on peer: inet-unicast
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Restart time configured on the peer: 120
  Stale routes from peer are kept for: 300
  Restart time requested by this peer: 120
  NLRI that peer supports restart for: inet-unicast
  NLRI that restart is negotiated for: inet-unicast
  NLRI of received end-of-rib markers: inet-unicast
  NLRI of all end-of-rib markers sent: inet-unicast
  Peer supports 4 byte AS extension (peer-as 7224)
  Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              1
    Received prefixes:            1
    Accepted prefixes:            1
    Suppressed due to damping:    0
    Advertised prefixes:          1
Last traffic (seconds): Received 4    Sent 8    Checked 4   
Input messages:  Total 24     Updates 2       Refreshes 0     Octets 505
Output messages: Total 26     Updates 1       Refreshes 0     Octets 582
Output Queue[0]: 0
```

您應該會在此看到每個列出的 `Received prefixes` 與 `Advertised prefixes` 皆為 1。這應屬於 `Table inet.0` 區段。

如果 `State` 不是 `Established`，請檢查 `Last State` 和 `Last Error` 以取得所需詳細資訊來更正問題。

如果 BGP 對等互連已啟動，請確認您的客戶閘道裝置是否向 VPC 公告預設路由 (0.0.0.0/0)。

```
user@router> show route advertising-protocol bgp 169.254.255.1
```

```
inet.0: 10 destinations, 11 routes (10 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 0.0.0.0/0               Self                                    I
```

此外，確定您會從虛擬私有閘道收到對應至您 VPC 的字首。

```
user@router> show route receive-protocol bgp 169.254.255.1
```

```
inet.0: 10 destinations, 11 routes (10 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.110.0.0/16           169.254.255.1        100                7224 I
```