Emlid

Community Forum

Can i use DDNS names?


#1

Hello,

in /etc/default/arducopter where I specify the IP of my GroundStation, can I also specify a DDNS domain ??

For example can I write TELEM1="-A udp:myGCS.no-ip.com:14550" ??

Of course I know that I will have to use port forward in my router both for UDP and TCP in order to make it pointing on the IP of my GCS … I am using RPI3 with Navio2 and the latest image that you provide here…

Thank you


(Coby Leuschke) #2

Any host name that can be properly resolved should work. Assuming the ports also pass any firewall rules.


(Igor Vereninov) #3

Ardupilot does not support hostname resolution.


(Benedikt) #4

i used to use mavproxy for ddns names!


#5

when i used the command ping myname.ddns.net it did return the ping times as expected. But when I used the myname.ddns.net name within the /etc/default/arducopter file, i cannot connect using MissionPlanner.

as ivereninov mentioned it seems that ardupilot does not support hostname resolution :rage:… Is there a request for this ?? I guess that anyone having a 4G-based drone, would be interested to use ddns names…

what can i do now ?? is there a workaround ? I would not like to use mavproxy for this…

thanks a lot


(Marcello) #6

Add these line in the config. While Arducopter will not accept them directly, adding these commands into the config will process the DDNS name into an IP :slight_smile:

hostname="myname.ddns.net"
ip=$(dig +short $hostname) #this also queries the DNS

TELEM1="-A $ip:14550"

Check this cool thread for more examples, etc. in case one doesn’t work for you! Thanks for asking this as I will add this into the tool I am working on!


#7

Marcello,

Into what config file do you add these lines?

Great contribution, thanks,

Paul


(Marcello) #8

/etc/default/arducopter is the file where you will find all the ardupilot settings.

hostname=$(dig +short myname.ddns.net)

TELEM1="-A $hostname:14550"

Also test this command in the terminal, to ensure it works at intended: dig +short myname.ddns.net

Let me know if something doesn’t work for you

My bad, forgot to post the link https://unix.stackexchange.com/questions/20784/how-can-i-resolve-a-hostname-to-an-ip-address-in-a-b


#9

Hello

I tested the command that you proposed dig +short myname.ddns.net individually in a termimal and it really returns the IP that i expected…

However when I modify the file /etc/default/arducopter as you said to look like
hostname=$(dig +short myname.ddns.net)
TELEM1="-A $hostname:14550"
i still cannot connect to MissionPlanner…

Can the command dig +short myname.ddns.net be recognized when it is inside the /etc/default/arducopter file ???

Please advise

Thanks a lot


#10

Hello,

can someone help me with this issue ?? How can I make it work ??

Thank you


(Marcello) #11

@drone_newbie My bad I was away at a competition, It is good news that the command is working. In terms of it not working when it is in the config file it may be because the config file is not actually formatted as a bash file? In other words you may have to add #!/bin/bash

I haven’t used the new image yet, I am planning to download it today, as I was using the older image for competition and didn’t want the new image to break what I was working on, so I will check it out for myself.


#12

Marcello, I also thought that this could happen because the config file was not formatted as bash file. SO i have already tried to add #!/bin/bash as well but it didnt work either…

Could you try it for yourself as well ? Maybe i did a mistake somewhere that i didnt realise…

THank you


(Marcello) #13

Yeah no problem, like I said I haven’t been running the new image because my competition, but I am downloading the update now. So I will look into it once its updated :slight_smile:


(Marcello) #14

@drone_newbie

This is interesting the fact that there is no #!/bash/bin yet it seems the config file is processed as bash, since it is set to ${ARDUPILOT_OPTS} which I believe is an environment variable. So if adding #!/bin/bash doesn’t work I’m afraid a dev is going to have to step in, as it may be a problem in how the config file is processed…

I cannot find any further details in the docs as to where the config file is read from or to how ${ARDUPILOT_OPTS} is setup

It may be worth double checking that all your DDNS info is correct


#15

