pan-os-python
pan-os-python copied to clipboard
Configure DHCP server/DHCP relay
There seems to be no way of configure dhcp server or relay with panos-python at the moment or I missed something?
@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'
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()