getting notification of public IP address change

Message
Author
User avatar
junoluna
Posts: 522
Joined: Sun Sep 29, 2019 11:53 pm

getting notification of public IP address change

#1 Post by junoluna »

was not sure where to put this because it really is not very mx related .......... but Is it possible to set up some kind of email notification?

i find the instructions on here better than stuff i try to glean from around the net

i have installed nextcloud and am dead pleased with it.... my server is located on a subdomain ncs.example.com.

example.com is hosted by wix and all works well on my LAN - all also works very well from outside my network as long as i change the A record in my DNS settings to show my actual current public IP...

being a dynamic IP - the thing changes fairly often and i have to update my DNS records.... no big problem when i am home - takes 5 seconds but if i am at work when the IP changes, then i cannot access my server....

i searched a bit and got lots of advice regarding dynamic dns servers - i don't even need anything that complex but is it possible to set up some kind of simple script that would notify me by email when my IP changes?

if anyone knows a simple way of achieving this, it would be great ..... as ever when responding to me, please don't confuse me with someone who knows what they are doing ... :turtle:
Last edited by junoluna on Thu Jan 18, 2024 2:22 am, edited 2 times in total.

User avatar
junoluna
Posts: 522
Joined: Sun Sep 29, 2019 11:53 pm

Re: getting notification of public IP address change

#2 Post by junoluna »

QSI for completeness - not my server QSI but an identical machine with pretty much identical propeties

Code: Select all

Snapshot created on: 20230804_1306
System:
  Kernel: 6.1.0-10-amd64 [6.1.38-2] arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.1.0-10-amd64 root=UUID=<filter> ro quiet splash
  Desktop: KDE Plasma v: 5.27.5 wm: kwin_x11 vt: 7 dm: SDDM Distro: MX-23.1_x64 Libretto August
    04 2023 base: Debian GNU/Linux 12 (bookworm)
Machine:
  Type: Laptop System: Dell product: Latitude E7470 v: N/A serial: <superuser required> Chassis:
    type: 9 serial: <superuser required>
  Mobo: Dell model: 0T6HHJ v: A00 serial: <superuser required> UEFI: Dell v: 1.36.3
    date: 09/18/2022
Battery:
  ID-1: BAT0 charge: 12.1 Wh (51.7%) condition: 23.4/38.0 Wh (61.5%) volts: 7.7 min: 7.6
    model: Samsung SDI DELL 1W2Y268 type: Li-poly serial: <filter> status: discharging
CPU:
  Info: model: Intel Core i5-6200U bits: 64 type: MT MCP arch: Skylake gen: core 6 level: v3
    note: check built: 2015 process: Intel 14nm family: 6 model-id: 0x4E (78) stepping: 3
    microcode: 0xF0
  Topology: cpus: 1x cores: 2 tpc: 2 threads: 4 smt: enabled cache: L1: 128 KiB
    desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB desc: 2x256 KiB L3: 3 MiB desc: 1x3 MiB
  Speed (MHz): avg: 698 high: 700 min/max: 400/2800 scaling: driver: intel_pstate
    governor: powersave cores: 1: 696 2: 700 3: 697 4: 700 bogomips: 19200
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
  Type: retbleed mitigation: IBRS
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: IBRS, IBPB: conditional, STIBP: conditional, RSB filling,
    PBRSB-eIBRS: Not affected
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel Skylake GT2 [HD Graphics 520] vendor: Dell Latitude E7470 driver: i915 v: kernel
    arch: Gen-9 process: Intel 14n built: 2015-16 ports: active: eDP-1 empty: DP-1,HDMI-A-1,HDMI-A-2
    bus-ID: 00:02.0 chip-ID: 8086:1916 class-ID: 0300
  Device-2: Sunplus Innovation Dell E5570 integrated webcam type: USB driver: uvcvideo
    bus-ID: 1-2:2 chip-ID: 1bcf:2b91 class-ID: 0e02
  Display: x11 server: X.Org v: 1.21.1.7 with: Xwayland v: 22.1.9 compositor: kwin_x11 driver: X:
    loaded: modesetting unloaded: fbdev,vesa dri: iris gpu: i915 display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1366x768 s-dpi: 96 s-size: 361x203mm (14.21x7.99") s-diag: 414mm (16.31")
  Monitor-1: eDP-1 model: BOE Display 0x05f3 built: 2013 res: 1366x768 hz: 60 dpi: 112 gamma: 1.2
    size: 309x173mm (12.17x6.81") diag: 354mm (13.9") ratio: 16:9 modes: 1366x768
  API: OpenGL v: 4.6 Mesa 23.1.2-1~mx23ahs renderer: Mesa Intel HD Graphics 520 (SKL GT2)
    direct-render: Yes
