Possible solution to determine if default network has changed (MacOS only for now)

Alex Tweedly alex at tweedly.net
Tue Oct 22 20:13:31 EDT 2019


Beware CARP !!   (or, very similarly, HSRP or VRRP).

In essence, there are a number of routers, which share a single MAC 
address - and it is passed between them (so there is always one active 
router and only it responds to the shared MAC address). Meanwhile they 
each use their own MAC address to run their routing protocols, and the HSRP.

Gives fast, easy and transparent fail-over (but with some pitfalls), so 
AFAIK not very widely used.

Alex.

P.S.  within Cisco, the engineering name for this was CRAP - but 
pressure form the marketing guys changed it, initally to CARP, and then 
to HSRP before it was released.

On 22/10/2019 19:05, Bob Sneidar via use-livecode wrote:

> Hi all.
>
> MacOS only for now.
>
> I think I put together a way to tell if the default network has changed since the last time an internet connection took place. It's no good of course, just getting the IP address, as given an identical subnet, you have a 1 in 254 change of getting the same IP address on a different network. We want to be absolutely certain.
>
> Similarly, the gateway, subnet mask and DNS might also be identical. Finally, the only adapter we care about is the one that is being used as the default route to the internet or local resources. (there may be more than one active adapter, as in the Ethernet and Wireless adapters).
>
> The trick is to get the MAC address of the router, then store it and compare it each time you attempt to communicate. Here's what I came up with. Feel free to chide me if I am overthinking this:
>
> on mouseUp
>     put "route get default" into tShellCommand
>     put shell(tShellCommand) into tDefaultAdapter
>     put lineOffset("Interface: ", tDefaultAdapter) into tInterfaceLine
>     
>     if tInterfaceLine = 0 then
>        answer info "No default interface found!" as sheet
>        exit mouseUp
>     end if
>     
>     put word 2 of line tInterfaceLine of tDefaultAdapter into tDefaultInterface
>     put "ipconfig getpacket " & tDefaultInterface into tShellCommand
>     put shell(tShellCommand) into tInterfaceDetail
>     put lineOffset("router (ip_mult): ", tInterfaceDetail) into tRouterLine
>     put word 3 of line tRouterLine of tInterfaceDetail into tRouterAddress
>     put char 2 to -2 of tRouterAddress into tRouterAddress
>     put tRouterAddress
>     put "arp " & tRouterAddress into tShellCommand
>     put shell(tShellCommand) into tArpReply
>     put word 4 of tArpReply into tDefaultMACAddress
> end mouseUp
>
> Bob S
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list