Posts Tagged ‘hsdpa’

Hi all,

today may be sound old and boring configure a directly using a command line a dialup connection. This is may be true in many cases an a little bit unuseful.. but I love command line 🙂 so I’m going to show how configure pppd to make a dial up throu a UMTS phone or a HSDPA pen.

In my case, I use a HSDPA phone with bluetooh link, but it is the same with any kind of serial port. This is a short list of used devices:

  • bluetooth: /dev/rfcommX
  • phone with data cable: /dev/ttyUSBX
  • HSDPA phone: /dev/ttyUSBX

Some times, HSDPA pen are recognized like a cdrom but do not fear about it, there are utilities to change the pen interface. If you have no idea, look in dmesg when you plug the phone/pen.

What we need: ppp daemon usually called…. (suspance)…….(a little more suspance)…. ppp :).

What we are going to do: write two files, a chat script and a ppp configuration.

This is my chat script

1. ABORT BUSY
2. ABORT ‘NO CARRIER’
3. ABORT ERROR
4. REPORT CONNECT
5. “” \rAT
6. OK ‘AT+CGDCONT=1,”IP”,”tre.it”‘
7. OK ATD*99***1#
8. CONNECT “”

Lines 1, 2, 3, 4 test the physical connection, necessary but not so interesting.

Line 5 checks for AT command

Line 6 is the trick: +CGDCONT=1 is the magical command who enable the UMTS protocol or HSDPA, without this you may get only a GPRS connection. Others parameter are necessary and says respectly the kind of connection (by ip) and the APN of your phone provider. If you do not know it, easy looking for that on your phone.

Line 7 is the call command. Call *99***1# or call *99# is the same, today I do not find any difference. If someone knows that…

Line 8 is the answer we expect.

Usually (I think on Debian and Ubuntu) this file may be placed in /etc/chatscripts, where we can find others like that.

The second file is placed in peers folder of ppp. In Debian that folder is /etc/ppp/peers. We could call hsdpa-provider.

1. /dev/rfcomm0
2. 115200
3. crtscts
4. local
5. noipdefault
6. defaultroute
7. usepeerdns
8. noauth
9. passive
10. connect “/usr/sbin/chat -v -f /etc/chatscripts/tre”
11. user pippo
12. ipcp-accept-remote
13. ipcp-accept-local

Explain it line by line is not so useful, for details look at man pppd. What we want to know is about lines 1, 10 and 11. Line 1 is the device, look the introduction if you do not find it. Line 10 says “use my chat script”, the one we have written. Line 11 is the user for dialup authentication: I think no provider asks about it so I put an uninteresting name.

We have finished.

To test it the simple way is plug your device or power on bluetooth and then call

pon hsdpa-provider

Using ifconfig we could see a new pppX interface.

To shutdown the connection, you can use poff command, or kill directly the ppp daemon.

That’s all folks!

Cheers.

Advertisements

Hi all,
remember the previous post about an easy way to transform a netbook in a router for hsdpa connections? Well, I decided to make a new version of the script that i proposed in that post.
The new version is a little bit wide. I mean, on netbook I have four network interfaces: ethernet, wireless, pan and dun. Sometimes I use bridge, tap, etc. In this situation that script needs to edited every time, changing internal and external interface… very boring, i know.

So this is the rule: the script is callable with a list of interfaces, the first is the gateway and others are the sources. Simple, don’t you?

#!/bin/sh
echo -e "\n Configuring NAT:"
IPTABLES=/sbin/iptables
DEPMOD=/sbin/depmod
MODPROBE=/sbin/modprobe
if [ ! -n "$2" ]; then
  res=65 #bad arguments
  msg="Usage: `basename $0` extif intif[s]"
else
  msg="done.\n"
  res=0
  echo -en " - loading modules: "
  echo -en "ip_tables, "
  $MODPROBE ip_tables
  echo -en "ip_conntrack, "
  $MODPROBE ip_conntrack
  echo -en "ip_conntrack_ftp, "
  $MODPROBE ip_conntrack_ftp
  echo -en "ip_conntrack_irc, "
  $MODPROBE ip_conntrack_irc
  echo -en "iptable_nat, "
  $MODPROBE iptable_nat
  echo -en "ip_nat_ftp, "
  $MODPROBE ip_nat_ftp
  echo ""
  echo " - Enabling forwarding "
  echo "1" > /proc/sys/net/ipv4/ip_forward
  echo " - Enabling DynamicAddr"
  echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  echo " - Clearing any existing rules and setting default policy"
  $IPTABLES -P INPUT ACCEPT
  $IPTABLES -F INPUT
  $IPTABLES -P OUTPUT ACCEPT
  $IPTABLES -F OUTPUT
  $IPTABLES -P FORWARD DROP
  $IPTABLES -F FORWARD
  $IPTABLES -t nat -F
  EXTIF=$1
  echo -n " - Forwarding: "
  for int in "$@"; do
    if [ "$int" != "$EXTIF" ]; then
      echo -n "$int, "
      $IPTABLES -A FORWARD -i $EXTIF -o $int -m state --state ESTABLISHED,RELATED -j ACCEPT
      $IPTABLES -A FORWARD -i $int -o $EXTIF -j ACCEPT
    fi
  done
  $IPTABLES -A FORWARD -j LOG
  echo ""
  echo " - Masquerade: $EXTIF"
  $IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
fi
if [ -n "$msg" ]; then
  echo -e "$msg"
fi
exit $res

Actually, I use this script to manage virtualbox lan connections, but this is another story.
Cheers to all.