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

PYTHON SCRIPT FOR LAYMAN NETWOK ENGINEER

 

netmiko import ConnectHandler

user = input("Enter the Username: ")

passwd = input("Enter the pass: ")

cisco_switch = {

    'device_type': 'cisco_ios',

    'host':   input("Enter the IP address: "),

    'username': user,

    'password': passwd,

    'port': 22,          # optional, defaults to 22

    'secret': 'secret',     # optional, defaults to ''

}

net_connect = ConnectHandler(**cisco_switch)

print("What do you want to see in switch: \n 1--VLAN\n 2--INETRFACE_IP\n 3--RUNING_CONFIG\n 4--STARTUP_CONFIG\n 5--TRUNK_PORTS\n 6--SPANING_TREE\n 7--MAC_ADDRESS_TABLE\n 8--ETHERCHANNEL/PORT-CHANNEL\n 9--IP_ROUTE_DATABASE\n")

while True:

    op = int(input("Enter your answer: "))

    if op == 1:

        output = net_connect.send_command('sh vlan br')

        print(output)

        print(100*"*")

    elif op == 2:

        net_connect.enable

        output = net_connect.send_command('sh ip int br')

        print(output)

        print(100*"*")

    elif op == 3:

        output = net_connect.send_command('sh running-config')

        print(output)

        print(100*"*")

    elif op == 4:

        output = net_connect.send_command('sh startup-config')

        print(output)

        print(100*"*")

    elif op == 5:

        output = net_connect.send_command('sh interfaces trunk')

        print(output)

        print(100*"*")

    elif op == 6:

        output = net_connect.send_command('sh spanning-tree summary')

        print(output)

        print(100*"*")

    elif op == 7:

        output = net_connect.send_command('sh mac address-table')

        print(output)

        print(100*"*")

    elif op == 8:

        output = net_connect.send_command('sh etherchannel summary')

        print(output)

        print(100*"*")

    elif op == 9:

        output = net_connect.send_command('sh ip route')

        print(output)

        print(100*"*")

    elif op == 0:

        exit(0)

    else:

        print("!!Invalid input")

 

OUTPUT: -




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