I want to write a script-Ubuntu_OS- would connect to a wireless Internet so I need to know how to connect Internet via terminal in Linux. I tried many suggestions on the Internet but nothing at all
-
Please add in some of the things you've tried, not just "I've tried some things".– RobJan 9, 2012 at 16:47
-
you can check this thread here which solved for him but it failed for me :( ubuntuforums.org/showthread.php?t=1740726– wisdomJan 9, 2012 at 16:50
-
I'll assume from the link you're using ubuntu. What sort of protection is on the wireless network, WEP, WPA, whatever?– RobJan 9, 2012 at 16:54
-
that's it....I'm using Ubuntu OS, the wireless encryption is WPA– wisdomJan 9, 2012 at 17:10
2 Answers
By your question i assume you want a script to connect to a wi-fi network using a linux script and access internet.
Scan all networks available
iwlist wlan0 scan
Cell 14 - Address: 80:A1:D7:7A:5E:68 <<AP
Channel:6
Frequency:2.437 GHz (Channel 6)
Quality=26/70 Signal level=-84 dBm
Encryption key:on
ESSID:"ra"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=000000003621716c
Extra: Last beacon: 1260ms ago
IE: Unknown: 000472686561
IE: Unknown: 010482848B96
IE: Unknown: 030106
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: Unknown: 050400010000
IE: Unknown: 2A0104
IE: Unknown: 32080C1218243048606C
From the list select essid of wi-fi netwwork you want to connect
iwconfig wlan0 essid ID key KEY
if ESSID is "" use access-point
iwconfig wlan0 ap AP key KEY
script
#!/bin/bash
ifconfig wlan0
iwconfig wlan0 ap AP key KEY
dhclient wlan0
-
I've tried this method but it tells me at the end of operation following:[No DHCPOFFERS received. Trying recorded lease 192.168.1.100 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. --- 192.168.1.1 ping statistics --- 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms No working leases in persistent database - sleeping. ] what does that means ?? then how can I check if it connected or NOT ?!– wisdomJan 9, 2012 at 17:09
-
-
no dhcpoffers received , means either you havent configured dhcp properly on router or the wi-fi interface is not connected properly . Check the output of "iwconfig wlan0" to see if its connected properly. Also you might need to configure ip manually if dhcp is not configured. ifconfig wlan0 192.168.0.1/24– dayaJan 9, 2012 at 17:17
-
Oops...I can't do that even with manually ip :( , anyone can explain step-by-step how will the script can work ?? or even can write the code then upload it ? .does it work with anyone ??– wisdomJan 9, 2012 at 20:42
-
please anyone can help :'( , after trying this code above the wireless became auto-disconnect every 7-10 minutes :( ,so I changed the password of it to skip the problem.– wisdomJan 12, 2012 at 10:55
You could try using WICD network manager, it has a CLI network manager you can install.
You could also try using the Ceni script from smxi, which has worked great for me in a few cases where WICD and Gnome-network-manager were not working.
These won't really be a script to start a network connection, but both are accessible from command line and both will let you scan for networks, connect, put in keys, etc. in a nice manner.