Interface IP in public range, incorrect IP sent to noip

0

RPi3 is connected to internet via 3G dongle. wwan0 interface IP is in public range, is accessible from outside and hasn't changed since I got the SIM. So far so good, right?

What worries me, is that a probably NAT-ed IP is sent to noip, not the interface one, making the site served by RPi inaccessible, unless the IP is known. Is there a way to send the "correct", wwan0 interface IP to noip?

Second worry is that when RPi will be moved off-site (to measure indoor temp), the dongle will use a different mobile mast and probably the IP of the wwan0 iface will change. My fear is that I will have to do a custom script to notify noip about the interface IP when IP changes or some sort of other notification.

Any feedback is appreciated!

krg

Posted 2018-01-16T06:52:06.420

Reputation: 7

Answers

0

Based on your story, my guess is that your operator has a proxy in place for mobile data speed optimization (something that reduces image sizes for example). This means your HTTP traffic will go through a proxy on the operator side, which could well be NAT'ed.

One way to avoid this is sending an explicit IP to noip (from their documentation):

curl http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.example.com&myip=1.2.3.4

This could easily be integrated into a shell script:

#!/bin/bash

IP=$(/sbin/ip -4 a l wwan0 | grep 'inet ' | grep -oP '(?<=inet\s)\d+(\.\d+){3}')

curl "http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.example.com&myip=${IP}"

Make this script executable and run it from cron every 10 minutes or so:

chmod 755 /home/user/update_noip.sh
crontab -e
# Add:
*/10 * * * * /home/user/update_noip.sh >/dev/null 2>&1

mtak

Posted 2018-01-16T06:52:06.420

Reputation: 11 805

Thank you, @mtak, for quick and concise reply!

Makes me bit embarrassed that I didn't even think of checking the noip documentation, but hey, we're only human.

Thanks for the script as well, something new to broaden my mind! – krg – 2018-01-16T19:02:32.193