Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
zh:docs:guide-user:network:switch_router_gateway_and_nat [2021/06/30 06:48] – [路由器、交换机、网关及NAT] biajizh:docs:guide-user:network:switch_router_gateway_and_nat [2021/07/01 07:44] – [OpenWrt as wireless access point (wireless-to-wired switch)] biaji
Line 18: Line 18:
  
  
-===== Router/gateway and double NAT problem with IPv4 or mixed IPv4/IPv6  =====+===== 作为路由器/网关时,IPv4或混用IPv4/IPv6情况下需要面对的双NAT问题  =====
 <WRAP todo> <WRAP todo>
-Are you an OpenWrt newcomer? Does this page with lots of technical network information seem scary? Are you worried that you don't know enough to make these decisions now?\\  +您是OpenWrt的新手么?这个页面里的各种网络技术信息是不是看起来很可怕?感觉无所适从了?\\ 
--> Just stop reading and use the default configuration for now. Your device will act as a router in a cascaded double NAT scenario which will work just fine for normal internet access, so you don't have to do anything.\\ +-> 您可以选择暂时放弃,转而使用默认配置。您的设备在双NAT场景下会作为一个路由工作,一般来说访问因特网不会有任何问题,您什么都不需要做。\\ 
--> Alternatively, [[docs:guide-quick-start:start|get familiar with OpenWrt]] first, then come back later and decide how to proceed.+-> 或者,先看看[[docs:guide-quick-start:start|熟悉OpenWrt]],回头再来决定下一步怎么做。
 </WRAP> </WRAP>
  
-[[docs:guide-user:network:integrating-openwrt-introduction|Double NAT]] is an issue that exists solely with IPv4. In a few decades, when the whole world is fully IPv6 enabled devices, this won't be a problem anymore, as IPv6 strictly forbids NAT. In the meantime for IPv4, act according to this how-to.+[[docs:guide-user:network:integrating-openwrt-introduction|NAT]]是一个仅在IPv4下才存在的问题。在不远的将来,当全世界都是支持IPv6的设备时,这个问题也将不复存在。因为IPv6已经禁用了NAT。不过目前,您可以遵循此页面来解决问题。
  
-The problem of IPv4 is that if you simply add an additional IPv4 router to an existing router of your ISP (internet service provider), you will face a problem called **double NAT** - both the newly added router and the existing ISP-supplied router do NAT, resulting in your client data traffic being "NATed" twice before it reaches the internet.+IPv4的问题在于:当你在现存的路由和ISP(互联网服务提供商)之间加上一个IPv4路由的时候,你就会遇到这个名为 **NAT** 的问题——新加的路由和现存的ISP提供的路由都做了NAT,最终导致客户端的数据在抵达因特网之前被“NAT”了两次。
  
-This double NAT scenario won't cause problems for basic tasks like browsing the internet, but it can cause problems when you are trying to host servers at home that you want to be reachable from the internet, or when doing peer-to-peer online gaming (which often uses the UDP protocol and does some funny firewall stuff called "UDP hole-punching").+在一般情况下,比如浏览互联网的时候,这种双NAT的场景不会造成什么问题。但当你想在家里建一个服务器,以供互联网访问的时候,亦或玩一些端到端连接的网络游戏的时候(这些游戏经常用UDP协议并会对防火墙做一些类似“UDP打洞”的神奇操作),问题就出现了。
  
-To deal with this double NAT problem and use IPv4 as flawlessly as possible, you need to choose how OpenWrt gets connected on its upstream side from several options. Note that in all these examples, the OpenWrt device is assumed to be on the "inside" of the network, i.e. clients <-> OpenWrt device <-> ISP device <-> Internet. Since the OpenWrt device is our main concern, we'll refer to //upstream// and //downstream// connections relative to it+为了解决双NAT问题,以尽量完美的使用IPv4,您需要从OpenWrt如何连接上游的几个选项中选择一个。请注意,在这些示例中,OpenWrt设备被认为是在网络“内部”的,诸如 客户端 <-> OpenWrt设备 <-> ISP设备 <-> 因特网。因为我们主要关注OpenWrt设备,我们将以它来定义相对的 //上游// 和 //下游// : 
-  * **Upstream**: the connection from the OpenWrt device to your network infrastructure +  * **上游**: OpenWrt设备到您的网络基础设施 
-  * **Downstream**: your home client devices connecting to your OpenWrt device+  * **下游**: 您家里连接到OpenWrt设备的客户端设备
  
 There is a range of options to connect the upstream side of OpenWrt to your existing home network. Each option tries to work around the double NAT problem with different technical tricks or configuration: There is a range of options to connect the upstream side of OpenWrt to your existing home network. Each option tries to work around the double NAT problem with different technical tricks or configuration:
Line 47: Line 47:
 | single | [[#device_as_a_gateway_with_a_true_modem_between_it_and_the_internet|OpenWrt as gateway using either OpenWrt-device-built-in or external modem]] | clients <-> OpenWrt as gateway with NAT <-> built-in/external modem (no NAT) <-> Internet | | single | [[#device_as_a_gateway_with_a_true_modem_between_it_and_the_internet|OpenWrt as gateway using either OpenWrt-device-built-in or external modem]] | clients <-> OpenWrt as gateway with NAT <-> built-in/external modem (no NAT) <-> Internet |
  
-====== Switches and client APs ====== +====== 作为交换机或客户端AP ====== 
-| single | Three usage Variants: \\ [[#openwrt_as_wireless_repeater_wifi_wifi_switch|OpenWrt as wireless repeater (Wi-Fi <-> Wi-Fi switch)]] \\ [[#openwrt_as_wireless_access_point_wifi_wired_switch|OpenWrt as wireless access point (Wi-Fi <-> wired switch)]] \\ [[#openwrt_as_a_wire_wire_switch|OpenWrt as wire (wire <-> wire switch)]] | clients <-> OpenWrt as switch (no NAT) <-> ISP router (with NAT) <-> Internet |+| single | 三种用法: \\ [[#openwrt_as_wireless_repeater_wifi_wifi_switch|OpenWrt作为无线中继(Wi-Fi <-> Wi-Fi交换机)]] \\ [[#openwrt_as_wireless_access_point_wifi_wired_switch|OpenWrt作为无线接入点(Wi-Fi <-> 有线交换机)]] \\ [[#openwrt_as_a_wire_wire_switch|OpenWrt作为有线交换机(有线 <-> 有线交换机)]] | 客户端 <-> OpenWrt交换机(NAT) <-> ISP路由器(NAT) <-> 因特网 |
   
 Note that for all of these upstream connection variants, the following applies: Note that for all of these upstream connection variants, the following applies:
 +
   * all variants can handle both wireless and wired clients on the downstream side (i.e. client devices connected to your LAN)   * all variants can handle both wireless and wired clients on the downstream side (i.e. client devices connected to your LAN)
   * all variants can host software services for both downstream and upstream sides (like NAS shares)   * all variants can host software services for both downstream and upstream sides (like NAS shares)
Line 149: Line 150:
 Note: In case you are interested in creating a so called "wireless mesh" instead of a wireless repeater, you will have to refer to other projects, e.g. [[https://libremesh.org/]] or [[https://open-mesh.org/]] at this time. Note: In case you are interested in creating a so called "wireless mesh" instead of a wireless repeater, you will have to refer to other projects, e.g. [[https://libremesh.org/]] or [[https://open-mesh.org/]] at this time.
  
-===== OpenWrt as wireless access point (wireless-to-wired switch)===== +===== OpenWrt作为无线接入点(无线到有线交换机)===== 
-Follow: [[docs:guide-user:network:wifi:dumbap|Wi-Fi access point]]+遵循: [[docs:guide-user:network:wifi:dumbap|Wi-Fi接入点]]
  
-As a wireless access point, OpenWrt connects to the existing network by wire. OpenWrt then acts as a networking device that allows your Wi-Fi devices to connect to the wired network over OpenWrt.  +作为一个无线接入点,OpenWrt将以有线连接至现存网络。供您的无线设备经由OpenWrt连接至有线网络所用。 
-  * the wired network provides Internet access+  * 有线网络提供因特网访问
   * OpenWrts upstream side (the other wired network it will connect to) will be a wired connection to the existing router. So OpenWrt acts as a client of this existing other network.   * OpenWrts upstream side (the other wired network it will connect to) will be a wired connection to the existing router. So OpenWrt acts as a client of this existing other network.
   * OpenWrts downstream side (the Wi-Fi network that OpenWrt will provide) will be an access point for your wireless clients   * OpenWrts downstream side (the Wi-Fi network that OpenWrt will provide) will be an access point for your wireless clients
  • Last modified: 2022/03/17 10:11
  • by biaji