Technical Tip: How to configure a FortiGate interface to use DHCP
Description
In a FortiGate where an interface IP is assigned by an ISP, DHCP may have to be used. In these scenarios an ISP will often also provide a Default Route and the DNS settings.
Scope
Applies only to:
- FortiGate or VDOM in NAT mode.
- FortiGate in Standalone mode or in HA mode, when in HA mode (Technical Tip: FortiGate HA and dynamic interface support (DHCP, PPPoE)) it is suggested to enable DHCP after the cluster has been configured.
Solution
Configuration (GUI):
-
Log in to the FortiGate.
-
From the navigation pane, go to Network -> Interfaces.
-
Edit the interface connecting to the ISP by selecting the 'edit' icon.
-
Change the addressing mode to DHCP.
-
Enable 'Retrieve default gateway from server'. This will place a default route in the routing table with a distance as shown in the distance field. In this example, the distance is 5.
- If the ISP also provides the DNS settings, enable the field 'Override internal DNS'.
-
Select OK.
-
The 'Status' should change to connected and show the IP information obtained (IP address, default gateway, DNS).
GUI page: FortiGate Interface to use DHCP.

Example configuration in the CLI:
config system interface
edit "port1"
set mode dhcp
set defaultgw enable
set dns-server-override enable
next
end
Note: When 'Retrieve gateway from server' is enabled on a DHCP interface, the route priority is set to 1 by default. While Administrative Distance can be changed in the GUI, the priority cannot. To change the priority, run the following commands in the CLI:
config system interface
edit "port1"
set priority 25
next
end