Friday, February 01, 2008

Ubuntu 7.10 + gprs Nokia E61 + internet sharing with WiFi

We can have peer to peer (ad-hoc) WiFi for sharing internet connection with another PC/Laptop.
In my notebook HP 520 Intel Core Duo, I create couple files for this purpose :
Also I use wvdial to dial Nokia E61 modem.

1. Bash script file, you can name it as 'internet_sharing.sh'.

#!/bin/sh
#########internet_sharing.sh#############

# released old rfcomm0 connection
sudo rfcomm release 0
sleep 3
# bind my E61 via bluetooth, provided you already paired it
sudo rfcomm bind 0 00:12:D2:6B:1F:4F 2
sleep 5
wvdial -C btcentrin.wvdialconf &

## eth1 is my WiFi
sudo iwconfig eth1 mode Ad-hoc channel 1 ESSID migenet

## sharing the WiFi
sudo modprobe iptable_nat

## You may need one of these lines to set the ip_forward
# sudo echo 1 > /proc/sys/net/ipv4/ip_forward
# sudo systcl -W net.ipv4.ip_forward=1

sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

sudo iptables -A FORWARD -i eth1 -j ACCEPT

#########internet_sharing.sh#############


2. btcentrin.wvdialconf file . Centrin is my gprs provider .

[Dialer Defaults]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","centrin.net.id"
Modem Type = Analog Modem
Phone = *99#
ISDN = 0
Username = johndoe
Init1 = ATZ
Password = thesecret
Modem = /dev/rfcomm0
Baud = 115200


Then you just run the internet_sharing.sh file.
And your partner PC/Laptop just need to set the appropriate WiFi ESSID and key.
Post a Comment