Technical Tip: How to configure a FortiGate interface to use DHCP
Description
Â
This article describes how a user can configure a FortiGate interface to use DHCP (Dynamic Host Configuration Protocol). DHCP is a way to assign automatically an IP address to a network device.
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 using HA mode, refer to Technical Tip: FortiGate HA and dynamic interface support (DHCP, PPPoE) for guidance on enabling 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 DNS settings, enable 'Override internal DNS' to use the DNS addresses retrieved from the DHCP server instead of the DNS server IP addresses configured on the DNS page.
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 default gateway from server' is enabled on a DHCP interface, the default route has a priority of 1. When multiple routes have the same administrative distance, the route with the lower priority value takes precedence. The administrative distance can be changed in the GUI, but the route priority cannot. To change the route priority, run the following commands in the CLI:
Â
 config system interface
  edit "port1"
    set priority 25
  next
end