Audio:
  Device-1: Intel Sunrise Point-LP HD Audio vendor: Dell Latitude E7470 driver: snd_hda_intel
    v: kernel alternate: snd_soc_skl,snd_sof_pci_intel_skl bus-ID: 00:1f.3 chip-ID: 8086:9d70
    class-ID: 0403
  API: ALSA v: k6.1.0-10-amd64 status: kernel-api tools: alsamixer,amixer
  Server-1: PipeWire v: 1.0.0 status: active with: 1: pipewire-pulse status: active
    2: wireplumber status: active 3: pipewire-alsa type: plugin 4: pw-jack type: plugin
    tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Intel Ethernet I219-LM vendor: Dell Latitude E7470 driver: e1000e v: kernel port: N/A
    bus-ID: 00:1f.6 chip-ID: 8086:156f class-ID: 0200
  IF: eth0 state: down mac: <filter>
  Device-2: Intel Wireless 8260 driver: iwlwifi v: kernel modules: wl pcie: gen: 1
    speed: 2.5 GT/s lanes: 1 bus-ID: 01:00.0 chip-ID: 8086:24f3 class-ID: 0280
  IF: wlan0 state: up mac: <filter>
Bluetooth:
  Device-1: Intel Bluetooth wireless interface type: USB driver: btusb v: 0.8 bus-ID: 1-8:3
    chip-ID: 8087:0a2b class-ID: e001
  Report: hciconfig ID: hci0 rfk-id: 5 state: up address: <filter> bt-v: 2.1 lmp-v: 4.2
    sub-v: 100 hci-v: 4.2 rev: 100
  Info: acl-mtu: 1021:4 sco-mtu: 96:6 link-policy: rswitch sniff link-mode: peripheral accept
    service-classes: rendering, capturing, object transfer, audio, telephony
Drives:
  Local Storage: total: 232.89 GiB used: 136.36 GiB (58.6%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/sda maj-min: 8:0 vendor: Western Digital model: WDS250G2B0B size: 232.89 GiB
    block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter> rev: 90WD
    scheme: GPT
Partition:
  ID-1: / raw-size: 232.63 GiB size: 227.92 GiB (97.97%) used: 136.36 GiB (59.8%) fs: ext4
    dev: /dev/sda2 maj-min: 8:2
  ID-2: /boot/efi raw-size: 256 MiB size: 252 MiB (98.46%) used: 274 KiB (0.1%) fs: vfat
    dev: /dev/sda1 maj-min: 8:1
Swap:
  Kernel: swappiness: 15 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: file size: 3 GiB used: 789.9 MiB (25.7%) priority: -2 file: /swap/swap
Sensors:
  System Temperatures: cpu: 39.0 C pch: 36.5 C mobo: 35.0 C
  Fan Speeds (RPM): cpu: 0
Repos:
  Packages: 2556 pm: dpkg pkgs: 2544 libs: 1373 tools: apt,apt-get,aptitude,nala pm: rpm pkgs: 0
    pm: flatpak pkgs: 12
  No active apt repos in: /etc/apt/sources.list
  Active apt repos in: /etc/apt/sources.list.d/debian-stable-updates.list
    1: deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/debian.list
    1: deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
    2: deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
    3: deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/mx.list
    1: deb https://mirror.kku.ac.th/mx-packages/mx/repo/ bookworm main non-free
    2: deb https://mirror.kku.ac.th/mx-packages/mx/repo/ bookworm ahs
  Active apt repos in: /etc/apt/sources.list.d/teamviewer.list
    1: deb [signed-by=/usr/share/keyrings/teamviewer-keyring.gpg] https://linux.teamviewer.com/deb stable main
Info:
  Processes: 233 Uptime: 16h 1m wakeups: 32 Memory: 7.65 GiB used: 4.13 GiB (53.9%) Init: SysVinit
  v: 3.06 runlevel: 5 default: graphical tool: systemctl Compilers: gcc: 12.2.0 alt: 12
  Client: shell wrapper v: 5.2.15-release inxi: 3.3.26
Boot Mode: UEFI

User avatar
DukeComposed
Posts: 1286
Joined: Thu Mar 16, 2023 1:57 pm

Re: getting notification of public IP address change

#3 Post by DukeComposed »

junoluna wrote: Thu Jan 18, 2024 2:13 am being a dynamic IP - the thing changes fairly often and i have to update my DNS records.... no big problem when i am home - takes 5 seconds but if i am at work when the IP changes, then i cannot access my server....
DynDNS has offered a solution for this situation for a number of years and they seem to have a fairly good track record of it. I presume their business model is: you delegate your DNS records to them, you run a client on your machine, it periodically pings them and makes sure that the IP address matches what they publish in the Domain Name System.

If you want to replicate that, you could put together a short Perl or Python script that checks what its public-facing IP address is, and then periodically updates your DNS records with that info.

User avatar
junoluna
Posts: 522
Joined: Sun Sep 29, 2019 11:53 pm

Re: getting notification of public IP address change

#4 Post by junoluna »

thanks for that.... i wouldn't really have the first idea how to write a script so i asked chat gpt to do it for me.... i doubt this is best practice but it looks ok to me and i don't feel dumb when i ask her (for she is definitely a sheila) for clarification 24 billion times...

may actually be working - i just need to wait for a public IP change to see if it notifies me

User avatar
DukeComposed
Posts: 1286
Joined: Thu Mar 16, 2023 1:57 pm

Re: getting notification of public IP address change

#5 Post by DukeComposed »

junoluna wrote: Thu Jan 18, 2024 11:22 pm thanks for that.... i wouldn't really have the first idea how to write a script so i asked chat gpt to do it for me.... i doubt this is best practice but it looks ok to me and i don't feel dumb when i ask her (for she is definitely a sheila) for clarification 24 billion times...

may actually be working - i just need to wait for a public IP change to see if it notifies me
I spent about five minutes looking around and it seems like ipify.org has a free API you can test out with just "curl https://api.ipify.org".

Be aware of how frequently your IP changes and prepare your DNS records' TTL values accordingly. Low TTLs increase traffic (and can in theory make malicious domain hijacking easier). High TTLs reduce traffic, since it lets resolvers cache the answers you give them for a longer period of time. But when your IP changes, they'll still expect to use the old value for as long as you told them they could. If your IP address changes and you run your script and update your DNS records with the new IP, your site is still unreachable to all the people who are still using the old records until their TTLs expire.

Edit: Fixed URL.
Last edited by DukeComposed on Fri Jan 19, 2024 5:52 am, edited 1 time in total.

User avatar
Eadwine Rose
Administrator
Posts: 14428
Joined: Wed Jul 12, 2006 2:10 am

Re: getting notification of public IP address change

#6 Post by Eadwine Rose »

I happen to have the IP address showing up in my conky, so I can see it when it changes.

Oh.. in fact it has this morning.
MX-23.6_x64 July 31 2023 * 6.1.0-34amd64 ext4 Xfce 4.20.0 * 8-core AMD Ryzen 7 2700
Asus TUF B450-Plus Gaming UEFI * Asus GTX 1050 Ti Nvidia 535.216.01 * 2x16Gb DDR4 2666 Kingston HyperX Predator
Samsung 870EVO * Samsung S24D330 & P2250 * HP Envy 5030

User avatar
junoluna
Posts: 522
Joined: Sun Sep 29, 2019 11:53 pm

Re: getting notification of public IP address change

#7 Post by junoluna »

Eadwine Rose wrote: Fri Jan 19, 2024 5:50 am I happen to have the IP address showing up in my conky, so I can see it when it changes.

Oh.. in fact it has this morning.
that would work fine when i am at home thanks
i remember adding the IP address to a conky config before - which one do you use Eadwine - is it pre-configured?

edit - have tried searching for the post that helped me add my ip to conky but can't find it.
Last edited by junoluna on Sun Jan 21, 2024 9:11 pm, edited 1 time in total.

User avatar
junoluna
Posts: 522
Joined: Sun Sep 29, 2019 11:53 pm

Re: getting notification of public IP address change

#8 Post by junoluna »

DukeComposed wrote: Fri Jan 19, 2024 5:45 am
I spent about five minutes looking around and it seems like ipify.org has a free API you can test out with just "curl https://api.ipify.org".
thanks - it actually does work - i just have to remember to charge my phone now -

i think nextcloud is just about the best thing i have ever seen (though none of it would be possible without the brilliant free operating systems we have-)- -sure my chips will be peed on at some point and i have left a big hole in my network for the world to poke around in :party2: :hitmyhead:

User avatar
figueroa
Posts: 1097
Joined: Thu Dec 20, 2018 11:20 pm

Re: getting notification of public IP address change

#9 Post by figueroa »

I use the ddclient application with dyn.dns for all my dynamic IP address changes. ddclient changes can trigger an email to you if you have smtp setup.
Andy Figueroa
Using Unix from 1984; GNU/Linux from 1993

User avatar
Eadwine Rose
Administrator
Posts: 14428
Joined: Wed Jul 12, 2006 2:10 am

Re: getting notification of public IP address change

#10 Post by Eadwine Rose »

junoluna wrote: Sun Jan 21, 2024 8:11 pm
Eadwine Rose wrote: Fri Jan 19, 2024 5:50 am I happen to have the IP address showing up in my conky, so I can see it when it changes.

Oh.. in fact it has this morning.
that would work fine when i am at home thanks
i remember adding the IP address to a conky config before - which one do you use Eadwine - is it pre-configured?
I have an own made conky, don't use the ones that come with the system.

Code: Select all

${color Tan1}IP number${goto 105}${color}${execi 3600 wget -q -O - https://icanhazip.com}
That is how I make mine appear, which gets requested every hour. Of course there is formatting and coloring around it here :)
MX-23.6_x64 July 31 2023 * 6.1.0-34amd64 ext4 Xfce 4.20.0 * 8-core AMD Ryzen 7 2700
Asus TUF B450-Plus Gaming UEFI * Asus GTX 1050 Ti Nvidia 535.216.01 * 2x16Gb DDR4 2666 Kingston HyperX Predator
Samsung 870EVO * Samsung S24D330 & P2250 * HP Envy 5030

Post Reply

Return to “Software / Configuration”