Soup to nuts advice for newbies - get your Yun running on a remote router.
Topic: Soup to nuts advice for newbies - get your Yun running on a remote router.
(Read 2131 times)
Soup to nuts advice for newbies - get your Yun running on a remote router.
May 02, 2020, 07:15 pm
: May 03, 2020, 09:27 pm by mcdmdphd
I am putting this post on the forum because it might help a newbie to go from ground zero to having a Yun device running on a remote wireless router. I posted something similar elsewhere, but it was hard to understand.
On initial setup, using a Windows machine:
Plug your Yun into power.
Connect your computer with the arduino factory wireless network, log in using your browser to 192.168.240.1 with "arduino" as the password, go to "configure", set up your device's new name, choose your local wifi networkwith its passord, set a new Yun password also, click "configure and restart", change your Windows network to the one you entered, wait.
For the webpage to connect again, go to advanced configuration, go to >network>interfaces>lan>edit and set up a static address, IPv4 netmask = 255.255.255.0, IPv4 gateway=192.168.1.254 or whatever your router dns server address is. Save and apply. Wait a while. If you choose a static address (like 192.168.1.150 for example), make sure nothing else is already hogging that port on your wireless router.
An IPAD app called "fing" can be used to show you which addresses are currently being used.
Download Putty into your Windows computer and use it to connect to the new machine with the static address that you chose. Set username = root and use the password you set up in the Luci shell.
Your Yun may come with the nano text editor - if so use that instead if you value your sanity.
Otherwise, use the despicable && awful vi text editor to change the nameserver file if you don't have nano. I can't find a good explanation of how Vi works because nobody likes it enough to honor it with a tutorial , but read this page.
Remember that hitting the esc key toggles you into and out of command mode.
The contents of /etc/resolv.conf need to be (if your router's nameserver is 192.168.1.254)
Once you do THAT you can use putty to do :
>opkg install openssh-sftp-server
NOW you can use the free Windows program WinSCP instead of vi or nano to edit files.
The contents of /etc/rc.local need to be changed to (in order to sync the yun with internet time when it starts):
You don't need to include the ntpd -q line if you don't need the yun to have the right time and date.
Likewise for this next thing, if you don't need time to be sync'd:
If there is no /etc/crontabs/root file, make an empty file called root in the crontabs directory with the WinSCP program
The contents of /etc/crontabs/root/ needs to be (in order to sync time every night at 1 AM):
0 1 * * * ntpd -q
Lastly - to make the DNS configuration persistent (don't you LOVE patching problems that have been there for 5 years or more?)
Change the part in /etc/init.d/dnsmasq from DNS_SERVERS="" to DNS_SERVERS="192.168.1.254 184.108.40.206 220.127.116.11" (if your router's nameserver is 192.168.1.254)
There is another place that says something like DNS_SERVERS="127.0.0.1"
or something like that. Replace with 192.168.1.254 18.104.22.168 22.214.171.124 instead of the 127.0.0.1
- note the spaces between 4 and 8 and 8 and 8
Reboot. Hopefully at this point the Yun itself is ready. Now you have to get the remote router
ready for it.
WHAT THE YUN IS ALL ABOUT - ACCESS TO THE YUN THROUGH THE INTERNET:
Call your internet provider tech support and have them give you a static port for your account. The first couple of DDEs (deliberately dumb employees) won't know what that is and you will
need to insist on moving up the supervisor chain until you find somebody who actually can do it. This may take hours or days. They should do it for free, it costs them nothing to do..
With port forwarding, you will be able to access your yun through your router using SFTP from the outside ONCE you know the outside internet address of your home router. Be aware though - opening ports through your router exposes you to some hacker risks.
There are websites and services that will track your router's web address for you. Don't waste your time and money with that. Just have a static port set up.
You have to set up permission for forwarding ports 22 and 23 on your remote router. Can't help you there, buddy. It's your hell machine, not mine, and they are all different
I assume 2 days have passed and you are back with us with barely suppressed rage, bags under your eyes and a slight caffeine tremor that won't go away for days.
Go into the arduino Luci shell using your browser (hopefully you know how to do this by now - just use a browser and on your non-remote router type in your LOCAL static address - not the new static WEM address for the remote router), go to the network tab, to the firewall tab and "accept" both input and output on the LAN. Hit save and apply.
Now you will need two Windows programs. "PUTTY" and "Filezilla", mentioned above. Download them if you don't have them already. They are free.
Use Filezilla and access your Yun from inside your network first, using its internal static address - fill in the username and your password for the Yun, save it with a name so you don't have to type it in every time and connect. Explore the Linux file system with your windows computer to get used to how the program works. Watch out, if you signed in as root you can do damage by deleting files. Now use an external computer (or use your iPhone hotspot instead of your home wifi) and use the external router static IP address to see if you can access the Yun with Filezilla from the outside. Troubleshoot as needed.
If the Yun is listening for port 22/23 and if the router is forwarding port 22/23, it will work. So now you can write and read Yun files from the outside using drag and drop into the Filezilla program. Make a new directory called "Sit and Stay".
Put a picture of your dog into the directory. Click on it. Good boy.
You need PUTTY to get in to the Linux shell. Type in the IP address (either the internal router static address
if you are on your home router, or the external static IP address of your router if you are on the outside)
and port 22. A shell will pop up, you will enter your username (root) and password and you are the in a user
shell for the Linux system. Useful info for the future - "reboot" reboots the whole thing, "reset-mcu" resets the program without resetting
the linux side. You are almost there.
So how do you put in a new arduino program from outside the local network since the Arduino web feature
for doing this simply does not work? It is cludgey, but after doing it for a while it only takes a minute.
On your Windows Arduino IDEprogram got to preferences and change the IDE to go to "verbose output"
Compile and save the sketch on the IDE
The last line or 2 of the output (the stuff you usually ignore at the bottom) will tell you where the IDE is stashing
the hex file
Find it using file explorer - In my case it's in the NEWEST hex file folder at C:\Users\micha\AppData\Local\Temp\.
IGNORE OLDER COMPILATIONS!
Sort them in order of last modified - my most recent one was in a folder called "arduino_build_974710" for example.
It has the date and time in file explorer to help you identify it.
arduino_build_974710\scratchpad.ino.with_bootloader.hex was the one I just used, for example
You want to use the hex file that has had the bootloader added to it. Recognize it by the title.
Using file explorer, copy this hex file to another arbitrary folder on your desktop
Use filezilla to copy the hex file to the /etc folder on the remote Yun (but it could go anywhere on the Yun as long as
you know where it is)
Go into putty, open the shell on the remote machine and then from any directory that you are in, enter
" run-avrdude /etc/whateveryourhexfileiscalled.withbootloader.hex "
( run-avrdude /etc/scratchpad.ino.with_bootloader.hex) in my case was the last hex file I compiled.
HOLY CRAP - it actually works.
Of course, your mileage may vary. I am so tired of reading wrong advice on these forums, but like I said, this
works for me. Good luck.