i had a look as well about this to see from which service the config file is read…
so i found that the /etc/systemd/system/arducopter.service file is using the config file… try to open it using nano.
let me know if you find a solution on this.
I aslo double checked that my ddns info is correct and it is…

thank you


(Marcello) #16

Yeah I had looked at systemd earlier, I looked at the arducopter one now (as opposed to the ardupilot one) hence they do not talk about its configuration as an EnvironmentFile.

Unfortunately there are good ways to do things and bad ways, systemd is a pretty decent way to do things in many respects, it is clean. However, systemd is also being used to manage 4 different ardupilot programs if you will. Essentially eliminating interaction in the shell (where you would add custom command) between this so called management stage and running the actual program. As you can see this is a flaw as we cannot actually “manage” how we are launching ardupilot.

In my opinion systemd should be used to deal with the running of an entire script, not to manage how a script should work as a whole. So now we cannot add hostnames since we cannot actually manage our program with any sort of commands. This also makes the start scripts and update-alternative tools overly complicated in a sense as it cannot actually process/manage how to launch ardupilot, rather it becomes a list (that is way to long) of predetermined systemd settings.

Instead a command could be processed in a bash setting such using variables where a few lines of processing using variables, could save having lists in several different directories, etc. It can also be seen how this is a problem again, at the bottom of this thread here:

As the Telemetry variables cannot be properly/dynamically handled as again there is no management stage. Systemd in this way has been used as a shortcut and thus we are not allowed to properly handled variables in the shell (by using a bash script) because of this being the bottom line.

@drone_newbie
Unless someone finds a clever loop hole, throws together some patch work, or rewrites the entire starting structure this is currently impossible as far as I can tell, which seems to be the truth after double checking man pages and any available forum posts.


As for considering patching something together according to the systemd man page, you cannot simply create a environment variable (possible named $DDNSHOST) and export it from a processed bash script since systemd will only read environment variables from the “Environment variables in spawned processes” section on https://www.freedesktop.org/software/systemd/man/systemd.exec.html#
Or set from an EnvironmentFile which does not seem to support shell commands


(Marcello) #17

@drone_newbie

At this point I would reccomnend leaving the start system alone as it has too ma many flaws and just create a quick bash script as so

(I am not assuming you don’t know bash, I’m just ensuring anyone can use this solution)

sudo touch arducopter.sh
sudo chmod +x arducopter.sh
sudo nano arducopter.sh

content do add to file:

#!/bin/bash

hostname=$(dig +short myname.ddns.net)
TELEM1="-A $hostname:14550"
sudo /usr/bin/arducopter “$TELEM1”


#18

Thanks for the answer… Before i try this, i would like to ask…

  1. In which folder should i create the arducopter.sh file? In /home/pi?
  2. All of thosw following three lines should be added in the arducopter.sh file?
    hostname=$(dig +short myname.ddns.net)
    TELEM1="-A $hostname:14550"
    sudo /usr/bin/arducopter “$TELEM1”
  3. How should the arducopter.sh script be executed? Shouldnt it start automatically during boot? If yes, how can i achieve that?

Thank you


#19

i tried your suggestion and it worked .
but in the last command of the arducopter.sh script i had to remove the " symbols in order to make it work and look like
sudo /usr/bin/arducopter $TELEM1

in order to make it run automatically , can i just put the script inside the /etc/rc.local file? or is there a better way?

overall, is this whole suggested method a safe method in order to use ddns names? can someone from the emlid team tell us their opinion?

thank you


(Marcello) #20

Ive been a little busy, so my bad to answer your questions.

  1. The folder doesn’t really matter, since it is just a simple script I would put it in the home folder. Alternatively you could make a new folder in your home folder called “scripts” as so.

mkdir scripts

  1. Yes, all the 3 lines go into the script

  2. Yes, in this case I would put it in the /etc/rc.local file. This is the best way based on how it is currently set up as a basic script. I would recommend putting the following in your rc.local file:

/home/pi/scripts/arducopter.sh

make sure you add it before the exit line

I would say it is “safe” at least just about as safe as you can get in terms of actually getting the ip for the hostname.