Fortinet black logo

Cookbook

Using virtual IPs to configure port forwarding

Copy Link
Copy Doc ID 598118ae-ea1f-11e9-8977-00505692583a:657500
Download PDF

Using virtual IPs to configure port forwarding

This recipe demonstrates how to use Virtual IPs (VIPs) to configure port forwarding on a FortiGate unit. This configuration allows users on the Internet to connect to your server protected behind a FortiGate firewall, without knowing the server’s internal IP address and only through ports that you choose.

In this example, TCP ports 80 (HTTP), 21 (FTP), and 22 (SSH) are opened for remote users to communicate with a server behind the firewall. The external IP address used is 172.20.121.67 and is mapped to 192.168.100.1 by the VIP.

1. Creating three VIPs

Go to Policy & Objects > Virtual IPs > Create New > Virtual IP.

Enter the External IP Address/Range. Next, enter the Mapped IP Address/Range.

Enable Port Forwarding and add a VIP for TCP port 80, webserver-http. While this example maps port 80 to port 80, any valid External Service port can be mapped to any listening port on the destination computer.

Next, create a second VIP for TCP port 21, webserver-ftp.

Finally, create a third a VIP for TCP port 22, webserver-ssh.

2. Adding VIPs to a VIP group

Go to Policy & Objects > Virtual IPs > Create New > Virtual IP Group.

Create a VIP group, in this example, webserver group. Under Members, include all three VIPs previously created.

3. Creating a security policy

Go to Policy & Objects > IPv4 Policy and create a security policy allowing access to a server behind the firewall.

Set Incoming Interface to your Internet-facing interface, Outgoing Interface to the interface connected to the server, and Destination Address to the VIP group (webserver group). If the FortiGate has Central NAT enabled, the VIP objects will not be available for selection in the policy editing window. Set Service to allow HTTP, FTP, and SSH traffic.

NAT is disabled for this policy so that the server sees the original source addresses of the packets it receives. This is the preferred setting for a number of reasons. For example, the server logs will be more meaningful if they record the actual source addresses of your users.

Use the appropriate Security Profiles to protect the servers.

4. Results

To ensure that TCP port 80 is open, connect to the web server from a remote connection on the other side of the firewall.

Next, ensure that TCP port 21 is open by using an FTP client to connect to the FTP server from a remote connection on the other side of the firewall.

Finally, ensure that TCP port 22 is open by connecting to the SSH server from a remote connection on the other side of the firewall.

For further reading, check out Virtual IPs in the FortiOS 5.4 Handbook.

Related Videos

sidebar video

VIP Port Forwarding (5.4)

  • 133,914 views
  • 6 years ago

Using virtual IPs to configure port forwarding

This recipe demonstrates how to use Virtual IPs (VIPs) to configure port forwarding on a FortiGate unit. This configuration allows users on the Internet to connect to your server protected behind a FortiGate firewall, without knowing the server’s internal IP address and only through ports that you choose.

In this example, TCP ports 80 (HTTP), 21 (FTP), and 22 (SSH) are opened for remote users to communicate with a server behind the firewall. The external IP address used is 172.20.121.67 and is mapped to 192.168.100.1 by the VIP.

1. Creating three VIPs

Go to Policy & Objects > Virtual IPs > Create New > Virtual IP.

Enter the External IP Address/Range. Next, enter the Mapped IP Address/Range.

Enable Port Forwarding and add a VIP for TCP port 80, webserver-http. While this example maps port 80 to port 80, any valid External Service port can be mapped to any listening port on the destination computer.

Next, create a second VIP for TCP port 21, webserver-ftp.

Finally, create a third a VIP for TCP port 22, webserver-ssh.

2. Adding VIPs to a VIP group

Go to Policy & Objects > Virtual IPs > Create New > Virtual IP Group.

Create a VIP group, in this example, webserver group. Under Members, include all three VIPs previously created.

3. Creating a security policy

Go to Policy & Objects > IPv4 Policy and create a security policy allowing access to a server behind the firewall.

Set Incoming Interface to your Internet-facing interface, Outgoing Interface to the interface connected to the server, and Destination Address to the VIP group (webserver group). If the FortiGate has Central NAT enabled, the VIP objects will not be available for selection in the policy editing window. Set Service to allow HTTP, FTP, and SSH traffic.

NAT is disabled for this policy so that the server sees the original source addresses of the packets it receives. This is the preferred setting for a number of reasons. For example, the server logs will be more meaningful if they record the actual source addresses of your users.

Use the appropriate Security Profiles to protect the servers.

4. Results

To ensure that TCP port 80 is open, connect to the web server from a remote connection on the other side of the firewall.

Next, ensure that TCP port 21 is open by using an FTP client to connect to the FTP server from a remote connection on the other side of the firewall.

Finally, ensure that TCP port 22 is open by connecting to the SSH server from a remote connection on the other side of the firewall.

For further reading, check out Virtual IPs in the FortiOS 5.4 Handbook.