I normally connect to internet through my mobile phone's SIM card. Its a GSM network.
To connect to internet in GUI manner I go to notification bar, click on network icon, and click on connections name. After connecting the network icon changes to indicate that I have connected to internet.
Can I do it in command line way?
The GUI is a front end to Network Manager, which is a daemon. You can ask the daemon to make a connection using the command line as well. This way, your configuration is shared between the GUI and command line methods.
The tool you can use for this is
nmcli
, which is installed with network-manager so should be present on your system already. To connect to a network called network-name in your GUI, typenmcli con up id network-name
on the command line. Similarly,nmcli con down id network-name
will disconnect. If the GUI (nm-applet
) is running, then you will see its displayed status change accordingly.See the nmcli manpage for further details. Manpages on newer releases include examples as well, although I can't find an online link to this.
All what need is right here
sudo nano /etc/chatscripts/ispname
Inside this file You will place following code:
You should replace “ispapn” with your ISP access point name (APN.)
if Your ISP is using PAP authentication so You must add user name and password provided by my ISP at the end of your /etc/ppp/pap-secrets file.
If your Internet service provider is using CHAP authentication do the same but use
/etc/ppp/chap-secrets
file.Also we must decide on remote name identification string that will be used in the next steps to instruct pppd to use right pap or chap credentials.
I will use string “ispname” here. So here’s what I have placed at the end of my
/etc/ppp/pap-secrets
file (place your user name, password and string of your choice here instead of my “ispusername”, “isppassword” and “ispname”):If your ISP isn’t using authentication and you don’t need to provide name and password to connect to Internet you can skip this step altogether.
As a next step we must create so called peers file that will be used by pppd to dial chat script created in the first step using credentials stored in the second step. I will call my peers file “ispname” and place it into /etc/ppp/peers directory:
sudo nano /etc/ppp/peers/ispname
Inside my peers file I will place following code:
This is basic configuration to get you online. To dial your connection you would use sudo pon ispname and to disconnect you would use sudo poff ispname where “ispname” is you peers file name. To be able to dial without sudo you need to add your self to “dialout” group:
Further you might want to create interface for your pppd connection so you could control your GSM mobile broadband connection using “ifup” and “ifdown” commands and/or dial automatically when your PC boot. You would achieve this by adding something like this to your
/etc/network/interfaces
file:Here is a link to an article about how to connect to the internet from the command line. I will not attempt to reproduce it here since it is clearly explained in the article.
http://www.ghacks.net/2009/04/14/connect-to-a-wireless-network-via-command-line/
I would assume that this will work with a phone like you are using, but I'm not sure if using a phone is different than typical wifi. Here is a thread in another forum that might help:
https://superuser.com/questions/34166/connecting-to-internet-via-phone-on-linux
I hope this helps. Good luck.
You can also use
wvdial
Install it using
sudo apt-get install wvdial
Then, runsudo wvdialconf
And edit the config file
sudo gedit /etc/wvdial.conf
You will get something like
Enter the Username and Password if required (leave blank if it's not required) . Also provide the Phone number to dial. For eg:
*91#
,#777
...etc If the phone is connected using USB, theModem
value will most probably be/tty/USB0
or something similar.Finally, use the
wvdial
command to initiate connection.