{"id":581,"date":"2013-06-22T03:53:43","date_gmt":"2013-06-22T10:53:43","guid":{"rendered":"http:\/\/albertomilone.com\/wordpress\/?p=581"},"modified":"2013-06-22T03:53:43","modified_gmt":"2013-06-22T10:53:43","slug":"getting-back-tethering-on-android-jellybean","status":"publish","type":"post","link":"https:\/\/albertomilone.com\/blog\/getting-back-tethering-on-android-jellybean\/","title":{"rendered":"Getting back tethering on Android Jellybean"},"content":{"rendered":"<p>Apparently Android &gt;= 4.1.2 <a href=\"https:\/\/code.google.com\/p\/android\/issues\/detail?id=38563\">breaks tethering in some cases<\/a>.<\/p>\n<p>Basically you can connect to your phone but you will get no data whatsoever.<\/p>\n<p>This may be fair (at least from Google&#8217;s point of view) if your mobile phone operator doesn&#8217;t allow tethering and Google wants to respect that. If, like me, you&#8217;re using a virtual operator (such as <strong>Coopvoce<\/strong>, which relies on TIM&#8217;s network) which clearly allows tethering (it&#8217;s written on their website), this new &#8220;feature&#8221; will break tethering for no reason and I&#8217;m not sure if such operators can or will actually do anything to fix the issue on their side.<\/p>\n<p>The main reason I have an Internet connection on my phone is because my ADSL at home has poor upstream bandwidth, therefore (for lack of alternatives) I use my phone&#8217;s HSUPA connection to upload stuff for work. Breaking tethering for me means making my life more difficult.<\/p>\n<p>Fortunately, in that bug report in the link above I also found part of the solution which helped me get Wireless tethering. Then I managed to enable USB tethering by myself.<\/p>\n<p>This tutorial will require <strong>rooting<\/strong> your phone, which you will <strong>do at your own risk<\/strong> and googling how to do it.<\/p>\n<h3>Requirements:<\/h3>\n<ul>\n<li>Grab the Android SDK<\/li>\n<li>Make a backup of your data (as unlocking the bootloader will erase everything)<\/li>\n<li>Unlock your bootloader<\/li>\n<li>Root your phone (install <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.koushikdutta.superuser&amp;feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5rb3VzaGlrZHV0dGEuc3VwZXJ1c2VyIl0.\">Superuser.apk<\/a>)<\/li>\n<li>Install &#8220;Scripts Manager&#8221; (SManager)<\/li>\n<li>Install a Text editor<\/li>\n<\/ul>\n<h3>Follow these steps:<\/h3>\n<p>Connect your phone to your PC using the USB cable<\/p>\n<p>Check your devices and their IP addresses:<\/p>\n<p>(Make sure that tethering is disabled and that your 3G\/2G\/HSUPA connection is enabled and running)<\/p>\n<pre>\nsudo adb kill-server\nsudo adb start-server\nadb shell\nsu\nnetcfg\n<\/pre>\n<p>Which will give you something like the following:<\/p>\n<pre>\nlo\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 127.0.0.1\/8\u00a0\u00a0 0x00000049 00:00:00:00:00:00\nifb0\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000082 22:b3:ab:4e:2b:0c\nifb1\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000082 6e:67:b2:6f:8d:6c\nsit0\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000080 00:00:00:00:00:00\nip6tnl0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000080 00:00:00:00:00:00\nrmnet0\u00a0\u00a0 UP\u00a0\u00a0\u00a0\u00a0\u00a0 217.202.140.0\/24\u00a0\u00a0 0x000010d1 00:00:00:00:00:00\nrmnet1\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001090 00:00:00:00:00:00\nrmnet2\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001090 00:00:00:00:00:00\np2p0\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001002 a2:0b:ba:21:d1:fe\nwlan0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001002 a0:0b:ba:21:d1:fe\n<\/pre>\n<p>In this case the interesting device is &#8220;<strong>rmnet0<\/strong>&#8221; (let&#8217;s call it the 3G device). Write down its name and its IP address.<\/p>\n<p>Now enable USB tethering and run &#8220;netcfg&#8221; again:<\/p>\n<pre>\nlo\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 127.0.0.1\/8\u00a0\u00a0 0x00000049 00:00:00:00:00:00\nifb0\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000082 22:b3:ab:4e:2b:0c\nifb1\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000082 6e:67:b2:6f:8d:6c\nsit0\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000080 00:00:00:00:00:00\nip6tnl0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00000080 00:00:00:00:00:00\nrmnet0\u00a0\u00a0 UP\u00a0\u00a0\u00a0\u00a0\u00a0 217.202.140.0\/24\u00a0\u00a0 0x000010d1 00:00:00:00:00:00\nrmnet1\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001090 00:00:00:00:00:00\nrmnet2\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001090 00:00:00:00:00:00\np2p0\u00a0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001002 a2:0b:ba:21:d1:fe\nwlan0\u00a0\u00a0\u00a0 DOWN\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0\/0\u00a0\u00a0 0x00001002 a0:0b:ba:21:d1:fe\nrndis0\u00a0\u00a0 UP\u00a0\u00a0\u00a0\u00a0\u00a0 192.168.42.129\/24\u00a0 0x00001043 c2:09:33:df:45:64\n<\/pre>\n<p>You will notice the presence of a new device (in this case &#8220;<strong>rndis0<\/strong>&#8221; which is the USB device). Again take note of its name and IP address (which will vary but it&#8217;s not a problem).<\/p>\n<p>We can now try to route traffic using iptables.<\/p>\n<p>So, for <strong>Wireless tethering<\/strong> (use the name of the 3G device and leave the IP address as it is):<\/p>\n<pre>iptables -tnat -A natctrl_nat_POSTROUTING -s 192.168.0.0\/16 -o rmnet0 -j MASQUERADE<\/pre>\n<p>And for <strong>USB tethering<\/strong> (use the name of the USB device and use the IP address of the 3G device):<\/p>\n<pre>iptables -tnat -A natctrl_nat_POSTROUTING -s 217.202.140.0\/24 -o rndis0 -j MASQUERADE<\/pre>\n<p><em><strong>Note:<\/strong> I&#8217;m not very familiar with iptables but I&#8217;ve found these commands to solve the problem here.<\/em><\/p>\n<p>Test tethering using a PC. If it works, then we can save the two lines above in a script.<\/p>\n<p>Open a text editor from your phone and type (or you can write it on your PC and then push it to your phone using adb push):<\/p>\n<pre>\n#!\/system\/bin\/sh\niptables -tnat -A natctrl_nat_POSTROUTING -s 192.168.0.0\/16 -o rmnet0 -j MASQUERADE\niptables -tnat -A natctrl_nat_POSTROUTING -s 217.202.140.0\/24 -o rndis0 -j MASQUERADE\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Then save the file, open it using SManager and tap on the &#8220;Boot&#8221; and on the &#8220;Su&#8221; labels (since we want this to run on boot and it requires root privileges).<\/p>\n<p><em><strong>Note: Make sure to give SManager root permissions when the Superuser app asks you.<\/strong><\/em><\/p>\n<p>And that&#8217;s it, restart your phone and everything should work flawlessly from now on.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apparently Android &gt;= 4.1.2 breaks tethering in some cases. Basically you can connect to your phone but you will get no data whatsoever. This may be fair (at least from Google&#8217;s point of view) if your mobile phone operator doesn&#8217;t allow tethering and Google wants to respect that. If, like me, you&#8217;re using a virtual <a class=\"read-more\" href=\"https:\/\/albertomilone.com\/blog\/getting-back-tethering-on-android-jellybean\/\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,14,5,9],"tags":[20],"class_list":["post-581","post","type-post","status-publish","format-standard","hentry","category-android","category-gnulinux","category-planet","category-ubuntu","tag-android"],"_links":{"self":[{"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/posts\/581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/comments?post=581"}],"version-history":[{"count":0,"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/posts\/581\/revisions"}],"wp:attachment":[{"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/media?parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/categories?post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/albertomilone.com\/blog\/wp-json\/wp\/v2\/tags?post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}