DHCP Logging in Cisco IOS Is a Nightmare
One of the readers sent me an interesting question: he’d like to know the IP address of his home router (to be able to connect to it from the office), but its IP address is assigned through DHCP and changes occasionally.
I wanted to solve the problem by hooking an EEM applet onto the DHCP-6-ADDRESS_ASSIGN syslog message. No good; as it turns out, Cisco IOS generates the logging message only when a DHCP-acquired IP address is assigned to an interface without one. If the IP address is changed via DHCP, the change is not logged.
One could understand the faulty programmers’ logic if the initial address assignment would be different from the address change, but DHCP is such a simple protocol that any change in client’s IP address requires the client to enter the INIT state, so acquiring a new IP address is no different from changing an existing one. I guess they had to take special precautions not to log the address change (and ensure we have another interesting challenge to chew on).
Fortunately, the IP routing table changes after every change in interface IP address, and you can catch that event with EEM.
ip ddns update method editdns
HTTP
add http://dyndns.editdns.net/api/dynLinux.php?p=PASSWORD&r=DNS_ENTRY
interval maximum 10 0 0 0
interval minimum 0 0 0 30
!
interface GigabitEthernet0/0
ip ddns update hostname g0-0.a.gw.teb.example.com
ip ddns update editdns host dyndns.editdns.net
ip address dhcp client-id GigabitEthernet0/0
!
http://www.cisco.com/en/US/docs/ios/ipaddr/command/reference/iad_dns1.html#wp1012430