answered
2014-10-16 09:54:04 +0200
Edit on latest 1.1.6+ images there has been changes in connman so you dont need to hack connmanctl anymore, just use normal route commands.
Unfortunately some applications check with connman about the network status. So you need to connect your phone to for example non-working open wlan accesspoint, and just use usb connection as default route.
Following is only for advanced users. Don't blame me if you mess up your networking. Remember to take backups of your connman config so you can recover back to normal.
More complicated answer if you really want to do it. Is first remove blacklisted usb and rndis interfaces from /etc/connman/main.conf (and append gadget to PreferredTechnologies line if you want)
And after reboot install connman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use
/usr/lib/connman/tools/connmanctl config gadget_[identifierFromServicescommand]_usb --ipv4 manual 192.168.2.15 255.255.255.0 192.168.2.14 --nameservers 8.8.8.8
/usr/lib/connman/tools/connmanctl connect gadget_[identifierFromServicescommand]_usb
After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.
Here is example usbnet.sh script that I use on my phone (start with "usbnet.sh start" vs "usbnet.sh stop"):
#!/bin/sh
#### in /etc/networking/interfaces-file I have the following lines in Linux PC:
#allow-hotplug usb0
#auto usb0
#iface usb0 inet static
# address 192.168.2.14
# netmask 255.255.255.0
# up iptables -A POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
# up echo 1 > /proc/sys/net/ipv4/ip_forward
# down iptables -D POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
# down echo 0 > /proc/sys/net/ipv4/ip_forward
if [ -f /usr/lib/connman/tools/connmanctl ]; then
ctl=/usr/lib/connman/tools/connmanctl
else
echo "please install connman-tools first"
exit 1
fi
check=`grep usb /etc/connman/main.conf`
if [ "$check" == "" ]; then
echo /etc/connman/main.conf seems ok.
else
echo please fix /etc/connman/main.conf by for example running following command:
echo "# sudo sed -i 's/usb,//g' /etc/connman/main.conf"
echo "and reboot machine"
exit 1
fi
if [ "$*" == "start" ]; then
$ctl enable gadget > /dev/null 2>&1
gadget=`$ctl services|grep gadget|cut -b 26-|tail -1`
if [ "$gadget" == "" ]; then
echo "did not find any connected gadget"
else
echo "lets rock and roll. Disconnect cellular and wifi connections..."
$ctl disable wifi > /dev/null 2>&1
$ctl disable cellular > /dev/null 2>&1
echo "lets try figure out pc side ip..."
pc_ip=`netstat -a -n|grep 15:22|cut -d: -f8|tail -1`
if [ "$pc_ip" == "" ]; then
pc_ip=192.168.2.14
echo "reverting to default 192.168.2.14"
else
echo "found it: $pc_ip"
fi
$ctl config $gadget --ipv4 manual 192.168.2.15 255.255.255.0 $pc_ip --nameservers 8.8.8.8
$ctl connect $gadget > /dev/null 2>&1
fi
else
echo "stopping usbnet.sh"
$ctl enable wifi > /dev/null 2>&1
$ctl enable cellular > /dev/null 2>&1
fi
There is a How To here on TJC to get the internet connection of your Pc through the USB cable but I am not sure if you will suffer the problem thst you are only able to use the internet partly...
Alex ( 2014-10-15 15:07:49 +0200 )editWhat is your /etc/rc.d/rc.ip_forward?
Sebix ( 2016-08-04 22:01:08 +0200 )edit