What is Port Forwarding?

转载 2010年05月26日 16:56:00


What is Port Forwarding?

There are a couple of concepts you need to know before you can understand port forwarding. I'm going to make a couple broad statements that are almost always true. For simplicity lets assume they are true for now.

1.) Every device on the internet has at least one ip address. The IP address is a number that is used to identify a device. For more information on ip addresses refer to our What is an IP Address page.

2.) Every IP address is divided up into many ports. When one computer sends data to another computer, it sends it from a port on an ip address to a port on an ip address. For more information on ports refer to our What is a Port page.

3.) A port can only be used by one program at a time.

Now that we've got those general concepts out of the way let's talk about NAT. NAT is an acronym for Network Address Translation. NAT takes one ip address and basically breaks it into many ip addresses.

Here the external ip address is broken into two internal ip addresses. The first ip address "IP Address1" is the gateway. While "IP Address2" is the ip address of the first computer. Take note that the router has two ip addresses. It has the external ip address, and an internal ip address which acts as the gateway for every computer on the network.

Excuse my rough drawing. Computers on the internal network can only "see" internal ip addresses. So computers on the internal network can not send data directly to a computer outside of the network. When a computer on the network wants to send data to a computer outside of the network, it sends the data to the gateway. Remember the gateway is the internal ip address of the router. The router then takes this data and sends it out to the computer on the internet. The router sends the data out of the external ip address. The same thing is true of computers on the internet. A computer outside of the network can not "see" a computer inside of the network. They can only "see" and send data to the external ip address of the router. The router must then decide what to do with this data. Lucky for us NAT takes care of most of the work for us. There are some programs that NAT was not designed to work with, those are the programs we need to set up port forwarding for. Okay take a deep breath! We are on to port forwarding.

Now that you understand the general concepts of a network, explaining port forwarding is easy. When a computer on the internet sends data to the external ip address of the router, the router needs to know what to do with the data. Port Forwarding simply tells the router which computer on the local area network to send the data to. When you have port forwarding rules set up, your router takes the data off of the external ip address:port number and sends that data to an internal ip address:port number. Port Forwarding rules are created per port. So a rule set up for port 53 will only work for port 53.

A port can only be used by one program at a time! Think of how this rule interacts with NAT. Well you've only got one external ip address on your router. When computer 1 is using port 500, it is using port 500 on it's internal ip address. If you have set up a port forwarding rule for computer 1 and port 500, the external ip address's port 500 is also in use. This means that you can only use port 500 on one computer on the network at a time. Using port 500 on two computers at the same time would violate the one program rule, and your data would get messed up. Most routers require you to specify an internal ip address to forward ports to, just for this reason. Some do not, so be aware of this. Port Forwarding rules will only work for one computer at a time!

Well I hope that was clear enough. Let me know what you think of this guide by using our comments page.

SecureCrt Port Forwarding功能(网络映射)

Port Forwarding:端口转发(端口映射)。linux系统里,如某些系统的数据库或者文件系统不希望外网来进行访问,则只有内网ip. 其中可分配一台外网的跳板机,可以用secureCrt功能...
  • guoxu775
  • guoxu775
  • 2012年09月19日 17:16
  • 8043

ssh port forwarding

SSH: Port Forwarding 1.正向隧道-隧道监听本地port,为普通活动提供安全连接 ssh -qTfnN -L port:host:hostport -l user remote...
  • bbplayers
  • bbplayers
  • 2011年09月30日 00:43
  • 2807

通过virtualbox的port forwarding(端口映射/传递)功能实现对Ubuntu虚拟机的远程访问

没有网络,一切都是浮云(有了网络,把浮云连起来,于是乎有了云计算....) 我们可以通过NAT方式很方便的使用host的网卡访问外网,那么如何远程访问虚拟机的服务呢? virtualbox...
  • flyflj
  • flyflj
  • 2012年12月27日 11:09
  • 1527

路由器端口触发与转发---Port Forwarding & Port Triggering

What is Port Triggering? If you have not read my explanation of port forwarding do so now. Yo...
  • lee244868149
  • lee244868149
  • 2014年08月08日 14:02
  • 2427

ssh port forwarding(ssh端口转发)

SSH的的Port Forward,中文可以称为端口转发,是SSH的一项非常重要的功能。它可以建立一条安全的SSH通道,并把任意的TCP连接放到这条通道中。下面仔细就仔细讨论SSH的这种非常有用的功能...
  • iloveyin
  • iloveyin
  • 2015年04月09日 19:12
  • 759

SSH Port Forwarding

  Introduction SSH is typically used for logging into ...
  • iiprogram
  • iiprogram
  • 2007年06月24日 13:00
  • 1893

NAT&Port Forwarding&Port Triggering

NAT     Nat,网络地址转换协议。主要功能是实现局域网内的本地主机与外网通信。     在连接外网时,内部Ip地址需要转换为网关(一般为路由器Ip地址)(端口号也需要相应的转换...
  • Windeal
  • Windeal
  • 2014年08月08日 15:55
  • 1476

iptables remote port forwarding

今天再一次需要用到iptables的port forwarding功能,半年前用过一次,忘得差不多了,今次重新学习,写到博客上来加深记忆。iptables的remote port forwarding...
  • linzhiqi07
  • linzhiqi07
  • 2013年05月24日 22:31
  • 1002

Port Forwarding & Port Triggering

  • Vincent_CC_90
  • Vincent_CC_90
  • 2014年10月24日 13:21
  • 381

port forwarding

Port Forwarding is configured on the router (machine making nat) and will forward connections origin...
  • perfectpdl
  • perfectpdl
  • 2010年12月16日 22:55
  • 865
您举报文章:What is Port Forwarding?