{"id":322,"date":"2011-10-01T03:39:43","date_gmt":"2011-10-01T01:39:43","guid":{"rendered":"https:\/\/www.opengis.ch\/?p=322"},"modified":"2020-04-29T16:06:56","modified_gmt":"2020-04-29T14:06:56","slug":"sharing-internet-connection","status":"publish","type":"post","link":"https:\/\/www.opengis.ch\/it\/2011\/10\/01\/sharing-internet-connection\/","title":{"rendered":"Sharing internet connection"},"content":{"rendered":"<p>Today, for some bizarre reasons only my android phone was connecting to a WiFi. So I decided to use it as a tethered modem. The problem was that my friend Bruno could not use the net either, so since networkmanager ad-hoc networks were not working and it is our day off climbing we decided to keep our fingers trained on the keyboard.<!--more--><br \/>\nHere are two little scripts to create an adhoc Wifi and forward internet connection over it.<br \/>\nenjoy Marco (and Bruno)<br \/>\nServer:<br \/>\n<code>#!\/bin\/sh<br \/>\nWIFINAME=bernaadhocwifi<br \/>\nKEY=keyneedtobe13 #key needs to be 5, 13 or 29 chars<br \/>\nGWIP=192.168.0.1<br \/>\nINTERFACE=wlan0<br \/>\nINTERFACETOSHARE=usb0<br \/>\n#<br \/>\n#Uncomment get ip from android phone or anything you need<br \/>\n#sudo ifconfig $INTERFACETOSHARE up<br \/>\n#sudo dhclient $INTERFACETOSHARE<br \/>\n#END CONFIG<br \/>\n#<br \/>\nsudo ifconfig $INTERFACE down<br \/>\nsudo iwconfig $INTERFACE mode ad-hoc<br \/>\nsudo iwconfig $INTERFACE essid $WIFINAME key s:$KEY<br \/>\nsudo ifconfig $INTERFACE $GWIP netmask 255.255.255.0 up<br \/>\n#Follow the above steps for another wireless card and set IP address in same subnet, say 192.168.0.2, and ping each other.<br \/>\n#<br \/>\n#Now to share the internet over wireless,<br \/>\nsudo iptables -t nat -A POSTROUTING -o $INTERFACETOSHARE -j MASQUERADE<br \/>\n#where usb0 is the connection you want to share<br \/>\n#You also need to enable IP forwarding:<br \/>\nsudo sh -c \"echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward\"<br \/>\n#Or, to enable permanently add the following line to \/etc\/sysctl.conf<br \/>\n#net.ipv4.ip_forward=1<br \/>\n#Some ISPs might limit the TTL so that you wont be able to share the internet. Fix:<br \/>\n#sudo iptables -t mangle -A PREROUTING -j TTL --ttl-inc 1<\/code><br \/>\nClient<br \/>\n<code>#!\/bin\/sh<br \/>\nWIFINAME=bernaadhocwifi<br \/>\nKEY=keyneedtobe13 #key needs to be 5, 13 or 29 chars<br \/>\nIP=192.168.0.2<br \/>\nGWIP=192.168.0.1<br \/>\nINTERFACE=wlan0<br \/>\n#END CONFIG<br \/>\n#<br \/>\n#Using the shared internet (in Linux)<br \/>\nsudo ifconfig $INTERFACE down<br \/>\nsudo iwconfig $INTERFACE mode ad-hoc<br \/>\nsudo iwconfig $INTERFACE essid $WIFINAME key s:$KEY<br \/>\nsudo ifconfig $INTERFACE $IP netmask 255.255.255.0 up<br \/>\n#<br \/>\n#Now to use the shared internet on another computer, set it to ad-hoc mode and assign IP address in the same subnet as described above and perform the following:<br \/>\n#<br \/>\n#Set the IP of computer sharing internet as gateway<br \/>\nsudo route add default gw $GWIP<br \/>\n#Set DNS server. We're using Google's DNS.<br \/>\nsudo sh -c \"echo 'nameserver 8.8.8.8' >> \/etc\/resolv.conf\"<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, for some bizarre reasons only my android phone was connecting to a WiFi. So I decided to use it as a tethered modem. The problem was that my friend Bruno could not use the net either, so since networkmanager ad-hoc networks were not working and it is our day [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[19],"tags":[125],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-scripts","tag-qgis-org"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":147,"url":"https:\/\/www.opengis.ch\/it\/2010\/12\/01\/qgis-globe-plugin-installer-script\/","url_meta":{"origin":322,"position":0},"title":"QGis Globe Plugin installer script","author":"Marco Bernasocchi","date":"1 Dicembre 2010","format":false,"excerpt":"Lately, thanks to ma Master Thesis, I've been co-working on the Globe Plugin for QGis here my install script for a threaded version of QGis with the Globe Plugin. By now the Globe has stereo 3D support, keyboard navigation (try all the num key), mouse navigation, a gui to control\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.opengis.ch\/it\/category\/programming\/cpp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1857,"url":"https:\/\/www.opengis.ch\/it\/2015\/10\/14\/spacemouse-in-ubuntu-15-04\/","url_meta":{"origin":322,"position":1},"title":"SpaceMouse in Ubuntu 15.04","author":"Marco Bernasocchi","date":"14 Ottobre 2015","format":false,"excerpt":"While preparing some 3D scenes for an exibition I discovered the SpaceMouse by 3dconnexion. A neat device we plan on installing in front of a projected globe. To get it to run in Ubuntu first get the drivers from www.3dconnexion.eu\/service\/drivers.html then sudo apt-get install libmotif3 mkdir -p \/tmp\/3D3dxware-linux cd \/tmp\/3D3dxware-linux\u2026","rel":"","context":"In &quot;3D&quot;","block_context":{"text":"3D","link":"https:\/\/www.opengis.ch\/it\/category\/3d\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":243,"url":"https:\/\/www.opengis.ch\/it\/2011\/07\/06\/globe-is-in-qgis-trunk\/","url_meta":{"origin":322,"position":2},"title":"Globe is in QGIS Trunk","author":"Marco Bernasocchi","date":"6 Luglio 2011","format":false,"excerpt":"Last night Pirmin committed our Globe plugin to the QGIS trunk. this means that getting the needed dependencies (see below), building QGIS with -DWITH_GLOBE=ON and activating the plugin its all it takes to get a super globe running on QGIS. Dependencies: sudo apt-get install osgearth osgearth-dev openscenegraph (should be enough)\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.opengis.ch\/it\/category\/programming\/cpp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3691,"url":"https:\/\/www.opengis.ch\/it\/2018\/04\/13\/porting-qgis-plugins-to-api-v3-strategy-and-tools\/","url_meta":{"origin":322,"position":3},"title":"Porting QGIS plugins to API v3 &#8211; Strategy and tools","author":"Marco Bernasocchi","date":"13 Aprile 2018","format":false,"excerpt":"The Release of QGIS 3.0 was a great success and with the first LTR (3.4) scheduled for release this fall, it is now the perfect time to port your plugins to the new API. QGIS 3.0 is the first major release since September 2013 when QGIS 2.0 was released. During\u2026","rel":"","context":"In &quot;Featured&quot;","block_context":{"text":"Featured","link":"https:\/\/www.opengis.ch\/it\/category\/featured\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1149,"url":"https:\/\/www.opengis.ch\/it\/2015\/01\/11\/qgis-mobile-0-2-demo\/","url_meta":{"origin":322,"position":4},"title":"QGIS Mobile 0.2 Demo","author":"Marco Bernasocchi","date":"11 Gennaio 2015","format":false,"excerpt":"It is with great pleasure the we want to share with you the demo video of version 0.2. of QGIS Mobile (temporary name) is a touch optimized interface for field work developed by OPENGIS.ch. The QGIS mobile 0.2 video demonstrates some basic functionality like navigation, feature identification and attribute editing.\u2026","rel":"","context":"In &quot;Android QGIS&quot;","block_context":{"text":"Android QGIS","link":"https:\/\/www.opengis.ch\/it\/category\/gis\/qfield\/android-qgis\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1147,"url":"https:\/\/www.opengis.ch\/it\/2015\/01\/08\/happy-new-year-to-the-power-of-two\/","url_meta":{"origin":322,"position":5},"title":"Happy new year to the power of two!","author":"Matthias Kuhn","date":"8 Gennaio 2015","format":false,"excerpt":"For the first time we at OPENGIS.ch can celebrate with 2 people, Marco Bernasocchi and Matthias Kuhn both experienced QGIS developers and holders of a Master degree in GIScience. After having worked individually in the last years, we have realized that there is a huge potential for us to join\u2026","rel":"","context":"In &quot;Android QGIS&quot;","block_context":{"text":"Android QGIS","link":"https:\/\/www.opengis.ch\/it\/category\/gis\/qfield\/android-qgis\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/pbdBtI-5c","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":1,"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":11200,"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/posts\/322\/revisions\/11200"}],"wp:attachment":[{"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opengis.ch\/it\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}