{"id":2262,"date":"2016-02-15T10:26:27","date_gmt":"2016-02-15T02:26:27","guid":{"rendered":"https:\/\/www.csslayer.info\/wordpress\/?p=2262"},"modified":"2016-02-15T10:26:27","modified_gmt":"2016-02-15T02:26:27","slug":"use-jolla-phone-to-share-wifi-via-usb","status":"publish","type":"post","link":"https:\/\/www.csslayer.info\/wordpress\/linux\/use-jolla-phone-to-share-wifi-via-usb\/","title":{"rendered":"Use Jolla Phone to share Wifi via USB"},"content":{"rendered":"<p>Recently I got a new Surface Pro 4, and starts to use it as my main laptop. I&#8217;m glad that it can work with Linux <a href=\"https:\/\/www.reddit.com\/r\/SurfaceLinux\/comments\/3xhmu7\/just_installed_chakra_linux_on_surface_pro_4_i7\/\">quite well<\/a>. But it does have some issue that I can&#8217;t live with: <a href=\"https:\/\/bugzilla.kernel.org\/show_bug.cgi?id=109681\">wifi will stop working after hours randomly<\/a>.<\/p>\n<p>Though someone points a <a href=\"https:\/\/github.com\/jimdigriz\/debian-mssp4\/blob\/master\/root\/lib\/systemd\/system-sleep\/mwifiex_pcie.sh\">workaround<\/a> to me on reddit, but it does not work for me. Fortunately, I was able to just use my usb ethernet at that time. But recently, I moved my seat at home to a place where I couldn&#8217;t reach the ethernet cable, so I has been forced to use wifi since then.<\/p>\n<p>Luckily, I found a <a href=\"https:\/\/together.jolla.com\/question\/3798\/usb-tethering\/\">thread<\/a> that indicated that I can make my Jolla phone to share the internet via USB. To make it short, one just need to execute<\/p>\n<pre>pkcon install usb-moded-connection-sharing-android-config<\/pre>\n<p>with developer account and restart the phone.<\/p>\n<p>But later I found that it only works with Cellular network but not with wifi. I digged into the <a href=\"https:\/\/git.merproject.org\/mer-core\/usb-moded\">related usb-moded code<\/a> to confirm that. The implementation explicitly disables wifi and enables cellular network for sharing.<\/p>\n<p>But this is not the end of the story. I found I can still manually enable wifi after select Internet sharing as usb mode. But the network itself doesn&#8217;t work, because the implementation only adds the masquerade iptables rule for the cellular network. So I just tried to add my iptables rule manually via:<\/p>\n<pre>iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE<\/pre>\n<p>And it works!<\/p>\n<p>Then I created an expect(1) script to ssh to phone and execute the iptables command automatically, so now I can happily use Jolla to connect the wifi network for me, just like using a wifi dongle. I still need to configure the dns server manually via networkmanager for my local connection because the dns server pushed by dhcp server is for cellular network, but that&#8217;s good enough since I can even use google&#8217;s public dns server blindly if I don&#8217;t are too much about the dns speed.<\/p>\n<p>This iptables rule also seems to be persistent if you don&#8217;t restart the phone, so I&#8217;m also considering to add it when the phone boots. For now I&#8217;m happy with my current solution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I got a new Surface Pro 4, and starts to use it as my main laptop. I&#8217;m glad that it can work with Linux quite well. But it does have some issue that I can&#8217;t live with: wifi will &hellip; <a href=\"https:\/\/www.csslayer.info\/wordpress\/linux\/use-jolla-phone-to-share-wifi-via-usb\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[218,221,220,219],"class_list":["post-2262","post","type-post","status-publish","format-standard","hentry","category-linux","tag-jolla","tag-tethering","tag-usb","tag-wifi"],"_links":{"self":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/comments?post=2262"}],"version-history":[{"count":1,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2262\/revisions"}],"predecessor-version":[{"id":2263,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2262\/revisions\/2263"}],"wp:attachment":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/media?parent=2262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/categories?post=2262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/tags?post=2262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}