|
|
2011-06-29
, 07:52
|
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#182
|
I've also got an asus transformer, I've managed to get it to tether to the n900 using your PAN script...
only issue I had was that when tethered it still behaved like there was no internet connection...
then I found that iptables had been uninstalled when I uninstalled v47 of the power kernel in order to install v46...
now, all is well
thanks for the script!
|
|
2011-07-04
, 09:41
|
|
Posts: 2 |
Thanked: 1 time |
Joined on Jul 2011
|
#183
|
#echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward
|
|
2011-07-04
, 09:49
|
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#184
|
|
|
2011-07-04
, 13:10
|
|
Posts: 2 |
Thanked: 1 time |
Joined on Jul 2011
|
#185
|
| The Following User Says Thank You to gtab_n900 For This Useful Post: | ||
|
|
2011-07-04
, 14:16
|
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#186
|
|
|
2011-07-05
, 08:49
|
|
Posts: 174 |
Thanked: 99 times |
Joined on Jan 2010
|
#187
|
|
|
2011-07-05
, 11:22
|
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#188
|
|
|
2011-07-06
, 09:11
|
|
Posts: 16 |
Thanked: 38 times |
Joined on Dec 2009
|
#189
|
Although setting sudoers is better, but it seems to confuse a lot of people. I've made change to the procedure section 4.3.3 to run the script directly with root privilege:
Code:echo "/home/user/bluetooth-pan.sh" | sudo gainroot
if [ $(whoami) != "root" ]; then echo "$0" | sudo gainroot exit fi
| The Following User Says Thank You to rdnetto For This Useful Post: | ||
|
|
2011-07-09
, 05:33
|
|
Posts: 166 |
Thanked: 74 times |
Joined on May 2010
|
#190
|
Hi, the Tab only got an IP address via the N900 when that ip_forward line was uncommented. Prior to that, pairing and 'connection' was completed but without an IP being provide.
I used jschan's tethering script here:
http://talk.maemo.org/showpost.php?p...&postcount=124
You can see here:
# Enable IP forwarding
#echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding
echo 1 > /proc/sys/net/ipv4/conf/$EXTERNAL_INTERFACE/forwarding
That it was commented out...
#!/bin/sh
#
# /opt/tether/tether.sh
#
# Written by jschan @ http://talk.maemo.org
#
# Code snippets and inspiration from:
# - http://wiki.maemo.org/DbusScripts
# - http://talk.maemo.org/showthread.php?t=58570
# - http://code.google.com/p/n900ipv6/source/browse/share/pan
#
# Enables tethering over USB network and Bluetooth PAN.
#
# usage: ./tether.sh start|stop [internal_interface]
#
# Examples:
# - "./tether.sh start" - Enables tethering on a single PAN client when an Internet connection is active
# - "./tether.sh stop" - Disables tethering on a single PAN client (assumes the client is on bnep0)
# - "./tether.sh start bnep1" - Enables tethering on a 2nd PAN client when an Internet connection is active
# - "./tether.sh stop bnep1" - Disables tethering on the 2nd PAN client, without interfering with the 1st
#
# Notes:
# - Tested to work with multiple Bluetooth PAN clients including a WiFi-only XOOM
# - Tested to work in conjuction with a dbus-scripts to automate tethering setups
# - Doesn't currently have support for multiple concurrent Internet interfaces
# such as an IPv4 grps connection and a seperate IPv6 grps connection.
# - IPv6 isn't supported yet... (Waiting for T-Mobile IPv6 activation)
#
# You will want to customize the IAP ID value below
# - DEFAULT_IAP_ID: This a code uniquely identifying the default GPRS connection to use if you aren't currently connected.
# It can be obtained with the following command: gconftool -R /system/osso/connectivity/IAP
# Find lines which matches /system/osso/connectivity/IAP/<IAP_ID> for the GRPS connection you use for Internet connectivity.
# See http://wiki.maemo.org/Phone_control#Connect_to_specific_saved_connection for more information.
DEFAULT_IAP_ID="efc9b252-9bf3-4aa7-a023-348c2d46f101"
DEFAULT_INTERFACE="bnep0"
PAN_NETWORK_PREFIX="10.20"
USB_NETWORK_PREFIX="10.30"
INTERFACE_OCTET="88"
DHCP_MIN_IP_OCTET="100"
DHCP_MAX_IP_OCTET="127"
DHCP_MAX_LEASE_TIME="1h"
PRIMARY_DNS="8.8.8.8"
SECONDARY_DNS="8.8.4.4"
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "usage: $0 start|stop [internal_interface]"
exit 1
fi
if [ -z "$2" ]; then
INTERFACE="$DEFAULT_INTERFACE"
else
INTERFACE="$2"
fi
print_message () {
echo "$(date) $*"
run-standalone.sh dbus-send \
--type=method_call \
--dest=org.freedesktop.Notifications \
/org/freedesktop/Notifications \
org.freedesktop.Notifications.SystemNoteInfoprint \
string:"$*"
}
connect_default_access_point () {
print_message "Establishing Default Connection"
dbus-send \
--system \
--type=method_call \
--print-reply \
--dest=com.nokia.icd \
/com/nokia/icd \
com.nokia.icd.connect \
string:$DEFAULT_IAP_ID uint32:0
#sleep 2
}
#set -x
INTERFACE_TYPE="$(echo $INTERFACE | sed 's/\([a-z]*\)[0-9]*/\1/')"
INTERFACE_NUMBER="$(echo $INTERFACE | sed 's/[a-z]*\([0-9]*\)/\1/')"
case $INTERFACE_TYPE in
bnep )
NETWORK_PREFIX="$PAN_NETWORK_PREFIX.$INTERFACE_NUMBER"
;;
usb )
NETWORK_PREFIX="$USB_NETWORK_PREFIX.$INTERFACE_NUMBER"
;;
* )
# Notify no active Internet connection
print_message "Unsupported interface type: $INTERFACE_TYPE"
exit 1
;;
esac
INTERFACE_IP="$NETWORK_PREFIX.$INTERFACE_OCTET"
NETMASK="255.255.255.0"
EXTERNAL_INTERFACE="$(ifconfig | awk '/(gprs|wlan)/ {print $1}' | head -1)"
DHCP_MIN_IP="$NETWORK_PREFIX.$DHCP_MIN_IP_OCTET"
DHCP_MAX_IP="$NETWORK_PREFIX.$DHCP_MAX_IP_OCTET"
DHCP_GATEWAY="$INTERFACE_IP"
DNSMASQ_PID_NAME="dnsmasq.$INTERFACE"
DNSMASQ_PID_FILE="/var/run/$DNSMASQ_PID_NAME.pid"
if [ "$1" == "start" ]; then
INTERFACE_EXISTANCE_CHECK="$(ifconfig -a | grep $INTERFACE | awk '{print $1}')"
if [ -z "$INTERFACE_EXISTANCE_CHECK" ]; then
# Notify no active Internet connection
print_message "$INTERFACE does not exist"
exit 1
fi
if [ -z "$EXTERNAL_INTERFACE" ]; then
connect_default_access_point
EXTERNAL_INTERFACE="$(ifconfig | awk '/(gprs|wlan)/ {print $1}' | head -1)"
if [ -z "$EXTERNAL_INTERFACE" ]; then
# Notify no active Internet connection
print_message "Unable to establish tether for $INTERFACE"
exit 1
fi
fi
# Setup interface
ifconfig $INTERFACE down 2> /dev/null
ifconfig $INTERFACE up
ifconfig $INTERFACE $INTERFACE_IP netmask $NETMASK
# Load modules
modprobe ipt_MASQUERADE
# flush old iptables rules
iptables --flush
iptables --table nat --flush
# Setup NAT
iptables --out-interface $EXTERNAL_INTERFACE \
--table nat \
--append POSTROUTING \
--jump MASQUERADE
# Enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding
echo 1 > /proc/sys/net/ipv4/conf/$EXTERNAL_INTERFACE/forwarding
# Setup DNS and DHCP
start-stop-daemon \
--exec /usr/sbin/dnsmasq \
--pidfile $DNSMASQ_PID_FILE \
--verbose \
--start -- \
--interface=$INTERFACE \
--listen-address=$INTERFACE_IP \
--except-interface=lo \
--bind-interfaces \
--pid-file=$DNSMASQ_PID_FILE \
--dhcp-range=$DHCP_MIN_IP,$DHCP_MAX_IP,$DHCP_MAX_LEASE_TIME \
--dhcp-option=1,$NETMASK \
--dhcp-option=3,$DHCP_GATEWAY \
--dhcp-option=6,$PRIMARY_DNS,$SECONDARY_DNS
# Notify user bluetooth tethering is active
print_message "Tethering from $INTERFACE to $EXTERNAL_INTERFACE activated"
elif [ "$1" == "stop" ]; then
start-stop-daemon \
--exec /usr/sbin/dnsmasq \
--pidfile $DNSMASQ_PID_FILE \
--verbose \
--stop
# Bring down the interface
ifconfig $INTERFACE down 2> /dev/null
# Disable IP forwarding for tethered interface
if [ -f "/proc/sys/net/ipv4/conf/$INTERFACE/forwarding" ]; then
echo 0 > /proc/sys/net/ipv4/conf/$INTERFACE/forwarding 2> /dev/null
fi
# Notify user bluetooth tethering is inactive
print_message "Tethering from $INTERFACE to $EXTERNAL_INTERFACE deactivated"
# Disable external interface IP forwarding if appropriate
DNSMASQ_CHECK="$(ps -eaf | grep 'dnsmasq' | grep -v -e '127\.0\.0\.1' -e 'grep')"
if [ -z "$DNSMASQ_CHECK" ]; then
echo "$(date) No more clients tethered--disabling all forwarding"
echo 0 > /proc/sys/net/ipv4/conf/$EXTERNAL_INTERFACE/forwarding
echo 0 > /proc/sys/net/ipv4/ip_forward
fi
else
echo "unknown argument: $1"
echo "usage: $0 start|stop [internal_interface]"
exit 1
fi
![]() |
| Tags |
| bluetooth-pan, tethering |
|
only issue I had was that when tethered it still behaved like there was no internet connection...
then I found that iptables had been uninstalled when I uninstalled v47 of the power kernel in order to install v46...
now, all is well
thanks for the script!