Archive for September, 2010

[how to set up your phone as a modem in Linux]

################################################################  ######==================———————=====================#######

Howdy all!

In this blog post I will summarise what I presented at our JLUG meeting(how to get a reliable internet connection in your room using a mobile phone as a modem in Backtrack Linux).

Requirements:

~~~~~~~~~~~

[1]A YU line(you may use other but be ready to pay)

[2]A mobile phone(with cable) or any 3G modem e.g Hauwei or any other

[3]A linux machine(either installed or a live CD)

Steps:

   

~~~~~~~

[1]Setup:
To set up your modem(phone) plug it in and open a linux terminal,From the Linux terminal type:

code:

root@bt:~# wvdialconf

why? wvdialconf is part of the wvdial scripts that will help you setup your modem it will
(a)Detect your modem(first it will search the serial ports for available modems)

(b)After detection it will create a configuration file for you at /etc/wvdial.conf NB:after the command has terminated you should see a message at the end that the configuration file has been created.

[2]Edit conf file:
To edit the configuration file fire up your favorate text editor (mine is nano) and load the configuration file(/etc/wvdial.conf)

code:

root@bt:~#nano /etc/wvdial.conf

you should see some of these details(your modem type,port,baund rate etc) Uncomment the commented entries in this case Password,Username and Phone and make sure they have these values

Phone=*99#

Password=yu

Username=yu

When you are done just ctrl x (Control x ) why? this will save your changes and exit from the nano text editor.

[3]Connecting:
Now to the juicy part to connect just type:

code:

root@bt:~#wvdial

why? wvdial is simply the dialer script that will dial your Carrier(ISP) in this case YU so that you can be assigned an IP after this command you should get an IP,(your IP,gateway,a DNS server or two should be displayed) and a new interface will be created (usually ppp0) for you.

NB: don’t close this terminal untill you are done with the connection!!!

[4]Test the connection:
To test the connection simply ping whatever you want to:

code:

root@chimera:~# ping google.com
PING google.com (72.14.234.104) 56(84) bytes of data.
64 bytes from mil01s07-in-f104.1e100.net (72.14.234.104): icmp_seq=1 ttl=52 time=496 ms
64 bytes from mil01s07-in-f104.1e100.net (72.14.234.104): icmp_seq=2 ttl=52 time=1016 ms
64 bytes from mil01s07-in-f104.1e100.net (72.14.234.104): icmp_seq=3 ttl=52 time=416 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2716ms
rtt min/avg/max/mdev = 416.679/643.066/1016.346/265.937 ms, pipe 2
root@chimera:~#

Success!!!

If you are alone thats all And for our Ubuntu brothers? no need to do all this !just plug and play stuff next, next, ok .

Sharing the connection

~~~~~~~~~~~~~~~~~~~~~~~

A times you may want to share this connection with your room mate or any body in the LAN but how?

Concept:

~~~~~~~~

The trick here is to simply tell your friend to use your IP as his/her gateway then you set up your linux machine as a gateway then you forward all the traffic.

NB:your friend’s OS does not matter and the connection speed will not be affected much. [Step I] First lets clear the iptables rules(not a must)

code:

root@chimera:~# iptables --flush
root@chimera:~# iptables --table nat --flush
root@chimera:~# iptables --delete-chain
root@chimera:~# iptables --table nat --delete-chain
root@chimera:~#

[Step II]

Set iptables to forward traffic through our new interface(ppp0)

code:

root@chimera:~# iptables --table nat --append POSTROUTING --out-interface ppp0 
-j MASQUERADE
root@chimera:~# iptables --append FORWARD --in-interface eth0 -j ACCEPT
root@chimera:~#

(where eth0 is our ethernet interface which should be in the LAN)

NB:where –table option is not specified we refer to the default table (filter) check the man pages (man iptables) for more info So far our machine is connected to the internet a fully configured as a gateway to the Internet for other machines in the LAN but we have not enabled IP forwarding in the kernel.

[Step III]

Enabling IP forwarding in our machine .So we need to edit the file /proc/sys/net/ipv4/ip_forward and change the value from 0 to 1 one can choose to use an editor or simply redirect 1 to that file . how?

code:

root@chimera:~# echo 1 > /proc/sys/net/ipv4/ip_forward
root@chimera:~#

this will change the value from 0 to 1

[step IV]

All done we tell our friend to set his/her gateway to our IP address

NB:to get our IP address simply type ifconfig the IP set for our eth0 should be our friends gateway IP. NOTE:We can make sure we are on the same network with our friend by typing:

code:
root@bt:~# ifconfig eth0 <our_IP> netmask<netmask> broadcast<broadcast> e.g

root@bt:~# ifconfig eth0 192.168.20.20 netmask 255.255.255.0 broadcast 192.168.20.255

And our freind has Internet connection as well!!!!!!

IMPORTANT

===========

This is not entirely free as you may think but its “free” in that the cost is fair for such connection speeds. To pick a tarrif dial *154# from your YU line and choose a package that fits your pocket or needs(option number 4 for individuals and number 3 for two or more people should be ok).

An automation shell script(to automaticaly do every thing for you) will be available for download soon keep watch:)

#######################################END######################################### ================Brought to you courtesy of ch!m3ra and JLUG======================== ###################################################################################