"Journey towards new learning"

DHCP configuration in Fortigate CLI




Download Lab config

This lab will show you how to configure the DHCP server on the Fortigate using CLI. It's really straightforward.  As you can see above. I am using two interfaces in the FortiGate. Port1 goes to R1 and Port 2 goes to the internet.

I am enabling DHCP so R1 will take an IP address automatically from Fortigate. I will ping R1 to the internet as Fortigate is already configured with Policy and NAT. Will attach the full config as well.

Enabling DHCP for Port1.

NETINFO_FORTINET # config system dhcp server
    edit 1
        set lease-time 300
        set dns-service default
        set default-gateway 10.1.1.1
        set netmask 255.255.255.0
        set interface "port1"
        config ip-range
            edit 1
                set start-ip 10.1.1.10
                set end-ip 10.1.1.20
            next
        end
    next
end

Enabling R1's interface and pinging the internet.

Router>ena
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#
Router(config)#int eth0/0
Router(config-if)#ip 
*May 11 14:56:16.053: %DHCP-6-ADDRESS_ASSIGN: Interface Ethernet0/0 assigned DHCP address 10.1.1.10, mask 255.255.255.0, hostname Router
end
!
Router#ping 4.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 379/491/881 ms
Router#
!
Router#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is 10.1.1.1 to network 0.0.0.0

S*    0.0.0.0/0 [254/0] via 10.1.1.1
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.1.1.0/24 is directly connected, Ethernet0/0
L        10.1.1.10/32 is directly connected, Ethernet0/0
Router#

We can see above our PC an IP from the assigned range and it's pinging the internet.

Verifying DHCP lease on Fortigate

NETINFO_FORTINET # execute dhcp lease-list 
port1
  IP                    MAC-Address             Hostname                VCI                     Expiry
  10.1.1.10             aa:bb:cc:00:05:00       Router                          Thu May 11 08:06:19 2023

NETINFO_FORTINET # 


You can configure DHCP in GUI as well. in order to do that navigate to the below and enjoy

Configure DHCP on the FortiGate
To add a DHCP server on the GUI:

  1. Go to Network > Interfaces.
  2. Edit an interface.
  3. Enable the DHCP Server option and configure the settings.

I hope this has been informative for you. If it seems helpful then Like, Share, and do not forget to subscribe and follow me for the upcoming posts

https://www.youtube.com/channel/UC0-p23p1xWsZsTXHUQ7CiJg

https://www.facebook.com/networkinginfo/

https://twitter.com/Dj1Pali

https://www.instagram.com/a_bhartiya_rider/

https://www.linkedin.com/in/dinesh-jangid-515b6a23/


No comments

Powered by Blogger.