-
-
Save djdembeck/4c2f251bf7a53a0ff9e1de2305043e40 to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| # Polls AT&T's DHCP server for updates, to keep static IPs alive. | |
| # This allows UDM Pro users to set their DHCP IP as 'static' in the 'Internet' section | |
| # allowing the use of static IP configuration in Unifi Network. | |
| # 1. Find your DHCP IP. | |
| # 2. Set Internet IPv4 to Static IP, and enter your DHCP address. Gateway is going to be .1 | |
| # 3. Add your static IP block to Additional IP Addresses | |
| # 4. Place this script in the on_boot.d/ directory: https://github.com/unifi-utilities/unifios-utilities/tree/main/on-boot-script | |
| # 5. After reboot, check the script is working: cat /var/log/udhcpc.log | |
| # Credit to https://community.ui.com/questions/Additional-IP-with-DHCP-primary-on-UDM-Pro/ceeaa11b-b1f2-442d-a8ba-6cdfcc29c7f6 | |
| # Tested on 3.0.20 | |
| PUBLIC_DHCP_IP="" | |
| # eth8 is RJ45, eth9 is SFP+ on UDMP | |
| WAN_PORT="eth9" | |
| nohup /usr/bin/busybox-legacy/udhcpc --foreground --interface $WAN_PORT --script /usr/share/ubios-udapi-server/ubios-udhcpc-script -r $PUBLIC_DHCP_IP >/var/log/udhcpc.log 2>&1 & |
| # /etc/logrotate.d/udhcpc | |
| # Rotate the logs to keep them from filling up the system | |
| /var/log/udhcpc.log { | |
| weekly | |
| rotate 1 | |
| size 100K | |
| compress | |
| delaycompress | |
| } |
Does this survive Ubiquiti updates?
This seems to most of the time. Though I have found cases where a Unifi update will remove wpasupplicant entirely and it needs to be reinstalled. In which case it does seem to keep the config files.
Obviously it doesn’t survive a factory reset which I had to recently. I’ve since wrote myself step by step instructions to be up and running from disaster recovery.
Thanks, clever script. I have a was-110 and a dmse and am going to buy a block of IP addresses. Since you mentioned you couldn't route entire networks with Source and Destination NAT rules, have you since looked at the policy engine Ubiquiti introduced? Without using the script, how were you able to obtain the dhcp address as well as the additional ip addresses (obviously then facing the issue you had routing entire networks with NAT rules)?
I must be missing something...https://community.ui.com/questions/UDM-PRO-Issue-with-Multiple-Static-Address-on-DHCP-Interface/293ff5b3-f38f-4914-9d72-2a34bbfcdce3
Does this survive Ubiquiti updates?