pan-os-python icon indicating copy to clipboard operation
pan-os-python copied to clipboard

Configure DHCP server/DHCP relay

Open arielpa-tr opened this issue 5 years ago • 1 comments

There seems to be no way of configure dhcp server or relay with panos-python at the moment or I missed something?

arielpa-tr avatar Sep 02 '20 11:09 arielpa-tr

@shinmog It doesn't work. For example:

        dhcp_relay = DhcpRelay(
            enabled=True,
            name=interface_name,
            servers=[dhcp_relay_host]
        )
        template.add(dhcp_relay)
        dhcp_relay.create()

raises exception: ' localhost.localdomain -> relay unexpected here'

mzakonek avatar Mar 17 '25 16:03 mzakonek

This is because DhcpRelay is child object of Dhcp. Dhcp --> DhcpRelay --> DhcpRelayIpv6Address. Config Tree Diagram.

The following code works fine.

from panos import network

intf = 'ethernet1/1.10'
pan = panorama.Panorama(hostname, username, password)
tmpl = panporama.Template('pan-template')

pan.add(tmpl)

dhcp_parent = network.Dhcp(intf)
tmpl.add(dhcp_parent)

dhcp_relay = network.DhcpRelay(
  name=intf,
  servers=['1.2.3.4', '5.6.7.8'],
  enabled=True,
  ipv6_enabled=False
)

dhcp_parent.add(dhcp_relay)
dhcp_parent.create()

notthedan avatar Jun 26 '25 21:06 notthedan