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

IPv4 to IPv6 Convertor

 

import ipaddress

 

def convertusingipaddress(ipv4address):

    print(ipaddress.IPv6Address('2002::' + ipv4address).compressed)

 

ipaddr=input("Enter your ip here: ")

convertusingipaddress(ipaddr)

 

OUTPUT








=======================================================================================================================================================

Note: In the above-given Python program there is one inbuild library imported to convert the Ipv4 into Ipv6 i.e.; “ipaddress” After that in the second line one function has been defined named “convertusingipaddressinside that function. I have printed using the module define at the top with the help of “.” Basically, it means the object of that inbuild module i.e.;IPv6Address('2002::' + ipv4address)will be converted in IPv6, and with “.compressed” I have compressed the original Ipv6 onto the compressed form of the IP address.

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