Automating/scripting Wifi connections - wifi

I am using Ubuntu 14.04 with an external wifi key.
My goal is to successfully connect to a wifi spot without going through the GUI using a script
I have tried the following commands:
-nmcli nm wifi on
-nmcli -p dev wifi
-nmcli con up id "essid"
The second command gives me a good list of available wifi issues, however when I try to connect with the third command an error prevents the connection:
-Error: Unknown login: my "essid".
I've tried many other commands located in the wireless part of the forum, but without success.
If I use the GUI and just click once on a wifi spot to connect it without the above commands It Works.
Thank you for your interest in my concern.
Sorry for my very bad english.

"nmcli con up" only connects to existing connections and uses the saved named of the connetion as ID, not the SSID of the network.
To connect to a "new" wireless network use:
nmcli wifi connect <(B)SSID> [password ] [wep-key-type key|phrase]

If you can live without NM, then what I used to do in order to programatically connect to wifi networks was to use iwconfig and dhclient.
In order to associate to the wireless AP:
iwconfig YOUR_INTERFACE essid YOUR_ESSID channel YOUR_WIFI_CHANNEL key YOUR_PSK
In order to get an IP address via DHCP:
dhclient YOUR_INTERFACE
Note that if NM is still running, this will not work.

Related

Pi3 not detecting wifi or ethernet. How to connect Internet to Pi3

When I place the cursor to network connection at the panel which is two red cross marks on a parallel line it says..
eth0: Link is down
wlan0: Not associated
When I tried to connect a Ethernet cable directly it detected the IP and said configured..But I am unable to browse giving error..the site cant be reached.
I tried connecting through wifi by adding lines of user and password in wpa-supplicant file.
Is there any problem with the software or hardware?
Please help me to solve the issue.
After connecting your Ethernet cable from modem to pi,..In the wired and wireless settings in pi3,select interface -> eth0 and select (tick)automatically configure empty options.
Do not enter any information in the below boxes like ip adress,router,dns server,dns search.

How to make a Wi-Fi hotspot from a Windows XP PC and with NO Wi-Fi Adapter

This computer is the only device that has wifi and my family needs it immediately to contact other people. I tried downloading OSToto Hotspot but it says i needed a wireless adapter which i dont have. And i also tried allowing other devices in my control panel to share the wifi but there was an ERROR 799 and i dont understand it. Trying to set the IP address wouldn't work. It disconnect the wifi instead. Please help
Your question title says "with no Wi-Fi Adapter" and the body says that the device is the only one with wifi.
If you do have a wifi adapter on your PC first thing I would check is
netsh wlan show drivers
from command line and look for something like
Hosted network supported : Yes
Here is some nice tutorial just in case.

Accessing remotely my web service

I have implemented a web service on my mac and I am able to access its functionalities through the url "http://localhost:8080/ServiceApp-war/resources/".
As I got satisfying results that I could see in the iPhone simulator in Xcode, I decided to connect my iPhone and test on it. But for this to work I think I need to change the "localhost" in my URL to the IP address of my mac.
I tried to replace it with my public IP address and I got a "could not connect to the server" error on my console. I also tried to replace "localhost" with the IP address I found in System Preferences-->Network-->Wi-Fi and I could see that it was working on the simulator but still nothing when I connect my iPhone and run the application on it.
Please provide a solution for accessing my web service remotely.
Thank you.
Create hotspot from your mac, connect to it with your iPhone and try again.
<lame solution>
Try some service for temporary domain, it will make your computer accessible from anywhere.
How do you "connect" your iPhone? USB connection does not create a network. Well, it does create if you turn on Personal Hotspot on your iPhone (maybe in some other cases, dunno). But the most simple way is to connect Mac and iPhone to the same WiFi network.
Once connected, you can use any of "ping" apps available on App Store. Just look for "ping" (some kind of "network reachability test" or so). You can check if your Mac is really reachable on the network.
If it's not reachable, check your network settings on both devices: do they belong to the same subnet, do they use the same gateway, etc.
If your Mac is reachable with ping, then you should deal with your web service. I setup the web server (which is already distributed within OS X): it already has all the settings to allow other devices to connect. But your web service may require some additional setup. It's two basic things: it should bind to your IP address (please check http://YOUR.IP:8080/ServiceApp-war/resources/ from your Mac!) and second, accept incoming connections from other agents, you should find it somewhere in its settings.
Ngrok was the perfect solution I was looking for.
https://ngrok.com
You could also try finch, which is similar to ngrok. It has a nice friendly GUI. https://meetfinch.com

ESP8266 Arduino Hostname (MDNS)

I am having problems with the hostname of my ESP8266. I am using the MDNSResponder and I can successfully access my device with mydevice.local
However, my WiFi router (Netgear WGR614) list the device as ESP_FEA38A. When I use 'Angry IP Scanner' on my mac, there is no hostname listed. Both, the ip scanner and the WiFi router both recognize several raspberrys and other devices like airport express.
Does anybody know what other host naming mechanisms are being used and how I can get my ESP8266 device getting listed with hostname?
If you are using the Arduino environment in the WiFi library there is a method for setting the hostname:
WiFi.hostname(newHostName);
Once I set this to the desired name the ESP8266 showed correctly in DHCP, on the router and, when available, was pingable. From my experimenting this needs to be done before any of the other WiFi actions for it to work effectively.
You can also include the Espressif SDK functionality although looking at the Arduino ESP8266 GitHub project it appears to already be included.
The Espressif SDK sets the hostname with the following command:
wifi_station_set_hostname(myHostname);

Is it possible to ping offline devices?

This may be a strange question but I really want to learn how "ping" command works. Today when I had my smartphone open and online, I pinged its external(public) IP from my terminal in Linux with "ping [ip address]" command and it worked of course.
When I turned off my smartphone and retried to ping its IP, it worked again! As far as I know ping is like sending a message and then getting a reply from the target.How is this possible since my phone is offline?
Any explanation is much appreciated! Thanks!
UPDATE:
Both my phone and PC use Wifi to connect to the internet and are in the same network.
Also there was not any other device that joined the network when I tried the above.
If you subscribe the service from an ISP, then you might share the use of one public IP address among your devices to connect to the Internet. Internally you'll use private IP addresses for your PC and phone. It seems to me that what you have pinged was the public IP address assigned on the gateway of your wifi router and not your phone.
If you are not sure, then try to access http://whatismyipaddress.com/ from both your devices and see if you have the same IP address or not.

Resources