• Adding Interface DHCP Support with an Event Handler

Print Friendly, PDF & Email

While EOS does not support DHCP on interfaces natively from the CLI, it is easy to leverage the underlying Linux operating system along with event-handlers to add this support yourself!

dhclient is available natively within EOS. The trick is that you need to first get dhclient to run for a given interface you want to DHCP an address for, and then you need to take the result from dhclient and apply that to the CLI as if it were a static configured IP address.

The following script (installed at /mnt/flash/dhcpintf) can be run out of an interface event-handler to start/stop dhclient for a given interface.

This dhclient script (installed at /mnt/flash/eosdhclientscript) translates the result of running dhclient into CLI configuration.

This script only supports interfaces in the default VRF. It also only configures the IP address and netmask of the interface, but could be extended to inject default routes, name servers, log servers, etc.

Now all you need to do is define an event-handler to run the dhcpintf script on the interface you’re interested in:

event-handler dhcp-ma1
trigger on-intf Management1 operstatus
action bash /mnt/flash/dhcpintf
delay 10


Get every new post on this blog delivered to your Inbox.

Join other followers: