resolve raspbian clone no-ip conflict

31 views Asked by At

I cloned raspbian SO by "SD card copier". In that SO I configured no-ip web-server redirection (no-ip duc).

When I start raspbian clone in other location it steal ip redirect from it's original twin.

Using original SO with ethernet, and configured no-ip duc with ethernet, I figured out to solve problem by starting cloned SO with wifi, but it not worked!

The problem is: how to prevent cloned-SO (when started) steals ip-redirect of origonal-SO. Someone has an idea to do that? Tank you.

1

There are 1 answers

0
Marco On

I found a solution (but maybe exists some simpler).

Concept: add a bash script to crontab and verify if router MAC-address match with specific router.

The bash script is (note: chmod +x):

#!/bin/bash

# SCRIPT DOES IF ROUTER MATCH EXPECTED MAC ADDRESS

# -- EDITABLE PART --
# function todo if TRUE
function_MATCH () {
  echo "MAC adresses match!"
}

# function todo if FALSE
function_MISMATCH () {
  echo "it's not as expected!"
}


# CHANGE VALUE WITH YOUR ROUTER MAC ADDRESS
EXPECTED="55:55:55:55:55:55"

# -- END EDITABLE PART --

# get "arp -a" string of router:
arp=$(arp -a 192.168.1.1)
# extract MAC adress
MAC=${arp##*at }
MAC=${MAC% [*}
if [ "$MAC" = "$EXPECTED" ];
 then function_MATCH
 else function_MISMATCH
fi

This is a generic function callback (function_MATCH or function_MISMATCH). To use this script to activate no-ip service only if router match desired one, change function_MATCH() with following one:

function_MATCH () {
  echo "MAC adresses match!"
  sudo noip2
}

then, save script (where you prefer) and edit crontab by calling, in terminal:

$ crontab -e

finally, call script in crontab adding it at the end.

for example (be carefull to add right script-path):

@reboot sleep 60 && /home/user/scripts/router_verificator.sh

Note: no-ip service need a connection to update ip-redirect. doing verification after 60secs from SO-start prevent no connection available.

I know, its quite complicated. If someone has a smarter solution.. tank you.