Back to Lab Listing

Lab Objective:

Learn how to configure port forwarding.

Lab Purpose:

With NAT, you have no easy way of ensuring outside hosts can connect to internal web servers or email servers on the correct port, such as 80 and 110. Port forwarding solves this problem by ensuring the correct port is attached to the servers.

Lab Tool:

Packet Tracer

Lab Topology:

Please use the following topology to complete this lab exercise:

port forwarding

Lab Walkthrough:

Task 1:

Connect a server and a PC to a router using crossover cables. The PC will browse to the web server, and the router will perform port forwarding.

Task 2:

Set the IP configuration for the host and server. The server Ethernet interface should be 172.16.1.2 and the default gateway 172.16.1.1, which will be the closest IP address of R0. The PC will be 192.168.1.2 and gateway of 192.168.1.1. Here it is:

port forwarding2

And on the PC:

port forwarding3

Task 3:

Configure IP addressing on R0.

Router(config)#host R0

R0(config)#int g0/0

R0(config-if)#ip add 172.16.1.1 255.255.0.0

R0(config-if)#no shut

%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

R0(config-if)#int g0/1

R0(config-if)#ip add 192.168.1.1 255.255.255.0

R0(config-if)#no shut

R0(config-if)#end

Task 4:

Ping the server and PC from the router to ensure IP connectivity.

R0#ping 172.16.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms

 

R0#ping 192.168.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms

Task 5:

The HTTP service is enabled by default on Packet Tracer servers, so all we need to do now is configure port forwarding and NAT on the router. We want incoming connections on port 80 for IP 10.0.0.2 to be forwarded to the web server IP of 172.16.1.2.

R0(config)#ip nat inside source static tcp 172.16.1.2 80 10.0.0.2 80

R0(config)#int g0/0

R0(config-if)#ip nat inside

R0(config-if)#int g0/1

R0(config-if)#ip nat outside

R0(config-if)#end

Task 6:

Test your configuration by connecting to 10.0.0.2 from the web browser on the PC. We won’t add any DNS to this lab to keep it simple.

port forwarding4

port forwarding5

We can connect to the web server from its outside address.

Task 7:

Check the NAT table on the router. Bear in mind that the source port usually won’t be 80, but the destination port will be. That’s what’s important.

R0#show ip nat tran

Pro  Inside global  Inside local    Outside local   Outside global

tcp 10.0.0.2:80     172.16.1.2:80   —             —

tcp 10.0.0.2:80     172.16.1.2:80  192.168.1.2:1029 192.168.1.2:1029

tcp 10.0.0.2:80     172.16.1.2:80  192.168.1.2:1030 192.168.1.2:1030

Note:

You would use port forwarding for web and email servers, live chat, gaming, and many other port-dependent services and protocols.

Newsletter Subscribe

Stay Informed, Stay Inspired: Subscribe for Cutting-Edge IT-Certification Insights

101 Labs Newsletter