How to create DHCP server and a policy in the Fortigate

Here is an example script that demonstrates how to use the  fortigate-api  package to create a DHCP server and a policy in the Fortigate   from fortigate_api import FortigateAPI # Create a FortigateAPI object fgt = FortigateAPI(host="host", username="username", password="password") # Create a DHCP server data = {     "default-gateway": "192.168.255.1",     "netmask": "255.255.255.0",     "interface": "vlan.123",     "ip-range": [         {"start-ip": "192.168.255.2", "end-ip": "192.168.255.254",}     ], } fgt.dhcp_server.create(data) # Create a policy in the Fortigate data = dict(     name="POLICY",     status="enable",     action="accept",     srcintf=[{"name": "any"}],     dstintf=[{"name": "any"}],     srcaddr=[{"name": "all"}],     dstaddr=[{"name&quo

PROGRAM TO FIND WILDCARD MASK USING SUBNET MASK AND VICE VERA

 

oct1,oct2,oct3,oct4=input("Enter the 'Subnet Mask' to know its 'Wildcard Mask' and Vice Versa: \n").split(".")

print(f"{255-int(oct1)}.{255-int(oct2)}.{255-int(oct3)}.{255-int(oct4)}")

 

OUTPUT



 

Note: In the above Program I have created 4 variables naming as oct1...4 and with the help of the input function take the user input basically It depends on what input has been given by the user whether it is a “subnet-mask” or “wildcard-mask” after I have used split function with “.” Which will split the user input by dot(.) and then store the data on the respective variables. In the next line, I printed the user data by using the print function where I have used ‘f’(string) to print the variable inside the string but there is one logic that has been implemented while printing you can see that “255-int(variable_name)” it is basically subtracting the variable value from 255 and printing on the console.

==================================X=============================

Comments

Popular posts from this blog

How to Configure VXLAN in FortiGate Firewall

Higher Availability in FortiGate and VRRP in Cisco

Python Script to take the Backup of Multiple device in a Network