Ask / Submit

Revision history [back]

click to hide/show revision 1
initial version

posted 2014-10-16 09:54:04 +0300

rainisto gravatar image

You can for example try setting wlan0 as adhoc network from commandline, that way system is fooled that wlan0 is beeing used when infact your default route still is usb0.

click to hide/show revision 2
No.2 Revision

You can for example try setting wlan0 as adhoc network from commandline, that way system is fooled that wlan0 is beeing used when infact your default route still is usb0.usb0/rndis0.

click to hide/show revision 3
No.3 Revision

You can Unfortunately some applications check with connman about the network status. So you need to connect your phone to for example try setting wlan0 non-working open wlan accesspoint, and just use usb connection as adhoc network from commandline, that way system is fooled that wlan0 is beeing used when infact your default route still is usb0/rndis0.route.

click to hide/show revision 4
No.4 Revision

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 so you can recover back to normal.

More complicated answer if you really want to do it. Is first remote blacklisted usb and rndis interfaces from /etc/connman/main.conf

And after reboot install conman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use "connmanctl connect gadget_[identifierFromServicescommand]_usb". After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

click to hide/show revision 5
No.5 Revision

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 so you can recover back to normal.

More complicated answer if you really want to do it. Is first remote blacklisted usb and rndis interfaces from /etc/connman/main.conf

And after reboot install conman-tools connman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use "connmanctl connect gadget_[identifierFromServicescommand]_usb". After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

click to hide/show revision 6
No.6 Revision

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 remote blacklisted usb and rndis interfaces from /etc/connman/main.conf

And after reboot install connman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use "connmanctl connect gadget_[identifierFromServicescommand]_usb". After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

click to hide/show revision 7
No.7 Revision

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 remote blacklisted usb and rndis interfaces from /etc/connman/main.conf

And after reboot install connman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use "connmanctl connect gadget_[identifierFromServicescommand]_usb". After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

disclaimer: you might need to run some more connmanctl commands to get everything running smoothly.

click to hide/show revision 8
No.8 Revision

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 remote blacklisted usb and rndis interfaces from /etc/connman/main.conf

And after reboot install connman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use "connmanctl use

connmanctl config [identifierFromServicescommand]_usb --ipv4 manual 192.168.2.15 255.255.255.0 192.168.2.14
connmanctl connect gadget_[identifierFromServicescommand]_usb". gadget_[identifierFromServicescommand]_usb

After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

disclaimer: you might need to run some more connmanctl commands to get everything running smoothly.

click to hide/show revision 9
No.9 Revision

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 remote blacklisted usb and rndis interfaces from /etc/connman/main.conf

And after reboot install connman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use

connmanctl config [identifierFromServicescommand]_usb gadget_[identifierFromServicescommand]_usb --ipv4 manual 192.168.2.15 255.255.255.0 192.168.2.14
connmanctl connect gadget_[identifierFromServicescommand]_usb

After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

click to hide/show revision 10
No.10 Revision

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 remote remove blacklisted usb and rndis interfaces from /etc/connman/main.conf

And after reboot install connman-tools package, and use "connmanctl services" to get list of your usb gadget line and then use

connmanctl config gadget_[identifierFromServicescommand]_usb --ipv4 manual 192.168.2.15 255.255.255.0 192.168.2.14
connmanctl connect gadget_[identifierFromServicescommand]_usb

After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

click to hide/show revision 11
No.11 Revision

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/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

connmanctl config gadget_[identifierFromServicescommand]_usb --ipv4 manual 192.168.2.15 255.255.255.0 192.168.2.14
connmanctl connect gadget_[identifierFromServicescommand]_usb

After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

click to hide/show revision 12
No.12 Revision

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

connmanctl config gadget_[identifierFromServicescommand]_usb --ipv4 manual 192.168.2.15 255.255.255.0 192.168.2.14
192.168.2.14 --nameservers 8.8.8.8
connmanctl connect gadget_[identifierFromServicescommand]_usb

After that connmanctl state should be "ready" and email client should not be asking network connect queries anymore.

click to hide/show revision 13
No.13 Revision

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

connmanctl /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
connmanctl /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.

click to hide/show revision 14
No.14 Revision

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:
#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 rndis /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 sudo sed -i 's/usb,rndis,//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 connected..."
    $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`
    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
click to hide/show revision 15
No.15 Revision

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:
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 rndis /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 sudo sed -i 's/usb,rndis,//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 connected..."
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`
    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
click to hide/show revision 16
No.16 Revision

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 rndis /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 sudo sed -i 's/usb,rndis,//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`
-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
click to hide/show revision 17
No.17 Revision

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 rndis /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 sudo sed -i 's/usb,rndis,//g' '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
click to hide/show revision 18
No.18 Revision

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 rndis 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 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
click to hide/show revision 19
No.19 Revision

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 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
click to hide/show revision 20
No.20 Revision

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 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
click to hide/show revision 21
No.21 Revision

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