Yota
Very Senior Member
I ran into this question a few weeks ago while writing a script: How to make the main router and node execute some commands synchronously. At first I thought this was impossible, because for AP mode, the main router does not communicate with the AP, and for AiMesh because the code is closed source, it is impossible to pass custom commands to the node router. Actually I have been using a very insecure method before, keeping the ssh key in the main router and letting the main router control the AP/Node via ssh. But today I thought of a simple way to pass commands to AP/Node without logging into AP/Node.
The answer is simple: use DNS
We can specify an IPv6 address for a non-existing local hostname as the interface for passing commands. After the command is encrypted, we can translate it into a hexadecimal IPv6 address. If one address is not enough, multiple addresses can be used. Of course, multiple hostnames should be used at this time, and then specify the address in dnsmasq. The AP or node only needs to periodically try to resolve the hostname. If get the command and execute it. (Commands must be encrypted before they can be used as IPv6 addresses, otherwise there will be security risks)
The advantage of this is that because APs and nodes also run DNS servers, they do exactly the same thing, such as returning command results and logs to the main router in the form of IPv6 addresses.
There is no in-depth study on sending files, and it may be possible to temporarily mount a file using an existing http page and restore it after downloading. the two routers can communicate via IPv6 DNS results before sending the file.
Of course this requires some scripting, and constant polling, I'm just giving an idea, no examples here, however, with this idea, some custom script developers can achieve synchronization and communication between main router and aimesh node or ap.
If DNS is available, why not just send DNS with specific hostname request as command trigger?
Because this is not secure, anyone can send the same request on the LAN, even if the hostname used to pass the command is encrypted and the attacker cannot run the custom command, it is still possible for the attacker to capture the DNS request and send the same DNS request to the router multiple times, causing the router to continuously run the command and crash. also, this requires opening dnsmasq logs and monitoring the logs, whereas
The answer is simple: use DNS
We can specify an IPv6 address for a non-existing local hostname as the interface for passing commands. After the command is encrypted, we can translate it into a hexadecimal IPv6 address. If one address is not enough, multiple addresses can be used. Of course, multiple hostnames should be used at this time, and then specify the address in dnsmasq. The AP or node only needs to periodically try to resolve the hostname. If get the command and execute it. (Commands must be encrypted before they can be used as IPv6 addresses, otherwise there will be security risks)
The advantage of this is that because APs and nodes also run DNS servers, they do exactly the same thing, such as returning command results and logs to the main router in the form of IPv6 addresses.
There is no in-depth study on sending files, and it may be possible to temporarily mount a file using an existing http page and restore it after downloading. the two routers can communicate via IPv6 DNS results before sending the file.
Of course this requires some scripting, and constant polling, I'm just giving an idea, no examples here, however, with this idea, some custom script developers can achieve synchronization and communication between main router and aimesh node or ap.
If DNS is available, why not just send DNS with specific hostname request as command trigger?
Because this is not secure, anyone can send the same request on the LAN, even if the hostname used to pass the command is encrypted and the attacker cannot run the custom command, it is still possible for the attacker to capture the DNS request and send the same DNS request to the router multiple times, causing the router to continuously run the command and crash. also, this requires opening dnsmasq logs and monitoring the logs, whereas
nslookup
is much simpler and elegant.
Last edited: