Archives page

Posts Tagged ‘networking’

Mobile Internet on the Eee PC (Ubuntu Eee)

Setting up the Internet on the Eee PC over bluetooth to my Nokia N95 with T-Mobile GPRS/EDGE/3G connection can be tricky.  Yet it sounds like one of those setups that could be so easy, right?  Well it seems stable for the moment, so here’s what you’ll need.  Or rather, what I have…

You’re going to be setting up your connection though pppd, and all of these instructions are based on instructions that I’m going to steal, slightly change and probably skip parts to suit my purposes (and hopefully yours) perfectly.

If your set-up doesn’t match exactly, perhaps you can make use of both pages and work out where things should change.  Or lovingly rip these instructions off, as I did – to make your own.

Setup your bluetooth dongle
First off, you’re going to need an apt repository that has the bluez-utils packages in. So open up a terminal
sudo nano /etc/apt/sources.list
and add the line
deb http://ftp.de.debian.org/debian etch main

Then you can install the package.

apt-update
apt-get install bluez-utils
/etc/init.d/bluetooth restart
lsusb | grep -i bluetooth
(should show the bluetooth device)
hcitool dev
(also lists bluetooth devices)

Setup networking

You can grab my gprs-settings which should be put into /etc/ppp/peers directory, and untarred.
tar -xvf gprs-settings.tar

Pair the phone

First, get the bluetooth ID of the N95
hcitool scan
Then pair your Eee with your phone, you have to do this from the N95.
Bluetooth -> right arrow (Paired devices) - Options
New paired devices (search)
Choose your eee and then type the pairing keys (anything of your choosing

Bind bluetooth to an rfcomm device

We use “rfcomm” to bind the bluetooth connection to a device. So first, find out the channel the phones bluetooth dial up networking system is on. You can do this with sdptool (Service Discovery Protocol tool):
sdptool search dun
Service Name: Dial-Up Networking
Service RecHandle: 0x1001e
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Language Base Attr List:
code_ISO639: 0x454e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

Note the “Channel: 2” which show which channel to bind.

Then to bind the channel (in this case #2) to one of the rfcomm devices (for example, rfcomm0):
rfcomm bind 0 11:22:BE:EF:44:33 2
You can see the binding with:
rfcomm
rfcomm0: 11:22:BE:EF:44:33 channel 2 clean

You might find you need to reset the bind and restart it every now and then (especially failed connection attempts)
rfcomm release 0
rfcomm bind 0 11:22:BE:EF:44:33 2

You can edit the settings in “/etc/bluetooth/rfcomm.conf,” set bind to “yes” and give the device and channel for rfcomm0. Then you can put these commands into /etc/init.d/bluetooth and it will automatically bind and release the rfcomm device:
# At the end of the "start)" section
rfcomm bind all
# At the beginning of the "stop)" section
rfcomm release all

Start pppd to connect.
Start up pppd.  Command line first, but because we’ve called it ppp0, you will later be able to do this via the normal ubuntu eee networking menu in the menu bar.
% pppd call ppp0
You should now have a ppp0 interface in your ‘ifconfig’ output that is up and running. The output should look something like this:
# pppd call ppp0
Press CTRL-C to close the connection at any stage!
defining PDP context...
rAT
OK
ATH
OK
ATE1
OK
AT+CGDCONT=1,"IP","general.t-mobile.uk","",0,0
OK
waiting for connect...
ATD*99#
CONNECT
Connected.
If the following ppp negotiations fail,
try restarting the phone.
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm0

You can hit control-c on the pppd process and it will shut down the connection, then you can release the rfcomm binding.

So… as I was saying… It’s not the easiest thing in the world to get going, but once you’ve got the hang of it, and set it up once you’ll have a connection everywhere you go.

Linux server as a wireless bridge

Since learning the XBox 360 doesn’t come with a wifi adapter, and that buying such a thing would add another 60 pounds to the cost of the console… I’ve been thinking of different ways to get an Internet connection from my high-speed wired network in the living room out to the router way out in the spare room. For many reasons, it’s just not practical for me to wire the whole flat.

Most of the solutions I came up with involved things like ‘spending money’, which I’m slightly adverse to do if I can do it with the existing kit, so these are the really basic steps to turn the existing linux box (with both wireless and wired cards) into a useful bridge. As usual, don’t be fooled into thinking this guide is here for anyone else, as much as it’s here for me when I need to rebuild the machine and I’ve forgotten it all. But feel free to leave a comment about how much warmer and fuzzier I’ve made your life through your use of these “instructions”.

The current configuration

Fedora 8 installation
Wireless Ethernet (ath0) card is connected as 192.168.0.8
Wired Ethernet (eth1) card is connected as 192.168.1.8
Named/bind/DNS server already configured and set-up to accept requests on 192.168.1.8
The Xbox will be wired, on 192.168.1.20

Setting up Fedora

Setup the forwarding rules

#Outgoing requests
iptables -t nat -A POSTROUTING -s 192.168.1.8/24 -o ath0 -j MASQUERADE
iptables -A FORWARD -s 192.168.1.0/24 -o ath0 -j ACCEPT
iptables -A FORWARD -d 192.168.1.0/24 -m state --state ESTABLISHED,RELATED -i eth1 -j ACCEPT
#Incoming requests (port forwarding)
iptables -t nat -A PREROUTING -p tcp -i ath0 -d 192.168.0.8 --dport 88 -j DNAT --to 192.168.1.20:88
iptables -t nat -A PREROUTING -p tcp -i ath0 -d 192.168.0.8 --dport 3074 -j DNAT --to 192.168.1.20:3074

Save your rules so they’re applied on start-up
sudo iptables-save > /etc/sysconfig/iptables

Enable ipv4 port forwarding
nano /etc/sysctl.conf
Change this line
net.ipv4.ip_forward = 0
to
net.ipv4.ip_forward = 1

The client machine / Xbox 360

Now on your client machine (note this will only have a wired connection).
IP Address: 192.168.1.20
Subnet mask: 255.255.255.0
Default Gateway: 192.168.1.8
DNS Server: 192.168.1.8

You’re going to need a DHCP server so that these settings are automatically assigned to the XBox 360. If don’t have one for your subnet already, you can set it up through dhcpd. You’ll probably want to do something about

Edit /etc/dhcpd.conf

ddns-update-style interim;
# HardWired
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.8;
option domain-name-servers 192.168.1.8;
authoritative;
range 192.168.1.10 192.168.1.20;
}
# Assign a static IP
host xbox {
hardware ethernet 00:45:40:10:FE:12;
fixed-address 192.168.1.20;
}

Then restart dhcpd
/etc/rc.d/init.d/dhcpd restart

Router

Remember those ports we forwarded on the server? You’ll also need to add port forwarding to your router, to forward the same ports (88, 3074) to the Fedora machine on 192.168.0.8.

And that’s really it. You should now be able to connect to the Internet without any troubles.