j-c-m / ubnt-letsencrypt

Let's Encrypt setup instructions for Ubiquiti EdgeRouter
470 stars 68 forks source link

Determine $WANIP when multiple IPs are set #15

Closed bswinnerton closed 6 years ago

bswinnerton commented 6 years ago

This pull request modifies the logic to of the renew.acme.sh script to pull the first WAN IP address when there are multiple addresses on the specified $WAN interface.

As an example, with the current implementation:

brooks@ubnt# ip addr show switch0.4094
14: switch0.4094@switch0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether f0:9f:c2:6f:23:9f brd ff:ff:ff:ff:ff:ff
    inet 8.8.8.8/32 scope global switch0.4094
       valid_lft forever preferred_lft forever
    inet 10.70.254.11/32 scope global switch0.4094
       valid_lft forever preferred_lft forever
    inet6 fe80::f29f:c2ff:fe6f:239f/64 scope link
       valid_lft forever preferred_lft forever

Would result in a $WANIP of:

brooks@ubnt# ip addr show switch0.4094 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1
8.8.8.8
10.70.254.11

Causing a Verify error: connection refused, because I assume the lighttpd.conf file gets misconfigured.

This pull request, rather unintelligently just grabs the first address:

brooks@ubnt# ip addr show switch0.4094 | grep "inet\b" | awk '{print $2}' | head -n 1 | cut -d/ -f1
8.8.8.8
bswinnerton commented 6 years ago

Another approach would be to let the user manually pass in the $WANIP and skip the ip addr show logic altogether if it's been passed in.

j-c-m commented 6 years ago

With the changes in 1ca5ec089f5763be1adf9514297baeb5e0150f4b the wandev is no longer required, so I took it one step further and deprecated the option entirely!

Thanks for bringing this to my attention.