(Die Seite wurde neu angelegt: „= Kommunikationsprotokoll = Router fragt neuer nach Adresse "asknew MAC" -> Alle antworten "usethis ASSIGNER MAC IP" ---> Router nutzt die erste msg die rein…“) |
|||
Zeile 59: | Zeile 59: | ||
option ipv6 'ADRESSE' | option ipv6 'ADRESSE' | ||
option assigner 'ASSIGNER | option assigner 'ASSIGNER | ||
<code> | |||
#!/bin/sh | #!/bin/sh | ||
Zeile 114: | Zeile 114: | ||
canusethis | canusethis | ||
fi | fi | ||
</code> | |||
= Node-Red Code = | = Node-Red Code = | ||
{ "f8:1a:67:a6:03:05": "<?xml version='1.0' standalone='yes'?><data><system_data><status>online</status><hostname>testknoten</hostname><description><![CDATA[Test]]></description><geo><lat>49.47271864</lat><lng>10.95820785</lng></geo><position_comment><![CDATA[Test]]></position_comment><contact>fff-router@chrisi01.de</contact><uptime>202139.89</uptime><idletime>199206.18</idletime><memory_total>124256</memory_total><memory_free>75988</memory_free><memory_buffering>4060</memory_buffering><memory_caching>17880</memory_caching><chipset>Freescale P1014</chipset><cpu>TP-Link TL-WDR4900 v1</cpu><model>TP-Link TL-WDR4900 v1</model><local_time>1608675321</local_time><loadavg>0.00</loadavg><processes>1/52</processes><kernel_version>4.14.209</kernel_version><nodewatcher_version>59</nodewatcher_version><babel_version>babeld-1.9.2+fff1</babel_version><distname>OpenWrt</distname><distversion>19.07.5</distversion><firmware_version>layer3-20200501-53-geaa5286-dirty</firmware_version><firmware_revision>build date: Sat Dec 19 13:30:34 UTC 2020</firmware_revision><openwrt_core_revision>v19.07.5</openwrt_core_revision><openwrt_feeds_packages_revision>2974079d3db786fe5da00c10f1d80e79b0112093</openwrt_feeds_packages_revision><hood>test</hood><hoodid></hoodid><vpn_active>0</vpn_active></system_data><interface_data><br-mesh><name>br-mesh</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><ipv4_addr>10.83.228.1</ipv4_addr><ipv6_addr>2a0b:f4c0:1a:58::/64</ipv6_addr><ipv6_addr>fdff::fa1a:67ff:fea6:305/64</ipv6_addr><ipv6_addr>fdff::1/64</ipv6_addr><ipv6_addr>fdff::f81a:67a6:305/64</ipv6_addr><ipv6_link_local_addr>fe80::fa1a:67ff:fea6:305/64</ipv6_link_local_addr><traffic_rx>0</traffic_rx><traffic_tx>33532</traffic_tx></br-mesh><eth0.1><name>eth0.1</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>0</traffic_rx><traffic_tx>33532</traffic_tx></eth0.1><eth0.2><name>eth0.2</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>0</traffic_rx><traffic_tx>23020680</traffic_tx></eth0.2><eth0.3><name>eth0.3</name><mtu>1500</mtu><mac_addr>fa:1a:67:a6:03:04</mac_addr><traffic_rx>837126540</traffic_rx><traffic_tx>256736647</traffic_tx></eth0.3><eth0><name>eth0</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>867779840</traffic_rx><traffic_tx>299961031</traffic_tx></eth0><w2ap><name>w2ap</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:04</mac_addr><traffic_rx>2338</traffic_rx><traffic_tx>16948755</traffic_tx><wlan_mode>Master</wlan_mode><wlan_tx_power>18 dBm</wlan_tx_power><wlan_ssid>bla.freifunk</wlan_ssid><wlan_type>AP</wlan_type><wlan_channel>13</wlan_channel><wlan_width>20</wlan_width></w2ap></interface_data><client_count>0</client_count><clients><eth0.1>0</eth0.1><w2ap>0</w2ap></clients><airtime2><active>171849671</active><busy>21780087</busy></airtime2><traffic_control><wan><enabled>0</enabled><in>0</in><out>0</out></wan></traffic_control><babel_neighbours><neighbour><ip>fe80::ba27:ebff:fe54:3b09</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>96</link_cost></neighbour><neighbour><ip>fe80::eade:27ff:fe58:ee94</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>256</link_cost></neighbour><neighbour><ip>fe80::fa1a:67ff:fe5a:857e</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>256</link_cost></neighbour></babel_neighbours></data>\n" } | { "f8:1a:67:a6:03:05": "<?xml version='1.0' standalone='yes'?><data><system_data><status>online</status><hostname>testknoten</hostname><description><![CDATA[Test]]></description><geo><lat>49.47271864</lat><lng>10.95820785</lng></geo><position_comment><![CDATA[Test]]></position_comment><contact>fff-router@chrisi01.de</contact><uptime>202139.89</uptime><idletime>199206.18</idletime><memory_total>124256</memory_total><memory_free>75988</memory_free><memory_buffering>4060</memory_buffering><memory_caching>17880</memory_caching><chipset>Freescale P1014</chipset><cpu>TP-Link TL-WDR4900 v1</cpu><model>TP-Link TL-WDR4900 v1</model><local_time>1608675321</local_time><loadavg>0.00</loadavg><processes>1/52</processes><kernel_version>4.14.209</kernel_version><nodewatcher_version>59</nodewatcher_version><babel_version>babeld-1.9.2+fff1</babel_version><distname>OpenWrt</distname><distversion>19.07.5</distversion><firmware_version>layer3-20200501-53-geaa5286-dirty</firmware_version><firmware_revision>build date: Sat Dec 19 13:30:34 UTC 2020</firmware_revision><openwrt_core_revision>v19.07.5</openwrt_core_revision><openwrt_feeds_packages_revision>2974079d3db786fe5da00c10f1d80e79b0112093</openwrt_feeds_packages_revision><hood>test</hood><hoodid></hoodid><vpn_active>0</vpn_active></system_data><interface_data><br-mesh><name>br-mesh</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><ipv4_addr>10.83.228.1</ipv4_addr><ipv6_addr>2a0b:f4c0:1a:58::/64</ipv6_addr><ipv6_addr>fdff::fa1a:67ff:fea6:305/64</ipv6_addr><ipv6_addr>fdff::1/64</ipv6_addr><ipv6_addr>fdff::f81a:67a6:305/64</ipv6_addr><ipv6_link_local_addr>fe80::fa1a:67ff:fea6:305/64</ipv6_link_local_addr><traffic_rx>0</traffic_rx><traffic_tx>33532</traffic_tx></br-mesh><eth0.1><name>eth0.1</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>0</traffic_rx><traffic_tx>33532</traffic_tx></eth0.1><eth0.2><name>eth0.2</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>0</traffic_rx><traffic_tx>23020680</traffic_tx></eth0.2><eth0.3><name>eth0.3</name><mtu>1500</mtu><mac_addr>fa:1a:67:a6:03:04</mac_addr><traffic_rx>837126540</traffic_rx><traffic_tx>256736647</traffic_tx></eth0.3><eth0><name>eth0</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>867779840</traffic_rx><traffic_tx>299961031</traffic_tx></eth0><w2ap><name>w2ap</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:04</mac_addr><traffic_rx>2338</traffic_rx><traffic_tx>16948755</traffic_tx><wlan_mode>Master</wlan_mode><wlan_tx_power>18 dBm</wlan_tx_power><wlan_ssid>bla.freifunk</wlan_ssid><wlan_type>AP</wlan_type><wlan_channel>13</wlan_channel><wlan_width>20</wlan_width></w2ap></interface_data><client_count>0</client_count><clients><eth0.1>0</eth0.1><w2ap>0</w2ap></clients><airtime2><active>171849671</active><busy>21780087</busy></airtime2><traffic_control><wan><enabled>0</enabled><in>0</in><out>0</out></wan></traffic_control><babel_neighbours><neighbour><ip>fe80::ba27:ebff:fe54:3b09</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>96</link_cost></neighbour><neighbour><ip>fe80::eade:27ff:fe58:ee94</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>256</link_cost></neighbour><neighbour><ip>fe80::fa1a:67ff:fe5a:857e</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>256</link_cost></neighbour></babel_neighbours></data>\n" } |
Version vom 23. Dezember 2020, 20:15 Uhr
Kommunikationsprotokoll
Router fragt neuer nach Adresse "asknew MAC" -> Alle antworten "usethis ASSIGNER MAC IP" ---> Router nutzt die erste msg die rein ploppt [Filter]
Router fragt ob er Adresse noch nutzen darf "canusethis MAC ASSIGNER IP" -> Vergeber antwortet "MAC ack ASSIGNER IP" --> Router nutzt Adresse weiter [Prüfscript] (dies muss alle 5 Minuten erledigt werden)
-> Vergeber antwortet "MAC nack ASSIGNER IP" --> Router frag neuer nach Adresse (Line 1)
-> Vergeber antwortet gar nicht --> Router frag neuer nach Adresse (Line 1)
Vergeber gibt Adresse frei wenn kein "canusethis" mehr kommt, er kann frei entscheiden wann er sie freigeben will, es sollte jedoch mindestens 1h sein um nicht ständig neue Adressen durch kurze Downtimes zu triggern (bei genug Adressen auch gerne deutlich mehr).
MAC => eindeutige Identifikation des Routers ASSIGNER => eindeutige Identifikation des mqtt Clients der IP Adressen vergibt
[Prüfscript] Prüfscript ob die Adresse funktioniert: Sie funktioniert: -> Vote positiv Sie funktioniert nicht -> Vote negativ --> Router frag neuer nach Adresse (Line 1)
[Filter] - Frage alle /ipv6/vote ab, mehr negativ als positiv filter out (mosquitto_sub -T '/ipv6/usethis/#/$ASSIGNER') - Manueller Filter für User (mosquitto_sub -T '/ipv6/usethis/#/$ASSIGNER') $ASSIGNER IST USERINPUT
/ipv6/asknew $MAC
/ipv6/usethis/$MAC/$ASSIGNER (wir brauchen $ASSIGNER da oben für [Filter]) { "assigner":"$ASSIGNER", "ip":"$IP" }
/ipv6/canusethis/$ASSIGNER { "mac":"$MAC", "ip":"$IP" }
/ipv6/canusethisanswer/$MAC ack
/ipv6/vote/$MACADDR/$ASSIGNER (retain) ack/nack
/etc/config/autol3
config ipv6
option ipv6 'ADRESSE'
option assigner 'ASSIGNER
- !/bin/sh
. /usr/share/libubox/jshn.sh
MACADDR=$(cat /sys/class/net/br-mesh/address | /bin/sed 's/://g')
MQTTSERVER=$(uci -q get mqtt.mqtt.server)
ASSIGNEROWN=$(uci -q get fff.autol3.assigner)
IPOWN=$(uci -q get fff.autol3.address)
asknew() {
mosquitto_pub -h $MQTTSERVER -p 1883 -t '/ipv6/asknew' -m "$MACADDR"
# use the first income message
# cancel after 5 second, after this time we don't get any IP address
autol3config=$(mosquitto_sub -h $MQTTSERVER -p 1883 -t '/ipv6/usethis/#' -C 1)
if [ -z "$autol3config" ] ; then
echo "No IP get"
exit 1;
fi
json_load "$autol3config"
json_get_var assigner assigner
json_get_var ip ip
uci set fff.autol3.address=$ip
uci set fff.autol3.assigner=$assigner
uci commit fff
uci del gateway.@client[0].ip6addr
uci add_list gateway.@client[0].ip6addr=$ip
uci commit gateway
yes | configure-layer3 -c
configure-layer3 -a
exit;
}
canusethis() {
mosquitto_pub -h "$(uci get mqtt.mqtt.server)" -p 1883 -t /ipv6/canusethis/$ASSIGNEROWN -m "{ \"mac\":\"$MACADDR\", \"ip\":\"$IPOWN\" }"
canusethisanswer=$(mosquitto_sub -h $MQTTSERVER -p 1883 -t /ipv6/canusethisanswer/$MACADDR -C 1 -W 5)
# check if we get answer, if no load asknew again and get new ip address
if [ -z $canusethisanswer ] ; then
uci del fff.autol3.address
uci del fff.autol3.assigner
uci commit fff
asknew
fi
}
if [ -z $(uci -q get fff.autol3) ] ; then
uci set fff.autol3=autol3
fi
if [ -n $(uci -q get fff.autol3) ] && [ -z $(uci -q get fff.autol3.address) ] ; then
asknew
fi
if [ -n $(uci -q get fff.autol3.address) ] ; then
canusethis
fi
Node-Red Code
{ "f8:1a:67:a6:03:05": "<?xml version='1.0' standalone='yes'?><system_data><status>online</status><hostname>testknoten</hostname><description><![CDATA[Test]]></description><geo><lat>49.47271864</lat><lng>10.95820785</lng></geo><position_comment><![CDATA[Test]]></position_comment><contact>fff-router@chrisi01.de</contact><uptime>202139.89</uptime><idletime>199206.18</idletime><memory_total>124256</memory_total><memory_free>75988</memory_free><memory_buffering>4060</memory_buffering><memory_caching>17880</memory_caching><chipset>Freescale P1014</chipset><cpu>TP-Link TL-WDR4900 v1</cpu><model>TP-Link TL-WDR4900 v1</model><local_time>1608675321</local_time><loadavg>0.00</loadavg><processes>1/52</processes><kernel_version>4.14.209</kernel_version><nodewatcher_version>59</nodewatcher_version><babel_version>babeld-1.9.2+fff1</babel_version><distname>OpenWrt</distname><distversion>19.07.5</distversion><firmware_version>layer3-20200501-53-geaa5286-dirty</firmware_version><firmware_revision>build date: Sat Dec 19 13:30:34 UTC 2020</firmware_revision><openwrt_core_revision>v19.07.5</openwrt_core_revision><openwrt_feeds_packages_revision>2974079d3db786fe5da00c10f1d80e79b0112093</openwrt_feeds_packages_revision><hood>test</hood><hoodid></hoodid><vpn_active>0</vpn_active></system_data><interface_data><br-mesh><name>br-mesh</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><ipv4_addr>10.83.228.1</ipv4_addr><ipv6_addr>2a0b:f4c0:1a:58::/64</ipv6_addr><ipv6_addr>fdff::fa1a:67ff:fea6:305/64</ipv6_addr><ipv6_addr>fdff::1/64</ipv6_addr><ipv6_addr>fdff::f81a:67a6:305/64</ipv6_addr><ipv6_link_local_addr>fe80::fa1a:67ff:fea6:305/64</ipv6_link_local_addr><traffic_rx>0</traffic_rx><traffic_tx>33532</traffic_tx></br-mesh><eth0.1><name>eth0.1</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>0</traffic_rx><traffic_tx>33532</traffic_tx></eth0.1><eth0.2><name>eth0.2</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>0</traffic_rx><traffic_tx>23020680</traffic_tx></eth0.2><eth0.3><name>eth0.3</name><mtu>1500</mtu><mac_addr>fa:1a:67:a6:03:04</mac_addr><traffic_rx>837126540</traffic_rx><traffic_tx>256736647</traffic_tx></eth0.3><eth0><name>eth0</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:05</mac_addr><traffic_rx>867779840</traffic_rx><traffic_tx>299961031</traffic_tx></eth0><w2ap><name>w2ap</name><mtu>1500</mtu><mac_addr>f8:1a:67:a6:03:04</mac_addr><traffic_rx>2338</traffic_rx><traffic_tx>16948755</traffic_tx><wlan_mode>Master</wlan_mode><wlan_tx_power>18 dBm</wlan_tx_power><wlan_ssid>bla.freifunk</wlan_ssid><wlan_type>AP</wlan_type><wlan_channel>13</wlan_channel><wlan_width>20</wlan_width></w2ap></interface_data><client_count>0</client_count><clients><eth0.1>0</eth0.1><w2ap>0</w2ap></clients><airtime2><active>171849671</active><busy>21780087</busy></airtime2><traffic_control><wan><enabled>0</enabled><in>0</in><out>0</out></wan></traffic_control><babel_neighbours><neighbour><ip>fe80::ba27:ebff:fe54:3b09</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>96</link_cost></neighbour><neighbour><ip>fe80::eade:27ff:fe58:ee94</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>256</link_cost></neighbour><neighbour><ip>fe80::fa1a:67ff:fe5a:857e</ip><outgoing_interface>eth0.3</outgoing_interface><link_cost>256</link_cost></neighbour></babel_neighbours>\n" }