http://openmoko.org/api.php?action=feedcontributions&user=Kostigoff&feedformat=atomOpenmoko - User contributions [en]2024-03-28T13:17:16ZUser contributionsMediaWiki 1.19.24http://openmoko.org/wiki/Om_2008.8Om 2008.82008-12-16T20:01:52Z<p>Kostigoff: /* Known Issues */</p>
<hr />
<div>{{Languages|Om 2008.8}}<br />
{{Om 2008.8}}<br />
<br />
{{Distributions|Om 2008.8}}<br />
<br />
== Summary ==<br />
<br />
'''Om 2008.8''' is the successor to [[Om 2007.2]] and had '''ASU''' as a codename. It was [http://lists.openmoko.org/pipermail/community/2008-August/025619.html released] on '''August 08, 2008''' (+ update "stable" releases starting from '''August 26, 2008'''). Om 2008.8 uses EFL for the launcher, custom UI applications and [[QtopiaOnX11|Qtopia on X11]] for telephony. The distribution is the first step from GTK+ on x11 to using multiple toolkits in combination.<br />
<br />
Compared to 2007.2 that had a longer development history, Om 2008.8 was definitely a .0 major release. So think KDE 4.0 vs. 3.5, not Linux 2.6.23 vs. 2.6.22. There were daily updates, some good some bad. The official life of Om 2008.8 was terminated with the release of a minor update, [[Om 2008.9 Update]]. However, since the minor update introduced no new major changes, most of the following remains true for 2008.9 also.<br />
<br />
== What was new compared to 2007.2 ? ==<br />
<br />
The main user-visible changes introduced in 2008.8 were:<br />
<br />
* The user interface has been fully revised with a new window manager [[illume]]. It is visually much richer, and can be customized further by using your own [[Edje]] files.<br />
* '''[[Om2008.8_Installer|A graphical installer]]''' allows to add easily new applications, [[Themes]] and functionality.<br />
* A new [[Om2008.8_Locations|Locations]] application is provided, to save your favorite spots and share them with friends via sms.<br />
* Power management has been improved: The Aux button now locks the screen, the Power button suspends and the red LED behind the Aux button lights up when charging.<br />
* The [[Om2008.8_Keyboard| keyboard]] is now the Qtopia one (whether this is an improvement has been [[Keyboard_Debate|hotly debated]]).<br />
<br />
For developers, the main changes are:<br />
* Multiple toolkits: '''Om 2008.8''' supports [http://www.enlightenment.org/ EFL], [http://trolltech.com/products/qtopia Qtopia] and [http://www.gtk.org GTK+] applications.<br />
* A [[Community Repository]] has been set up, it is integrated in the ([[Om2008.8_Installer|Installer]]).<br />
* '''Source Codes''' are publicly available, allowing for customization all the way down to low level systems.<br />
<br />
For more details, see the [[Om 2008.8 Guide]] and the [[Om 2008.8 Feature Plan]].<br />
<br />
<br />
{| class="wikitable" cellspacing="2" cellpadding="2" style="padding: 0%; margin:0em 0em 1em 0em; border:1px solid #c0c0c0; background:#eeeeee; width:100%;floating="center"; "<br />
! style="background:#fcfcfc;border-left:1px solid #9999cc;border-right:1px ; border-top:2px solid 75d806; border:1px solid #222222; width:33% " |<br />
[[Image:Om2008 home.png|200px|center]]<br />
! style="background:#fcfcfc;border-left:1px solid #9999cc;border-right:1px ; border-top:2px solid 75d806; border:1px solid #222222; width:33% " |<br />
[[Image:Installer4.png|200px|center]]<br />
! style="background:#fcfcfc;border-left:1px solid #9999cc;border-right:1px ; border-top:2px solid 75d806; border:1px solid #222222; width:33% " |<br />
[[Image:Om2008 installer1.png|200px|center]]<br />
|-<br />
<br />
! style="background:#fcfcfc;border-left:1px solid #9999cc;border-right:1px ; border-top:2px solid 75d806; border:1px solid #222222; width:33% " |<br />
[[Image:Main.png|200px|center]]<br />
! style="background:#fcfcfc;border-left:1px solid #9999cc;border-right:1px ; border-top:2px solid 75d806; border:1px solid #222222; width:33% " |<br />
[[Image:Edit1.png|200px|center]]<br />
! style="background:#fcfcfc;border-left:1px solid #9999cc;border-right:1px ; border-top:2px solid 75d806; border:1px solid #222222; width:33% " |<br />
[[Image:Om locations4.png|200px|center]]<br />
|}<br />
<br />
<br />
<!---the following anchor is here to ensure that the "Download" link at http://openmoko.com/download.html links to the correct section. please don't delete the anchor unless that link is changed or removed---><br />
<span id="Flash_Om_2008.8_images"></span><br />
<br />
<br />
<br />
== Known Issues ==<br />
<br />
This is only a subset, and some of the bits reported below may have been fixed by stable updates (see [http://onlinedev.blogspot.com/search/label/om2008.8%20review Alasal's test reports] as well as the "Updates" section below). See [http://docs.openmoko.org/trac/search?q=2008.8 all tickets with 2008.8] in the bug tracker.<br />
<br />
'''Suspend'''<br />
<br />
Builds from the last days of August tend to suspend after 30s no matter what you set in settings. Switching the screensaver off with `xset s off' disables suspend completely. Note that this command must be typed into the terminal application on the phone itself; if you try to run it from an ssh session it fails with the error `xset: unable to open display ""'. This is because ssh sessions change the display settings expecting you might want X11 forwarding. In fact if you are using X11 forwarding with ssh -Y, the command won't fail over ssh, but it still won't do what you expect, as xset will assume you're talking about the forwarded X11 session, and thus doesn't affect the X11 session on the phone. Therefore if you use a ssh session you need to enter `xset -display :0 s off'.<br />
<br />
Alex reportedly solved the problem going into Illume Settings, then Power, and setting to OFF the 2 parameters. He still gets the screensaver, but can reactivate easily just by touching.<br />
<br />
If resume breaks audio (the ringing of the phone or for calling someone) a very probable reason is that the pulseaudio sound server is installed. This happens e.G. when openmoko-mediaplayer2 is installed. There seems to be [http://lists.openmoko.org/pipermail/openmoko-kernel/2008-August/004877.html activity to fix this application] already, though.<br />
<br />
'''GSM'''<br />
<br />
* [http://docs.openmoko.org/trac/ticket/1766 Cannot make calls or receive SMS messages]<br />
* [http://docs.openmoko.org/trac/ticket/1662 GSM not working properly after x hours]<br />
* [http://docs.openmoko.org/trac/ticket/1832 Cannot dial numbers starting with * or #]<br />
<br />
'''WiFi'''<br />
<br />
* [http://docs.openmoko.org/trac/ticket/1929 WiFi can only connect once]<br />
<br />
'''Audio quality'''<br />
<br />
* [http://docs.openmoko.org/trac/ticket/1640 Improve overall audio]<br />
<br />
'''System Software'''<br />
<br />
* [http://docs.openmoko.org/trac/ticket/1736 Boot screen goes into sleep and never wake up if not touch during booting]<br />
* [http://docs.openmoko.org/trac/ticket/1597 After long suspend, kernel thread events]<br />
* [http://docs.openmoko.org/trac/ticket/1315 xglamo: performance decreases after a while]<br />
* [http://docs.openmoko.org/trac/ticket/1682 Neo turns off before reaching x]<br />
<br />
'''QPE high cpu usage'''<br />
* qpe does scan whole filesystem ( including SD card ) for documents , mp3 files , etc. If you don't want it you can edit <tt>/opt/Qtopia/etc/default/Trolltech/Storage.conf</tt> and disable Sd Card scanning ( overwrite 1 by 0 ), i.e. the section in the file should read like this after aplying the change to Om2008.9:<br />
<br><code>[MountPoint0]</code><br />
<br><code>Name[] = SD Card</code><br />
<br><code>Path=/dev/mmcblk0p1</code><br />
<br><code>Removable = 1</code><br />
<br><code>Applications = 0</code><br />
<br><code>Documents = 0</code><br />
<br><code>ContentDatabase = 0</code><br />
<br />
<br />
'''Networking'''<br />
* No Updates/Installation are possible or pings to domains because DNS is not working. This problem occurs because the /etc/resolv.conf is empty by default.<br />
Add these lines in /etc/network/interfaces:<br />
<pre><br />
up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf<br />
</pre><br />
This is to be inserted below gateway address and above the bluetooth networking. After this it will be set on every reboot. Note that sending all DNS traffic to these servers lets their administrators follow each and every web site you visit. You might want to consider using the nameservers of your real ISP instead since they can already do such tracking.<br />
<br />
For resolving DNS without restarting, run the following commands:<br />
<pre><br />
echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf<br />
</pre><br />
This should solve most of your moko side networking issues. If you need any other help please refer to [[USB Networking]]<br />
<br />
{{note| [http://en.wikipedia.org/wiki/Resolvconf resolvconf] is installed so should probably be used<br />
<br />
'''Problem''': parts of resolvconf are missing: without the scripts under /etc/network/if-{up,down}.d, and /etc/resolvconf/run/enable-updates and /lib/resolvconf/list-records it does nothing, and even then, /etc/resolvconf/run should probably be a symlink to /var/run, or /etc/resolv.conf needs to be pointed at /etc/resolvconf/run/resolv.conf -- once all that's done, it seems to work as long as you add something like this to /etc/network/interfaces at the end of the usb0 stanza:<br />
<br />
dns-nameservers 192.168.0.200<br />
dns-search example.com<br />
<br />
and add <tt>usb*</tt> above <tt>eth*</tt> in <tt>/etc/resolvconf/interface-order</tt><br />
<br />
}}<br />
<br />
{{Note| '''Solution:''' Steps to add missing resolvconf script: <br><br />
<code>touch /etc/resolvconf/run/enable-updates</code><br><br />
<code>cd /etc ; rm resolv.conf ; ln -s /etc/resolvconf/run/resolv.conf .</code><br><br />
<code>mkdir /lib/resolvconf/ ; cd /lib/resolvconf/</code><br><br />
<code><br />
<br />
<nowiki>wget http://87.227.108.179/list-records</nowiki> </code><br><br />
<code>chmod +x list-records</code><br><br />
Edit <code>/etc/network/interfaces</code> and remove the lines:<br><br />
<code> network 192.168.0.0</code><br><br />
<code> gateway 192.168.0.200</code><br><br />
If we need to use the usb network more then just locally from the computer in the other end of the USB-cable, login with ssh and add a default route like this:<br><br />
<code>route add default gateway 192.168.0.200</code><br />
}}<br />
<br />
* Usb-networking will not work until rebooted after initial boot.<br />
<br />
'''Usability'''<br />
<br />
* The Pin-Dialog by default just shows letters. You have to slide your finger up/down over the keyboard to make the numbers/uppercase/special characters appear.<br />
* The installer app doesn't release administrative rights which results in not being able to use opkg. Solution: run "killall packagekitd" (on the freerunner or when ssh'ed in).<br />
* The installer app doesn't release administrative rights which results in not being able to use opkg. Alternate Solution: On the FreeRunner, use the drop-down menu to close all open applications.<br />
* The keyboard may not be adapted for all uses. See [[Keyboard Debate]] for a full discussion and options.<br />
<br />
== Subsequent upgrades ==<br />
<br />
Posterior to the Om2008.8 release made on 2008/08/08, development has been [http://lists.openmoko.org/pipermail/community/2008-August/026491.html split in two branches] aiming respectively at the next minor and major releases.<br />
<br />
Direct follow-up for 2008.8 occured on the [http://git.openmoko.org/?p=openmoko.git;a=shortlog;h=org.openmoko.asu.stable org.openmoko.asu.stable] branch, with the short term goal to improve stability and useability, keeping the same features set. Official updates are available in the [http://downloads.openmoko.org/repository/Om2008.8/ 2008.8 packages repository] feeds. Since this repository is already configured in 2008.8, using 'opkg update; opkg upgrade' is sufficient to stay up to date. On September 19th, a point upgrade named [[Om 2008.9 Update]] was released. Maintenance-oriented development continues on the same branch towards the second point update, still using the same package repositories.<br />
<br />
The long-term development branch is named [http://git.openmoko.org/?p=openmoko.git;a=shortlog;h=org.openmoko.dev org.openmoko.dev], this is where most activity happens. This branch has refocused on the base system functionalities, no applications are installed by default. Critical bugfixes from that branch are eventually ported to the ''.asu.stable'' branch. Using binaries updates from that branch (or any other non-2008.8 repository) on a 2008.x stable base is likely to send you in [http://en.wikipedia.org/wiki/Dependency_hell Dependency Hell], you have been warned.<br />
<br />
== Dedication ==<br />
<br />
<pre><br />
From: Openmoko<br />
To: openmoko-community mailing list<br />
<br />
Om 2008.8 was designed to be empty, for the very purpose of showcasing your ideas.<br />
<br />
Think of our products as galleries. We're building the environment.<br />
Each one different from the next. You'll get all the free art supplies<br />
you could imagine because we want you to add your own meaning.<br />
You choose: consume, create, or both.<br />
<br />
Either way you create your own meaning. It's about you.<br />
</pre><br />
<br />
[[Category:Om 2008.8| ]]</div>Kostigoffhttp://openmoko.org/wiki/FDOM_-_a_Fat_and_Dirty_OM_based_distribution/ruFDOM - a Fat and Dirty OM based distribution/ru2008-12-11T20:03:24Z<p>Kostigoff: /* Описание */</p>
<hr />
<div>{{Languages|FDOM_-_a_Fat_and_Dirty_OM_based_distribution}}<br />
=== Описание ===<br />
Это комбинация приложений и демонстрация возможностей Freerunner и функциональный телефон. Все получено из официальных рпозитарев.<br />
<br />
Любые вопросы могут быть посланы на dsamblas at gmail dot com<br />
<br />
или в комунтити форуме или local-openmoko-spain list<br />
<br />
Смотри [[Development_resources#Mailing_Lists|mailing lists]]<br />
<br />
David-Reyes Samblas Martinez<br />
<br />
Co Admins<br />
<br />
Armin ranjbar aka zoup<br />
<br />
Nacho Seijo aka himero<br />
<br />
=== Скачать ===<br />
Download from http://compartida.net/openmoko/FDOM .<br />
* Note: Use '''wget -c''' to retrieve the files, because the server seems to cut the connection time to time. Do check the md5 hashes of the files after downloading to prevent any problems. or try one of the mirrors<br />
* Mirrors:<br />
** http://files.tdobson.net/openmoko/freerunner/fdom/<br />
*** Mirror admin contact: www.tdobson.net/contact<br />
** http://openmoko.truebox.co.uk/mirror/compartida.net/<br />
<br />
=== Development ===<br />
I you want to come to the script kidding party :) join us at <br />
<br />
http://projects.openmoko.org/projects/fdom/<br />
<br />
Serious developers are welcome too :) but remember "if it's cool, it works(in some way),doesn't annoying(too much) rest of things and fits on the nand it's in" :) we will let scalability, stability, resource saving and so on to the OM guys :) <br />
<br />
=== Предупреждение ===<br />
* If after an opkg update/upgrade dialer, contacts and other qtopia-x11 apps don't work and qpe shows an error window you should check whether the startup file is executable, or revert changes.<br />
<br />
The following adds permissions of '''r'''ead and e'''x'''ecution to the qtopia startup session file:<br />
# chmod a+rx /etc/X11/Xsession.d/89qtopia<br />
<br />
The following reverts last change to the qtopia startup session file:<br />
# cp /etc/X11/Xsession.d/89qtopia.bk~ /etc/X11/Xsession.d/89qtopia<br />
<br />
Теперь перегрузитесь neo.<br />
<br />
==== Обновление от 15 Сентября ====<br />
* It seems that there were major updates today that caused dialer to not work , It does happen when you click on dialer and it does exit with Enlightenment error , qucik fix to this is <br />
<br />
# ln /opt/Qtopia/bin/qcop /usr/bin/qcop -s<br />
<br />
but i believe adding /opt/Qtopia/bin to global system path is better solution (How?).<br />
<br />
==== 20080927 and Pidgin ====<br />
* I forget to install the following packages to enable ssl (needed by msn) and irc<br />
install the following to make it work <br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-plugin-ssl_2.5.0-r0_armv4t.ipk<br />
<br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-plugin-ssl-nss_2.5.0-r0_armv4t.ipk<br />
<br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-plugin-ssl-gnutls_2.5.0-r0_armv4t.ipk<br />
<br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-protocol-irc_2.5.0-r0_armv4t.ipk<br />
<br />
=== История изменений ===<br />
==== version 20080927 ====<br />
* added up to 29 games including kobodeluxe<br />
* added pythm -> python gtk mplayer frontend<br />
* added FDSubmenu-> a Fat and Dirty first aproach to have submenus<br />
* updated orrery 2.0 -> now with zoom feature<br />
* arrange some icons<br />
* fixed the sound out when suspend<br />
<br />
==== version 20080925 ====<br />
* based on 2008.9<br />
* added nano -> Terminal text editor<br />
* added navit -> Car navigation system with routing engine<br />
* added Duke Nukem 3D -> Legendary first person shooter game. more information: [[Games#Duke_Nukem_3D]]<br />
* added Linphone -> VoIP client<br />
* added Pidgin msn and yahoo plugins<br />
* added jalimo with javaSE and javaME<br />
* opkg update/upgrade make today<br />
<br />
==== version 20080913 ====<br />
* added Pidgin -> Instant Messaging multiprotocol, installed with plugins for irc and xppm/googletalk. More plugins are avaible on the amstrong repository. There are some gtk gliches, but messaging is functionally usable.<br />
* added Remoko -> PC remote controler via bluetooth, with gestures it's easy to look like one is performing black magic conjurations, I recommend to train gestures with more subtle moviments ;)<br />
* added Thomas B. <tommy.b at gmx dot net> illume Raster's keyboard Numbers splitted version-> my wrong pin entries has decreased sensible. Thanks, Thomas !<br />
* omview e17 theme applied<br />
* opkg update/upgrade make today<br />
<br />
==== version 20080909 ====<br />
* Some 20080805 bugs eliminated<br />
* opkg update/upgrade make today<br />
<br />
==== version 20080905 ====<br />
<br />
===== Installed graphical applications =====<br />
<br />
* Default apps from OM2008.08-updates excluding Locations<br />
* qtopia-phone-x11-datebook<br />
* qtopia-phone-x11-mediaplayer (not tested yet)<br />
* Raster's Illume keyboard with qwerty button and configuration wrench<br />
* tap/untap -> silly script to landscape/portrait screen switch<br />
* numptyphysics -> addictive game<br />
* openmoko-terminal2 <br />
* tangogps -> configured to use Google Maps<br />
* Mofi-> wifi assistant<br />
* omview-> image viewer<br />
* orrery-> Stelar maps of the sky GPS capable<br />
* services -> GPRS and GSM control. You must reconfigure the GPRS scripts for your data-provider. Search the wiki or lists for more information.<br />
* agps-ui-> GPS testing<br />
* minimo-> web browser<br />
* gestures<br />
<br />
===== Installed terminal-based applications =====<br />
* joe<br />
* mplayer<br />
* tapuntap<br />
<br />
===== Дополнительные исправления =====<br />
* fixed qte-illume keyboard fights (here illume wins :) )<br />
* fixed pygtk<br />
* fixed gtk2 theme<br />
* Used packages from angstrom repository, but without adding it to the feeds, dependencies solved manually<br />
<br />
=== Roadmap ===<br />
* some method to add submenus ->I was thinking about some simply pygtk .desktop reader that can read a dir passed by parameter and shows an scrollable list of buttons, more sofistications later <br />
* Duke Nukem 3d<br />
* Spanish Dictionary <br />
* Tango look<br />
* Navit-> route solver<br />
<br />
=== Внешние ссылки ===<br />
Some people talking about us ;) thanks a lot <br />
<br />
http://openmoko-fr.org/blog/index.php?post/2008/09/16/Test-de-FDOM (FR)<br />
<br />
http://www.bunix.de/key/personal-blog/blog_id/533.htm (DE)<br />
<br />
http://community.livejournal.com/ru_openmoko/6577.html (RU)<br />
<br />
[[category:Distributions]]</div>Kostigoffhttp://openmoko.org/wiki/FDOM_-_a_Fat_and_Dirty_OM_based_distribution/ruFDOM - a Fat and Dirty OM based distribution/ru2008-12-11T20:02:13Z<p>Kostigoff: /* Описание */</p>
<hr />
<div>{{Languages|FDOM_-_a_Fat_and_Dirty_OM_based_distribution}}<br />
=== Описание ===<br />
Это комбинация приложений и демонстрация возможностей Freerunner и функциональный телефон. Все получено из официальных рпозитарев.<br />
<br />
Любые вопросы могут быть посланы на dsamblas at gmail dot com<br />
или в комунтити форуме или local-openmoko-spain list<br />
<br />
Смотри [[Development_resources#Mailing_Lists|mailing lists]]<br />
<br />
David-Reyes Samblas Martinez<br />
<br />
Co Admins<br />
Armin ranjbar aka zoup<br />
Nacho Seijo aka himero<br />
<br />
=== Скачать ===<br />
Download from http://compartida.net/openmoko/FDOM .<br />
* Note: Use '''wget -c''' to retrieve the files, because the server seems to cut the connection time to time. Do check the md5 hashes of the files after downloading to prevent any problems. or try one of the mirrors<br />
* Mirrors:<br />
** http://files.tdobson.net/openmoko/freerunner/fdom/<br />
*** Mirror admin contact: www.tdobson.net/contact<br />
** http://openmoko.truebox.co.uk/mirror/compartida.net/<br />
<br />
=== Development ===<br />
I you want to come to the script kidding party :) join us at <br />
<br />
http://projects.openmoko.org/projects/fdom/<br />
<br />
Serious developers are welcome too :) but remember "if it's cool, it works(in some way),doesn't annoying(too much) rest of things and fits on the nand it's in" :) we will let scalability, stability, resource saving and so on to the OM guys :) <br />
<br />
=== Предупреждение ===<br />
* If after an opkg update/upgrade dialer, contacts and other qtopia-x11 apps don't work and qpe shows an error window you should check whether the startup file is executable, or revert changes.<br />
<br />
The following adds permissions of '''r'''ead and e'''x'''ecution to the qtopia startup session file:<br />
# chmod a+rx /etc/X11/Xsession.d/89qtopia<br />
<br />
The following reverts last change to the qtopia startup session file:<br />
# cp /etc/X11/Xsession.d/89qtopia.bk~ /etc/X11/Xsession.d/89qtopia<br />
<br />
Теперь перегрузитесь neo.<br />
<br />
==== Обновление от 15 Сентября ====<br />
* It seems that there were major updates today that caused dialer to not work , It does happen when you click on dialer and it does exit with Enlightenment error , qucik fix to this is <br />
<br />
# ln /opt/Qtopia/bin/qcop /usr/bin/qcop -s<br />
<br />
but i believe adding /opt/Qtopia/bin to global system path is better solution (How?).<br />
<br />
==== 20080927 and Pidgin ====<br />
* I forget to install the following packages to enable ssl (needed by msn) and irc<br />
install the following to make it work <br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-plugin-ssl_2.5.0-r0_armv4t.ipk<br />
<br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-plugin-ssl-nss_2.5.0-r0_armv4t.ipk<br />
<br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-plugin-ssl-gnutls_2.5.0-r0_armv4t.ipk<br />
<br />
opkg -force-depends install http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv4t/base/libpurple-protocol-irc_2.5.0-r0_armv4t.ipk<br />
<br />
=== История изменений ===<br />
==== version 20080927 ====<br />
* added up to 29 games including kobodeluxe<br />
* added pythm -> python gtk mplayer frontend<br />
* added FDSubmenu-> a Fat and Dirty first aproach to have submenus<br />
* updated orrery 2.0 -> now with zoom feature<br />
* arrange some icons<br />
* fixed the sound out when suspend<br />
<br />
==== version 20080925 ====<br />
* based on 2008.9<br />
* added nano -> Terminal text editor<br />
* added navit -> Car navigation system with routing engine<br />
* added Duke Nukem 3D -> Legendary first person shooter game. more information: [[Games#Duke_Nukem_3D]]<br />
* added Linphone -> VoIP client<br />
* added Pidgin msn and yahoo plugins<br />
* added jalimo with javaSE and javaME<br />
* opkg update/upgrade make today<br />
<br />
==== version 20080913 ====<br />
* added Pidgin -> Instant Messaging multiprotocol, installed with plugins for irc and xppm/googletalk. More plugins are avaible on the amstrong repository. There are some gtk gliches, but messaging is functionally usable.<br />
* added Remoko -> PC remote controler via bluetooth, with gestures it's easy to look like one is performing black magic conjurations, I recommend to train gestures with more subtle moviments ;)<br />
* added Thomas B. <tommy.b at gmx dot net> illume Raster's keyboard Numbers splitted version-> my wrong pin entries has decreased sensible. Thanks, Thomas !<br />
* omview e17 theme applied<br />
* opkg update/upgrade make today<br />
<br />
==== version 20080909 ====<br />
* Some 20080805 bugs eliminated<br />
* opkg update/upgrade make today<br />
<br />
==== version 20080905 ====<br />
<br />
===== Installed graphical applications =====<br />
<br />
* Default apps from OM2008.08-updates excluding Locations<br />
* qtopia-phone-x11-datebook<br />
* qtopia-phone-x11-mediaplayer (not tested yet)<br />
* Raster's Illume keyboard with qwerty button and configuration wrench<br />
* tap/untap -> silly script to landscape/portrait screen switch<br />
* numptyphysics -> addictive game<br />
* openmoko-terminal2 <br />
* tangogps -> configured to use Google Maps<br />
* Mofi-> wifi assistant<br />
* omview-> image viewer<br />
* orrery-> Stelar maps of the sky GPS capable<br />
* services -> GPRS and GSM control. You must reconfigure the GPRS scripts for your data-provider. Search the wiki or lists for more information.<br />
* agps-ui-> GPS testing<br />
* minimo-> web browser<br />
* gestures<br />
<br />
===== Installed terminal-based applications =====<br />
* joe<br />
* mplayer<br />
* tapuntap<br />
<br />
===== Дополнительные исправления =====<br />
* fixed qte-illume keyboard fights (here illume wins :) )<br />
* fixed pygtk<br />
* fixed gtk2 theme<br />
* Used packages from angstrom repository, but without adding it to the feeds, dependencies solved manually<br />
<br />
=== Roadmap ===<br />
* some method to add submenus ->I was thinking about some simply pygtk .desktop reader that can read a dir passed by parameter and shows an scrollable list of buttons, more sofistications later <br />
* Duke Nukem 3d<br />
* Spanish Dictionary <br />
* Tango look<br />
* Navit-> route solver<br />
<br />
=== Внешние ссылки ===<br />
Some people talking about us ;) thanks a lot <br />
<br />
http://openmoko-fr.org/blog/index.php?post/2008/09/16/Test-de-FDOM (FR)<br />
<br />
http://www.bunix.de/key/personal-blog/blog_id/533.htm (DE)<br />
<br />
http://community.livejournal.com/ru_openmoko/6577.html (RU)<br />
<br />
[[category:Distributions]]</div>Kostigoffhttp://openmoko.org/wiki/Hacking_the_UI_(Om_2008)Hacking the UI (Om 2008)2008-12-10T20:45:08Z<p>Kostigoff: /* Modifying */</p>
<hr />
<div>This guide will cover modifying the main screen of the [[Om_2008.8]] distribution and related ([[FDOM]] etc).<br />
<br />
{{Todo|Merge with [[Customize Application Icons]]. [[User:MinhHaDuong|MinhHaDuong]] 07:31, 27 October 2008 (UTC)}}<br />
<br />
==Home screen==<br />
===Modifying===<br />
Icon files are located under /usr/share/pixmaps.<br />
<br />
.png extension is assumed<br />
<br />
Any .desktop file placed in /usr/share/applications will appear on the home screen.<br />
<br />
Example:<br />
<pre><br />
[Desktop Entry]<br />
Encoding=UTF-8<br />
Name=INSTALLER<br />
TryExec=assassin<br />
GenericName=Installer<br />
Comment=Assassin Openmoko Installer<br />
StartupNotify=false<br />
Exec=assassin<br />
Icon=assassin<br />
Terminal=false<br />
Type=Application<br />
Categories=PackageManager;System;Settings;Bar;<br />
</pre><br />
<br />
===Set icons to appear in the low menu===<br />
In the above example, 'Bar;' indicates that the item will appear in the bottom menu where 'INSTALLER' sits as default. Add 'Bar;' to 'Categories' for it to appear here.<br />
<br />
==See also==<br />
<br />
* [[Themes]]<br />
* [[Edje]]<br />
<br />
[[Category:Settings]]</div>Kostigoffhttp://openmoko.org/wiki/Customize_Application_IconsCustomize Application Icons2008-12-10T20:44:21Z<p>Kostigoff: /* FSO and OM 2008.8 */</p>
<hr />
<div>This guide briefly describes how you can customize the application icons shown on the home screen.<br />
<br />
<br />
{{Todo|Merge with [[Hacking the UI]]. [[User:MinhHaDuong|MinhHaDuong]] 07:31, 27 October 2008 (UTC)}}<br />
<br />
= FSO and OM 2008.8 =<br />
At FSO application icons are stored below ''/usr/share/pixmaps/''. Those icons are just little image files ou might already know from your PC desktop. To avoid scaling the images should be of 64x64 pixels.<br />
The icons are referenced by the <tt>.desktop</tt> files in ''/usr/share/applications/''.<br />
<br />
Assume the following shortened example file ''/usr/share/applications/my-app.desktop'' which provides a clickable icon on your phones home screen:<br />
<pre><br />
[Desktop Entry]<br />
...<br />
Icon=my-icon<br />
...<br />
</pre><br />
<br />
This desktop entry references an image "my-icon" which, because of the missing full path and extension, causes the desktop to search for image files below its stndard search path. this will find the icon file ''/usr/share/applications/my-icon.png''.<br />
<br />
You can also provide a full path, for example:<br />
Icon=/home/root/my-icon.png<br />
<br />
= Icon sources =<br />
<br />
Where can I find Free icons ?<br />
* http://www.kde-look.org/<br />
* http://www.gnome-look.org/<br />
* http://commons.wikimedia.org/wiki/Comparison_of_icon_sets<br />
* http://commons.wikimedia.org/wiki/Category:Icons<br />
* http://commons.wikimedia.org/wiki/Tango_icons#Phones_.2F_PDAs has OpenMoko device icons<br />
* http://www.smashingmagazine.com/2008/03/06/35-really-incredible-free-icon-sets/<br />
* http://www.maxpower.ca/free-icons/2006/03/05/<br />
<br />
Yeah, but where can I find Free icons sets, 64x64px png, designed for 250dpi for smartphone functions ?<br />
* Maybe someone will do http://www.openmoko-look.org someday ?<br />
<br />
[[Category:Advanced End User]]<br />
[[Category:Settings]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-10T20:28:01Z<p>Kostigoff: /* Debian, Ubuntu and others */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
<tt>/usr/local/etc/devd/cdce.conf</tt> as:<br />
<br />
<pre><br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
</pre><br />
<br />
and <tt>/usr/local/etc/devd/cdce.sh</tt> as:<br />
<br />
<pre><br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
</pre><br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
) &<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
;Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
<pre><br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
</pre><br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
<pre><br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
</pre><br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
<br />
<tt><br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
</tt><br />
<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-10T20:27:01Z<p>Kostigoff: /* Debian, Ubuntu and others */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
<tt>/usr/local/etc/devd/cdce.conf</tt> as:<br />
<br />
<pre><br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
</pre><br />
<br />
and <tt>/usr/local/etc/devd/cdce.sh</tt> as:<br />
<br />
<pre><br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
</pre><br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
) &<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
<pre><br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
</pre><br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
<pre><br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
</pre><br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
<br />
<tt><br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
</tt><br />
<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-10T20:26:12Z<p>Kostigoff: /* Mandriva */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
<tt>/usr/local/etc/devd/cdce.conf</tt> as:<br />
<br />
<pre><br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
</pre><br />
<br />
and <tt>/usr/local/etc/devd/cdce.sh</tt> as:<br />
<br />
<pre><br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
</pre><br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
<pre><br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
</pre><br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
<pre><br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
</pre><br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
<br />
<tt><br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
</tt><br />
<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-10T17:53:09Z<p>Kostigoff: /* GUI on desktop through SSH */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
<tt>/usr/local/etc/devd/cdce.conf</tt> as:<br />
<br />
<pre><br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
</pre><br />
<br />
and <tt>/usr/local/etc/devd/cdce.sh</tt> as:<br />
<br />
<pre><br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
</pre><br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
<br />
<tt><br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
</tt><br />
<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-10T17:51:02Z<p>Kostigoff: /* SuSE */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
<tt>/usr/local/etc/devd/cdce.conf</tt> as:<br />
<br />
<pre><br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
</pre><br />
<br />
and <tt>/usr/local/etc/devd/cdce.sh</tt> as:<br />
<br />
<pre><br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
</pre><br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/User:KostigoffUser:Kostigoff2008-12-10T05:31:55Z<p>Kostigoff: New page: Sergei Kostigoff Skills: x86asm,C,Pascal,GNU/Linux Location: Russia, Moscow www: http://www.kostigoff.net (mainly in English)</p>
<hr />
<div>Sergei Kostigoff<br />
<br />
Skills: x86asm,C,Pascal,GNU/Linux<br />
<br />
Location: Russia, Moscow<br />
<br />
www: http://www.kostigoff.net (mainly in English)</div>Kostigoffhttp://openmoko.org/wiki/Openmoko_Local_Groups:_MoscowOpenmoko Local Groups: Moscow2008-12-10T05:28:54Z<p>Kostigoff: /* Possible Participants */</p>
<hr />
<div>=== Possible Participants ===<br />
{|border=1<br />
!Name<br />
!Skills<br />
!Level of Interest<br />
!Other<br />
!Has Device<br />
!Has Debug Board<br />
|-<br />
|[[User:Shadowjack|Shadowjack]]<br />
|C, C++, Linux, GPS<br />
|High<br />
|<br />
|<br />
|<br />
|-<br />
|[[User:Denizzz|Denizzz]]<br />
|C, C++, Linux, GPS<br />
|High<br />
|<br />
|<br />
|<br />
|-<br />
|[[User:BasilK|BasilK]]<br />
|C, C++, Linux, GPS<br />
|High<br />
|<br />
|<br />
|[[Image: MokoBox.jpg|center]]<br />
|-<br />
|[[User:Vc24|vc24]]<br />
|C, C++, Linux<br />
|High<br />
|<br />
| GTA01<br />
|<br />
|-<br />
|[[User:Shallburn|Shallburn]]<br />
|C,OCaml,Scheme,Linux<br />
|Middle<br />
|<br />
|<br />
|<br />
|-<br />
|[[User:Kayo|Kayo]]<br />
|C++, Lua, Python, GNU/Linux<br />
|High<br />
|<br />
|<br />
|<br />
|-<br />
|[[User:yoush|yoush]]<br />
|C/C++, Linux kernel hacker, Debian Developer<br />
|High<br />
|<br />
|<br />
|<br />
|-<br />
|[[User:GreyCardinal|GreyCardinal]]<br />
|C/C++, Linux kernel hacker, Debian Developer<br />
|High<br />
|<br />
|GTA02v5<br />
|<br />
|-<br />
|[[User:SR|SR]]<br />
|C, C++, GNU/Linux<br />
|High<br />
|<br />
|GTA02v6<br />
|Yes<br />
|-<br />
|[[User:Narmo|Narmo]]<br />
|C, C++, GNU/Linux, Objective-C<br />
|High<br />
|<br />
|[[Image:Moko.jpg|center]]<br />
|<br />
|-<br />
|[[User:Anv|Anv]]<br />
|C, C++, GNU/Linux, Python<br />
|High<br />
|<br />
|[[Image:Moko.jpg|center]]<br />
|<br />
|-<br />
|[[User:kostigoff|kostigoff]]<br />
|x86asm,C,Pascal,GNU/Linux<br />
|High<br />
|<br />
|[[Image:Moko.jpg|center]]<br />
|Yes<br />
<br />
|-|}<br />
<br />
[[Category:Openmoko Local Groups]]</div>Kostigoffhttp://openmoko.org/wiki/Getting_Started_with_your_Neo_FreeRunnerGetting Started with your Neo FreeRunner2008-12-09T18:51:15Z<p>Kostigoff: /* Update with the package manager */</p>
<hr />
<div>{{Languages|Getting Started with your Neo FreeRunner}}<br />
<br />
{| class="wikitable" cellspacing="2" cellpadding="2" style="padding: 0%; margin:0em 0em 1em 0em; background:#eeeeee; width:100%;floating="center"; "<br />
! style="background:#fcfcfc; width:75% " |<br />
<p align="left"><br />
Thank you for purchasing this Developer release of Neo FreeRunner. The [[Neo FreeRunner]] phone is the second hardware platform to take advantage of Openmoko. This guide will help you get to know your Neo FreeRunner and how to start using your Neo FreeRunner.</p><br />
<br />
<p align="left"><br />
Some Frequently Asked Questions for new owners are featured in the [[FAQ#Getting_Started_with_your_Neo_FreeRunner]].<br />
</p><br />
<br />
! style="background:#fcfcfc; width:25% " |<br />
[[Image:Freerunner box.png|200px|thumb|Neo FreeRunner Package]]<br />
|}<br />
{{Neo FreeRunner Menu}}<br />
<br />
== Package Contents ==<br />
<br />
[[Image:GTA02ALL.png|left|400px|thumb|Inside the package]]<br />
<br /><br />
: [[Image:Circle2.gif|10px]] Neo FreeRunner<br />
: [[Image:Circle2.gif|10px]] Stylus<br />
: [[Image:Circle2.gif|10px]] Battery<br />
: [[Image:Circle2.gif|10px]] Charger<br />
: [[Image:Circle2.gif|10px]] USB Cable (A -> Mini-B 5-pole)<br />
: [[Image:Circle2.gif|10px]] microSD Card 512MB & SD adapter<br />
: [[Image:Circle2.gif|10px]] [[Thank You green card]]<br />
<div style="clear: both">&nbsp;</div><br />
<br />
== Get the source code == <br />
The software included in this product contains copyrighted software that is licensed under the [http://downloads.openmoko.org/sources/Om2008.9-Lite.iso GPL]. A complete corresponding source code or CD-ROM ISO image with the GPL license is available for download [http://downloads.openmoko.org/sources/Om2008.9-Lite.iso here]. You may also obtain the same corresponding CD-ROM by sending a money order or check for $10 to any one of our [http://downloads.openmoko.org/sources/Om2008.9-Lite.iso distributors].<br />
<br />
Please write “source for Neo FreeRunner ” in the memo line of your payment.<br />
<br />
== Setting up the hardware, getting to know the Neo FreeRunner physically ==<br />
<br />
===Installing the Micro-SD card, the SIM card, and the Battery ===<br />
<br />
<div align-center><br />
<table width="80%" style="clear: both; border: 1px solid #ffffff; border-collapse: collapse; padding: 0.2em; margin: 0; font-size: 100%; margin: 0 1px;"><br />
<tr valign="top" style="background: #ffffff"><br />
<td style="width: 50%; white-space: nowrap; padding: 4px 1em 0 0.5em; border-right: 1px solid #ffffff;">[[Image:menu13.jpg|233px|thumb|Open the case like this.|center]]</td><br />
<td style="padding: 1px 1em 0; background: #ffffff;">[[Image:menu14.jpg|250px|thumb|Opening !|center]]</td><br />
</tr><br />
<tr valign="top" style="background: #ffffff"><br />
<td style="padding: 1px 1em 0; background: #ffffff;">[[Image:menu11.jpg|260px|thumb|Put the SIM card and SD card here.|center]]</td><br />
<td style="width: 50%; white-space: nowrap; padding: 4px 1em 0 0.5em; border-right: 1px solid #ffffff;">[[Image:menu12.jpg|233px|thumb|Finally, put in the battery.|center]]</td><br />
</tr></table><br />
</div><br />
<br />
<br />
# Remove the rear cover of the Neo FreeRunner by first holding the Neo FreeRunner on the side and then use your fingernail to prise off the rear cover at the slot on top of the device.<br />
# Now you should be able to locate the combined SIM and Micro-SD card holder at the bottom of the battery compartment.<br />
# Unlock the SIM card holder by sliding the metal clip down, towards the USB socket, with your fingernail. Use caution, as these parts are delicate and could be damaged by forcing them in the wrong direction.<br />
# Lift up on the SIM card holder.<br />
# The Micro-SD card holder is held in place by a latch on either side. It is easiest to open the Micro-SD card holder by releasing these latches one at a time rather than by lifting from the middle, as lifting from the middle tends to increase the latching pressure. A small screwdriver or knife can be used for this.<br />
# Insert the Micro-SD card into the Micro-SD card holder. Note that on the inside of metal part of the holder there are little holding tabs for the card. Slide the card in these holders (on the metal part) before closing the card holder. Note that the electrical contacts should face down and towards the edge of the Neo FreeRunner.<br />
# Close the Micro-SD card holder, making sure that both latches of the holder are securely fastened.<br />
# Insert the SIM card into the SIM card holder, taking care to slide inside the two metal tabs in the cover. Note that the electrical contacts should face down and that the cut corner should be closest to the external GPS Antenna Socket.<br />
# Close the SIM card holder and lock it by sliding the metal clip towards the external GPS Antenna Socket on the FreeRunner.<br />
# Insert the battery into the battery compartment, aligning the electrical contacts on the battery with the electrical contacts in the battery compartment. Insert the side with the electrical contacts first.<br />
# Replace the rear cover on the FreeRunner.<br />
<br />
[[Image:FR_SIM_SD_open.jpg|457px|thumb|SIM and SD holders open, with cards in place|center]]<br />
<br />
[[http://video.google.de/videoplay?docid=-8343770443102960945 A short video]] is also available. It was shot using the previous version of the Neo, but the installation procedures remains the same.<br />
<br />
===Charging the Neo FreeRunner===<br />
<br />
Before using the Neo FreeRunner for the first time, you should charge the battery completely. The battery can be charged using the provided charger at 1000mA or from a powered USB port capable of providing 500mA worth of current. Most computers will be able to charge the FreeRunner without any problems.<br />
<br />
Neo FreeRunner does NOT charge when powered off, so be sure to turn it on and allow it to boot all the way to the GUI (Graphical User Interface). This should happen automatically when you plug in USB power, either from a computer or the provided charger.<br />
<br />
Although the provided charger is rated at 2A, the maximum charge rate of the Neo FreeRunner is 1A, and thus the charge rate with the charger is less than the charger capacity.<br />
<br />
The provided charger includes three "national" plugs. The default is North America, with alternative U.K (3 square pins) and Euro (two round pins) adapters. To install the alternative power adapters, depress the latch in the cover (on the opposite side of the charger from the product information label) and slide the cover outward. Note that the two North American pins do not come out; the other adapters slide over them, and snap into place. The two-pin Euro adapter is removed in the same way as the cover. The three-pin U.K. adapter is removed by '''gently''' pressing the dummy ground pin (black) '''toward the end of the adapter with the cord''' and then sliding it off the adapter.<br />
<br />
Charging an empty battery at 100mA takes 12~15 hours, at 500mA takes 2,5~3,5 hours, and at 1000mA takes 1.5~2.5 hours. (90%~100%) [to be confirmed]<br />
<br />
IMPORTANT: See [[Neo_FreeRunner_Hardware_Issues|Neo FreeRunner Hardware Issues]] about not allowing the battery to discharge completely.<br />
<br />
===Buttons and connectors===<br />
<br />
<table width="80%" style="clear: both; border-collapse: collapse" valign="top"><br />
<tr><br />
<td style="width: 25px">&nbsp;</td><br />
<td style="width: 370px">[[Image:menu9.jpg|370px|thumb|Power Button, USB and external GPS Antenna (left to right)|center]]</td><br />
<td style="width: 25px">&nbsp;</td><br />
<td style="width: 370px">[[Image:menu8.jpg|370px|thumb|AUX Button and phone jack (left to right)|center]]</td><br />
</tr><br />
<tr><br />
<td></td><br />
<td>'''Power'''<br />
Tapping the power button exits the current application.<br />
<br />
Holding the power button brings up a menu allowing you to:<br />
* Power on and off the GPS, wifi, GSM, and bluetooth antennae<br />
* Change power management mode to:<br />
** Dim first then lock<br />
** Dim only, don't lock<br />
** Disabled<br />
* Lock the screen<br />
* Shutdown the device.</td><br />
<td></td><br />
<td>'''Aux'''<br />
Tapping the Aux button hides or shows the currently running application.<br />
<br />
Holding the Aux button brings up a menu allowing you to:<br />
<br />
* Hide and show the title bar (Fullscreen toggle)<br />
* Alternate wide or tall display modes (Swap Orientation)<br />
* Save the content of the screen as an image file (Screenshot)<br />
</td><br />
</tr><br />
</table><br />
<br />
[[Booting the Neo FreeRunner]] takes about 2 minutes overall, so patience is in order. The longest step comes after the Linux boot messages in very small fonts have scrolled by, at the graphical "openmoko" sunrise page.<br />
<br />
The phone jack is a 2.5mm connector with four contacts: stereo + MIC. It is compatible with the headsets used by Motorola smartphones (A780,A1200, ...) and the V-360.<br />
<br />
To plug regular (i.e. without microphone) headphones commonly used to listen to music, a compatible 2.5mm 4 rings jack to 3.5mm stereo jack adapter is needed. It has been reported that Nokia's 2.5mm -> 3.5mm adapters do not work, but that a 3.5mm Stereo Audio Adapter for Motorola MPx200/E398 works well, as well as the generic Radio Shack 274-004. You will also want to switch from speaker output to headset, by restoring the appropriate alsa.state-file (usually the mediaplayer should do this for you) or via alsamixer (see below), to enable stereo output in there.<br />
<br />
===Unlocking the screen===<br />
<br />
When the screen is locked, you should see a Matrix-style green graphic with the Openmoko symbol in the middle of the bottom of the screen along with lock and unlock symbols. If you drag the Openmoko symbol to the unlock symbol at the top then the screen will become unlocked.<br />
<br />
==Known Issue==<br />
<br />
Because the software changes so rapidly, you should review the current list of [[Om_2007.2#Known_Issues|known issues]].<br />
<br />
==Navigating menus and applications==<br />
<br />
''Note:'' this section describes the interface used by the "2007.2" image, which is the current default image for Openmoko. For some helpful tips on the "2008.8" image see this [[Om_2008.8_Guide]]<br />
<br />
====Today Page====<br />
<br />
[[Image:Todaypage_reduced_true.png|200px|right]] Openmoko starts by displaying the "Today" page, which is your home page. Icons in the top row indicate the status of the phone. The bottom row consists of three tabs. The tab with a house on the left leads to the "Today" page you're viewing now. The central tab leads to the "Launch Task" page, which is the main menu used to start applications. The tab with gears on the right leads to the "Running Tasks" page, which is used to deal with currently open windows and applications.<br />
<br />
<br clear=all /><br />
<br />
[[Image:Todaypage_reduced_false.png|right|200px|]] The "Today" page is empty, as shown above, when you first start Openmoko. We explain below how to turn on the "full view", displayed to the right. In the full view, a second row of icons give quick links to commonly-used applications such as the dialer, the adressbook, mailbox and calendar. The main body of the screen displays a clock and other useful information.<br />
<br />
See [[Today/2007.2]] for more information about the Today page and customization.<br />
<br />
<br clear=all /><br />
<br />
====Launch Task Page====<br />
<br />
{{stub}}<br />
<br />
[[Image:LaunchTasks.png|right|200px]] This page displays a menu of available applications. You may choose a category of applications to display to simplify the screen, or choose to display them all.<br />
<br />
Current categories are [PIM Suite], [[Om_2007.2_Applications|Applications]], [[Games/Om 2007.2|Games]], Utilities, and All.<br />
<br />
<br clear=all /><br />
<br />
====Running Tasks Page====<br />
<br />
{{stub}}<br />
<br />
[[Image:RunningTasks.png|right|200px]] This page displays currently-running tasks. Any individual task may be terminated by selecting it and then clicking on the garbage-can icon to close it. All tasks may be terminated by clicking on any one of them and then clicking on the "folder" icon in the upper right (expect this to change in future releases). Any task may be rejoined by selecting it and then selecting the "return" icon at the middle top.<br />
<br />
<br clear=all /><br />
<br />
====Exiting from and switching to an Application====<br />
<br />
Any time an application is running, you can simply click the device's power button and the application will exit, returning you to the Today page.<br />
<br />
Alternatively, you can cycle through active applications using the AUX button<br />
<br />
Clicking the top-left of the screen displays the drop down ''task menu''. This menu lists all active applications and allows to switch directly to any one. ''Note:'' If the task menu is not shown, click and hold the [[#Aux|Aux]] button to bring up the Aux menu, and select "Toggle Fullscreen".<br />
<br />
== Using the terminal ==<br />
<br />
To start a console from "Today" page, click the middle tab at the bottom of the screen to display the "Launch applications" page, then select Terminal in the "Applications" submenu. The multitaps keyboard slides up (and down) from the bottom of the screen automatically when you touch the screen.<br />
<br />
===Setting date and time===<br />
<br />
From the terminal, type the following, but replace ''MM'' with the month (01-12); ''DD'' with the day (01-31); ''hhmm'' with the time (0000-2359); ''YYYY'' with the year (optional); and ''.ss'' with the seconds (optional).<br />
<br />
date -s ''MMDDhhmmYYYY.ss''<br />
<br />
To make the change persist between reboots, sync the hardware clock with the updated system time.<br />
<br />
hwclock --systohc<br />
<br />
See [[Setting Date and Time]] for more discussion, including synchronizing with an NTP server.<br />
<br />
<br />
<br />
=== Accessing the microSD card ===<br />
<br />
Mounted at /media/card by default.<br />
<br />
If you have multiple partitions on the card, the first (/dev/mmcblk0p1) will be mounted at /media/card, the second at /media/mmcblk0p2, the third at /media/mmcblk0p3 etc. To setup the package management to write on the microSD card when installing new software follow the [[Package_management | package management guide]].<br />
<br />
== Set up USB-based networking, SSH and update ==<br />
<br />
Openmoko allows TCP/IP-over-USB networking for your phone. The main advantages of this are<br />
* You don't need to set-up GPRS or WLAN network connection for the phone software to reach the Internet<br />
* You can SSH from your computer into the phone shell and comfortably do low-level tasks using your computer's terminal software and real keyboard instead of the tiny screen and touchscreen keyboard<br />
<br />
Naturally, the phone must be connected to your computer with USB cable.<br />
<br />
===Connect with the Neo FreeRunner===<br />
<br />
This is discussed in the [[USB_Networking|USB Networking]] section.<br />
<br />
===Update with the package manager===<br />
<br />
In order to keep the FreeRunner up-to-date with the latest features and bug-fixes, it is advisable update the software at regular intervals.<br />
<br />
There are two main methods of doing this:<br />
* upgrading with the package manager '''opkg'''<br />
* or manually flashing the device (see [[Flashing the Neo FreeRunner]]).<br />
<br />
There are three layers to the software on the FreeRunner:<br />
<br />
* [[uboot|uBoot]]: Think of u-boot as a combination of the BIOS and Grub on a PC.<br />
* Kernel: The Linux kernel<br />
* Root Filesystem: The rest of the system<br />
<br />
Note that ''uboot'', the ''kernel'' and the ''root filesystem'' may all be flashed to update them. For uboot, this is the only possibility (see [[Flashing_the_Neo_FreeRunner#Flashing_the_boot_loader]]). The advantage of flashing the kernel manually rather than using opkg seems to be speed. The disadvantage of flashing the root file system is that it wipes out all local modifications, including /home. If /home is moved to the SD disk, this is no longer a problem.<br />
<br />
Warning: UPGRADING TO DAILY KERNELS FROM THE DEVELOPMENT BRANCH MAY BREAK THINGS. That said, assuming that your FreeRunner can access the internet (see above), the kernel and other packages can be updated with<br />
<br />
# opkg update<br />
# opkg -test upgrade<br />
# opkg upgrade<br />
<br />
The first updates the repository information, telling opkg what packages are available. The second allows you to see what the package manager wants to do. The third upgrades all packages for which a newer version is available. '''At the moment, some signature files are missing (404 errors), which opkg complains about, but this is cosmetic.''' The repositories will still update with the missing signature files.<br />
<br />
Important: If you have followed the Getting Started Guide this far, but opkg upgrades do not appear to be happening. Try checking the .conf files in the /etc/opkg/ directory. If you see four URLs pointing at<br />
<nowiki>http://buildhost.openmoko.org/</nowiki> , this is your problem. The 2007.2 repository has been moved to http://downloads.openmoko.org/repository/Om2007.2. Update your .conf files to point at equivalent directories under this repository, e.g.:<br />
<br />
# sed -i 's/buildhost.openmoko.org\/daily-feed/downloads.openmoko.org\/repository\/Om2007.2/' $(grep -l buildhost /etc/opkg/*.conf)<br />
<br />
Note that running opkg upgrade on a factory-fresh phone will upgrade dropbear (the ssh software) and various xserver packages, and neither upgrades elegantly while in use. Xserver must be updated over ssh to complete succesfully. Dropbear can be updated over ssh with the proper command:<br />
# nohup opkg upgrade dropbear &<br />
Or upgrade it directly in the FreeRunner terminal.<br />
# opkg upgrade dropbear<br />
<br />
When updating over ssh, the session will be interrupted, but the command should complete successfully(check nohup.out on your device to verify), and you should be able to reconnect within a few seconds.<br />
<br />
Another (better) option is to start a screen session before the upgrade with:<br />
<br />
# screen<br />
<br />
After loosing the ssh connection and login in again via ssh reconnect to the running screen session with:<br />
<br />
# screen -x<br />
<br />
Then connect to the FreeRunner via ssh and type:<br />
# opkg upgrade<br />
<br />
And run this command :<br />
# depmod<br />
<br />
Alternatively you can upgrade the xserver packages via ssh and then upgrade the rest from the FreeRunner's terminal.<br />
<br />
If you do your first upgrade in two installments like this, it will go more smoothly.<br />
<br />
It will be possible in the future to update uboot with opkg, but this has not yet been implemented.<br />
<br />
=== Installing multimedia, web browsing and other applications ===<br />
<br />
There are many applications you can install - check out the [[Repositories]] for a list of packages, an example of how to add a repository using scaredy cat as an example can also be found here. A list of pre-installed and available packages with descriptions can be found here - [[Available Packages]].<br />
<br />
The calendar can be installed with<br />
<br />
<pre><br />
opkg install openmoko-dates2<br />
</pre><br />
<br />
For a Media Player:<br />
<br />
<pre><br />
opkg install openmoko-mediaplayer2<br />
wget http://abraxa.dyndns.org:81/random/openmoko-mediaplayer-theme.tar.bz2<br />
tar xjf openmoko-mediaplayer-theme.tar.bz2 -C /usr/share/themes/Moko/gtk-2.0<br />
rm openmoko-mediaplayer-theme.tar.bz2<br />
</pre><br />
<br />
If you want a basic image viewer, have a look at the one from the gpe suite:<br />
<br />
<pre><br />
opkg install gpe-icons<br />
opkg install gpe-gallery<br />
</pre><br />
<br />
To obtain the standard web browser, use:<br />
<br />
<pre><br />
opkg install openmoko-browser2<br />
</pre><br />
<br />
An alternative browser, minimo, offers many more features.<br />
First download and unpack it on your GNU/Linux host:<br />
<br />
<pre><br />
wget http://www.ginguppin.de/files/minimo.tar.bz2<br />
tar jvxf minimo.tar.bz2<br />
</pre><br />
<br />
Copy it over to the FreeRunner:<br />
<pre><br />
scp minimo_* root@192.168.0.202:/tmp<br />
</pre><br />
<br />
Then on the FreeRunner:<br />
<pre><br />
opkg install /tmp/minimo_0.02\+cvs20070626-r0_armv4t.ipk<br />
</pre><br />
<br />
You'll probably also want to [[Switching Keyboards|change the keyboard]] including the [[Switching Keyboards#How_to_add_a_keyboard_toggle_button|keyboard toggle applet]]<br />
<br />
=== Importing contacts ===<br />
<br />
If you can export your contacts to VCard format, either multiple files or single file containing all of them, you may use the script on [[Import Vcf Contacts]] page to bring them to Neo.<br />
<br />
==The next steps==<br />
<br />
Congratulations for setting up your Neo FreeRunner. There are many more ressources to help free your phone:<br />
<br />
===Customize the interface===<br />
home screen clock, keyboard<br />
<br />
The stock [[Openmoko2007.2]] image flashed onto the Neo FreeRunner is really just the bare bones. For example, you don't have the clock and the quick-launch icons showing. Here's how you can change that:<br />
<br />
# dbus-launch gconftool-2 -t boolean -s /desktop/poky/interface/reduced false<br />
# /etc/init.d/xserver-nodm restart<br />
<br />
If you rather have a regular clock instead of the digital one, do this instead:<br />
<br />
# dbus-launch gconftool-2 -t boolean -s /desktop/poky/interface/reduced false<br />
# dbus-launch gconftool-2 -t boolean -s /desktop/poky/interface/digital_clock false<br />
# /etc/init.d/xserver-nodm restart<br />
<br />
REMOVE CLICK SOUND VIA /etc/pulse/session<br />
<br />
More information about today screen customization at [[Today/2007.2]].<br />
<br />
Also, if you prefer having a full keyboard, using matchbox's qwerty keybord, see [[Switching_Keyboards#Matchbox_keyboard|these instructions]]. Then you may also see [http://lists.openmoko.org/pipermail/community/2008-July/021296.html these], which describe a way to add an applet allowing the showing/hiding of that keyboard.<br />
<br />
===Use the GPS===<br />
<br />
Simple guide to get going with '''GPS''':<br />
<br />
# opkg install gpsd<br />
# echo "GPS_DEV=\"/dev/ttySAC1\"" > /etc/default/gpsd<br />
<br />
and restart gpsd, the gps daemon, with<br />
<br />
# /etc/init.d/gpsd restart<br />
<br />
To test GPS, you can use agpsui:<br />
<br />
# opkg install openmoko-agpsui<br />
<br />
For a nice map, try [[tangoGPS]]:<br />
<br />
# opkg install tangogps<br />
<br />
or download it from [http://www.tangogps.org/downloads/tangogps_0.9.3-r1_armv4t.ipk tangogps.org].<br />
<br />
There were critical [[GPS Problems]] earlier that are largely fixed in newest kernels, see the instructions above to install the updates. More information is on the [[GPS]] page.<br />
<br />
===Play with WLAN, GPRS and Bluetooth===<br />
<br />
There are plenty of development opportunities to integrate these functions in the Openmoko software.<br />
<br />
'''WLAN''': See [[Wireless Networking]]<br />
<br />
'''GPRS''': See [[Manually using GPRS]]<br />
<br />
'''Bluetooth''': See [[Manually using Bluetooth]]<br />
<br />
=== Testing a new distribution ===<br />
<br />
[[Om 2008.8]] is the successor to Om 2007.2 (and had ASU as a codename). It was launched on August 08, 2008. You may wish to test it or (if you feel adventurous) install it in place of the stock 2007.2 distribution you've just got to know.<br />
<br />
=== Welcome to the community ===<br />
<br />
The release of the FreeRunner in the summer 2008 has led the community into a new period of rapid growth. The resources available are summarized on the [[Openmoko:Community_Portal]]. These are always exciting and interesting times to live in when the balance between Chaos and Order tilts towards change.<br />
<br />
As an entry point, the [[http://lists.openmoko.org/pipermail/community/ openmoko community mailing list]] is perhaps the most active. As of July 2008, its volume amounts to dozens of messages per day. Openmoko people are there too. You may ask for help on the [[https://lists.openmoko.org/mailman/listinfo/support support mailing list]].<br />
<br />
Or if you use IRC, there is always a good group in the channel #openmoko on FreeNode.<br />
<br />
The links on the top-right of this page lead to the sister sites in the Openmoko community:<br />
* Home and Wiki lead to the same Main Page on the wiki. It needs cleaning, we know...<br />
* Doc leads to the bug ''Trac''king system.<br />
* Planet goes to the collection of Openmoko-relatd blogs.<br />
* Projects is the GForge, free hosting for application developers.<br />
* Lists is the listing of all the public mailing lists on lists.openmoko.org.<br />
<br />
== Annotated references ==<br />
<br />
* [[Neo FreeRunner]]. The top-level view of the specifications.<br />
* [[Neo FreeRunner GTA02 Hardware]]. The detailed specifications.<br />
* [[GTA02 Openness]]. Ultimate chip-level specifications, data sheets and hardware documentation.<br />
* [[Distributions]]. Strengths and weaknesses of the various distributions available for the Neo.<br />
* [[FAQ#Getting_Started_with_your_Neo_FreeRunner]]. Answers.<br />
<br />
To search this wiki with Google, use the following search term:<br />
<br />
<search term> site:http://wiki.openmoko.org/wiki/<br />
<br />
[[Category:Neo FreeRunner Hardware| ]]<br />
[[Category:Basic End User]]</div>Kostigoffhttp://openmoko.org/wiki/Getting_Started_with_your_Neo_FreeRunnerGetting Started with your Neo FreeRunner2008-12-09T18:46:31Z<p>Kostigoff: /* Update with the package manager */</p>
<hr />
<div>{{Languages|Getting Started with your Neo FreeRunner}}<br />
<br />
{| class="wikitable" cellspacing="2" cellpadding="2" style="padding: 0%; margin:0em 0em 1em 0em; background:#eeeeee; width:100%;floating="center"; "<br />
! style="background:#fcfcfc; width:75% " |<br />
<p align="left"><br />
Thank you for purchasing this Developer release of Neo FreeRunner. The [[Neo FreeRunner]] phone is the second hardware platform to take advantage of Openmoko. This guide will help you get to know your Neo FreeRunner and how to start using your Neo FreeRunner.</p><br />
<br />
<p align="left"><br />
Some Frequently Asked Questions for new owners are featured in the [[FAQ#Getting_Started_with_your_Neo_FreeRunner]].<br />
</p><br />
<br />
! style="background:#fcfcfc; width:25% " |<br />
[[Image:Freerunner box.png|200px|thumb|Neo FreeRunner Package]]<br />
|}<br />
{{Neo FreeRunner Menu}}<br />
<br />
== Package Contents ==<br />
<br />
[[Image:GTA02ALL.png|left|400px|thumb|Inside the package]]<br />
<br /><br />
: [[Image:Circle2.gif|10px]] Neo FreeRunner<br />
: [[Image:Circle2.gif|10px]] Stylus<br />
: [[Image:Circle2.gif|10px]] Battery<br />
: [[Image:Circle2.gif|10px]] Charger<br />
: [[Image:Circle2.gif|10px]] USB Cable (A -> Mini-B 5-pole)<br />
: [[Image:Circle2.gif|10px]] microSD Card 512MB & SD adapter<br />
: [[Image:Circle2.gif|10px]] [[Thank You green card]]<br />
<div style="clear: both">&nbsp;</div><br />
<br />
== Get the source code == <br />
The software included in this product contains copyrighted software that is licensed under the [http://downloads.openmoko.org/sources/Om2008.9-Lite.iso GPL]. A complete corresponding source code or CD-ROM ISO image with the GPL license is available for download [http://downloads.openmoko.org/sources/Om2008.9-Lite.iso here]. You may also obtain the same corresponding CD-ROM by sending a money order or check for $10 to any one of our [http://downloads.openmoko.org/sources/Om2008.9-Lite.iso distributors].<br />
<br />
Please write “source for Neo FreeRunner ” in the memo line of your payment.<br />
<br />
== Setting up the hardware, getting to know the Neo FreeRunner physically ==<br />
<br />
===Installing the Micro-SD card, the SIM card, and the Battery ===<br />
<br />
<div align-center><br />
<table width="80%" style="clear: both; border: 1px solid #ffffff; border-collapse: collapse; padding: 0.2em; margin: 0; font-size: 100%; margin: 0 1px;"><br />
<tr valign="top" style="background: #ffffff"><br />
<td style="width: 50%; white-space: nowrap; padding: 4px 1em 0 0.5em; border-right: 1px solid #ffffff;">[[Image:menu13.jpg|233px|thumb|Open the case like this.|center]]</td><br />
<td style="padding: 1px 1em 0; background: #ffffff;">[[Image:menu14.jpg|250px|thumb|Opening !|center]]</td><br />
</tr><br />
<tr valign="top" style="background: #ffffff"><br />
<td style="padding: 1px 1em 0; background: #ffffff;">[[Image:menu11.jpg|260px|thumb|Put the SIM card and SD card here.|center]]</td><br />
<td style="width: 50%; white-space: nowrap; padding: 4px 1em 0 0.5em; border-right: 1px solid #ffffff;">[[Image:menu12.jpg|233px|thumb|Finally, put in the battery.|center]]</td><br />
</tr></table><br />
</div><br />
<br />
<br />
# Remove the rear cover of the Neo FreeRunner by first holding the Neo FreeRunner on the side and then use your fingernail to prise off the rear cover at the slot on top of the device.<br />
# Now you should be able to locate the combined SIM and Micro-SD card holder at the bottom of the battery compartment.<br />
# Unlock the SIM card holder by sliding the metal clip down, towards the USB socket, with your fingernail. Use caution, as these parts are delicate and could be damaged by forcing them in the wrong direction.<br />
# Lift up on the SIM card holder.<br />
# The Micro-SD card holder is held in place by a latch on either side. It is easiest to open the Micro-SD card holder by releasing these latches one at a time rather than by lifting from the middle, as lifting from the middle tends to increase the latching pressure. A small screwdriver or knife can be used for this.<br />
# Insert the Micro-SD card into the Micro-SD card holder. Note that on the inside of metal part of the holder there are little holding tabs for the card. Slide the card in these holders (on the metal part) before closing the card holder. Note that the electrical contacts should face down and towards the edge of the Neo FreeRunner.<br />
# Close the Micro-SD card holder, making sure that both latches of the holder are securely fastened.<br />
# Insert the SIM card into the SIM card holder, taking care to slide inside the two metal tabs in the cover. Note that the electrical contacts should face down and that the cut corner should be closest to the external GPS Antenna Socket.<br />
# Close the SIM card holder and lock it by sliding the metal clip towards the external GPS Antenna Socket on the FreeRunner.<br />
# Insert the battery into the battery compartment, aligning the electrical contacts on the battery with the electrical contacts in the battery compartment. Insert the side with the electrical contacts first.<br />
# Replace the rear cover on the FreeRunner.<br />
<br />
[[Image:FR_SIM_SD_open.jpg|457px|thumb|SIM and SD holders open, with cards in place|center]]<br />
<br />
[[http://video.google.de/videoplay?docid=-8343770443102960945 A short video]] is also available. It was shot using the previous version of the Neo, but the installation procedures remains the same.<br />
<br />
===Charging the Neo FreeRunner===<br />
<br />
Before using the Neo FreeRunner for the first time, you should charge the battery completely. The battery can be charged using the provided charger at 1000mA or from a powered USB port capable of providing 500mA worth of current. Most computers will be able to charge the FreeRunner without any problems.<br />
<br />
Neo FreeRunner does NOT charge when powered off, so be sure to turn it on and allow it to boot all the way to the GUI (Graphical User Interface). This should happen automatically when you plug in USB power, either from a computer or the provided charger.<br />
<br />
Although the provided charger is rated at 2A, the maximum charge rate of the Neo FreeRunner is 1A, and thus the charge rate with the charger is less than the charger capacity.<br />
<br />
The provided charger includes three "national" plugs. The default is North America, with alternative U.K (3 square pins) and Euro (two round pins) adapters. To install the alternative power adapters, depress the latch in the cover (on the opposite side of the charger from the product information label) and slide the cover outward. Note that the two North American pins do not come out; the other adapters slide over them, and snap into place. The two-pin Euro adapter is removed in the same way as the cover. The three-pin U.K. adapter is removed by '''gently''' pressing the dummy ground pin (black) '''toward the end of the adapter with the cord''' and then sliding it off the adapter.<br />
<br />
Charging an empty battery at 100mA takes 12~15 hours, at 500mA takes 2,5~3,5 hours, and at 1000mA takes 1.5~2.5 hours. (90%~100%) [to be confirmed]<br />
<br />
IMPORTANT: See [[Neo_FreeRunner_Hardware_Issues|Neo FreeRunner Hardware Issues]] about not allowing the battery to discharge completely.<br />
<br />
===Buttons and connectors===<br />
<br />
<table width="80%" style="clear: both; border-collapse: collapse" valign="top"><br />
<tr><br />
<td style="width: 25px">&nbsp;</td><br />
<td style="width: 370px">[[Image:menu9.jpg|370px|thumb|Power Button, USB and external GPS Antenna (left to right)|center]]</td><br />
<td style="width: 25px">&nbsp;</td><br />
<td style="width: 370px">[[Image:menu8.jpg|370px|thumb|AUX Button and phone jack (left to right)|center]]</td><br />
</tr><br />
<tr><br />
<td></td><br />
<td>'''Power'''<br />
Tapping the power button exits the current application.<br />
<br />
Holding the power button brings up a menu allowing you to:<br />
* Power on and off the GPS, wifi, GSM, and bluetooth antennae<br />
* Change power management mode to:<br />
** Dim first then lock<br />
** Dim only, don't lock<br />
** Disabled<br />
* Lock the screen<br />
* Shutdown the device.</td><br />
<td></td><br />
<td>'''Aux'''<br />
Tapping the Aux button hides or shows the currently running application.<br />
<br />
Holding the Aux button brings up a menu allowing you to:<br />
<br />
* Hide and show the title bar (Fullscreen toggle)<br />
* Alternate wide or tall display modes (Swap Orientation)<br />
* Save the content of the screen as an image file (Screenshot)<br />
</td><br />
</tr><br />
</table><br />
<br />
[[Booting the Neo FreeRunner]] takes about 2 minutes overall, so patience is in order. The longest step comes after the Linux boot messages in very small fonts have scrolled by, at the graphical "openmoko" sunrise page.<br />
<br />
The phone jack is a 2.5mm connector with four contacts: stereo + MIC. It is compatible with the headsets used by Motorola smartphones (A780,A1200, ...) and the V-360.<br />
<br />
To plug regular (i.e. without microphone) headphones commonly used to listen to music, a compatible 2.5mm 4 rings jack to 3.5mm stereo jack adapter is needed. It has been reported that Nokia's 2.5mm -> 3.5mm adapters do not work, but that a 3.5mm Stereo Audio Adapter for Motorola MPx200/E398 works well, as well as the generic Radio Shack 274-004. You will also want to switch from speaker output to headset, by restoring the appropriate alsa.state-file (usually the mediaplayer should do this for you) or via alsamixer (see below), to enable stereo output in there.<br />
<br />
===Unlocking the screen===<br />
<br />
When the screen is locked, you should see a Matrix-style green graphic with the Openmoko symbol in the middle of the bottom of the screen along with lock and unlock symbols. If you drag the Openmoko symbol to the unlock symbol at the top then the screen will become unlocked.<br />
<br />
==Known Issue==<br />
<br />
Because the software changes so rapidly, you should review the current list of [[Om_2007.2#Known_Issues|known issues]].<br />
<br />
==Navigating menus and applications==<br />
<br />
''Note:'' this section describes the interface used by the "2007.2" image, which is the current default image for Openmoko. For some helpful tips on the "2008.8" image see this [[Om_2008.8_Guide]]<br />
<br />
====Today Page====<br />
<br />
[[Image:Todaypage_reduced_true.png|200px|right]] Openmoko starts by displaying the "Today" page, which is your home page. Icons in the top row indicate the status of the phone. The bottom row consists of three tabs. The tab with a house on the left leads to the "Today" page you're viewing now. The central tab leads to the "Launch Task" page, which is the main menu used to start applications. The tab with gears on the right leads to the "Running Tasks" page, which is used to deal with currently open windows and applications.<br />
<br />
<br clear=all /><br />
<br />
[[Image:Todaypage_reduced_false.png|right|200px|]] The "Today" page is empty, as shown above, when you first start Openmoko. We explain below how to turn on the "full view", displayed to the right. In the full view, a second row of icons give quick links to commonly-used applications such as the dialer, the adressbook, mailbox and calendar. The main body of the screen displays a clock and other useful information.<br />
<br />
See [[Today/2007.2]] for more information about the Today page and customization.<br />
<br />
<br clear=all /><br />
<br />
====Launch Task Page====<br />
<br />
{{stub}}<br />
<br />
[[Image:LaunchTasks.png|right|200px]] This page displays a menu of available applications. You may choose a category of applications to display to simplify the screen, or choose to display them all.<br />
<br />
Current categories are [PIM Suite], [[Om_2007.2_Applications|Applications]], [[Games/Om 2007.2|Games]], Utilities, and All.<br />
<br />
<br clear=all /><br />
<br />
====Running Tasks Page====<br />
<br />
{{stub}}<br />
<br />
[[Image:RunningTasks.png|right|200px]] This page displays currently-running tasks. Any individual task may be terminated by selecting it and then clicking on the garbage-can icon to close it. All tasks may be terminated by clicking on any one of them and then clicking on the "folder" icon in the upper right (expect this to change in future releases). Any task may be rejoined by selecting it and then selecting the "return" icon at the middle top.<br />
<br />
<br clear=all /><br />
<br />
====Exiting from and switching to an Application====<br />
<br />
Any time an application is running, you can simply click the device's power button and the application will exit, returning you to the Today page.<br />
<br />
Alternatively, you can cycle through active applications using the AUX button<br />
<br />
Clicking the top-left of the screen displays the drop down ''task menu''. This menu lists all active applications and allows to switch directly to any one. ''Note:'' If the task menu is not shown, click and hold the [[#Aux|Aux]] button to bring up the Aux menu, and select "Toggle Fullscreen".<br />
<br />
== Using the terminal ==<br />
<br />
To start a console from "Today" page, click the middle tab at the bottom of the screen to display the "Launch applications" page, then select Terminal in the "Applications" submenu. The multitaps keyboard slides up (and down) from the bottom of the screen automatically when you touch the screen.<br />
<br />
===Setting date and time===<br />
<br />
From the terminal, type the following, but replace ''MM'' with the month (01-12); ''DD'' with the day (01-31); ''hhmm'' with the time (0000-2359); ''YYYY'' with the year (optional); and ''.ss'' with the seconds (optional).<br />
<br />
date -s ''MMDDhhmmYYYY.ss''<br />
<br />
To make the change persist between reboots, sync the hardware clock with the updated system time.<br />
<br />
hwclock --systohc<br />
<br />
See [[Setting Date and Time]] for more discussion, including synchronizing with an NTP server.<br />
<br />
<br />
<br />
=== Accessing the microSD card ===<br />
<br />
Mounted at /media/card by default.<br />
<br />
If you have multiple partitions on the card, the first (/dev/mmcblk0p1) will be mounted at /media/card, the second at /media/mmcblk0p2, the third at /media/mmcblk0p3 etc. To setup the package management to write on the microSD card when installing new software follow the [[Package_management | package management guide]].<br />
<br />
== Set up USB-based networking, SSH and update ==<br />
<br />
Openmoko allows TCP/IP-over-USB networking for your phone. The main advantages of this are<br />
* You don't need to set-up GPRS or WLAN network connection for the phone software to reach the Internet<br />
* You can SSH from your computer into the phone shell and comfortably do low-level tasks using your computer's terminal software and real keyboard instead of the tiny screen and touchscreen keyboard<br />
<br />
Naturally, the phone must be connected to your computer with USB cable.<br />
<br />
===Connect with the Neo FreeRunner===<br />
<br />
This is discussed in the [[USB_Networking|USB Networking]] section.<br />
<br />
===Update with the package manager===<br />
<br />
In order to keep the FreeRunner up-to-date with the latest features and bug-fixes, it is advisable update the software at regular intervals.<br />
<br />
There are two main methods of doing this:<br />
* upgrading with the package manager '''opkg'''<br />
* or manually flashing the device (see [[Flashing the Neo FreeRunner]]).<br />
<br />
There are three layers to the software on the FreeRunner:<br />
<br />
* [[uboot|uBoot]]: Think of u-boot as a combination of the BIOS and Grub on a PC.<br />
* Kernel: The Linux kernel<br />
* Root Filesystem: The rest of the system<br />
<br />
Note that ''uboot'', the ''kernel'' and the ''root filesystem'' may all be flashed to update them. For uboot, this is the only possibility (see [[Flashing_the_Neo_FreeRunner#Flashing_the_boot_loader]]). The advantage of flashing the kernel manually rather than using opkg seems to be speed. The disadvantage of flashing the root file system is that it wipes out all local modifications, including /home. If /home is moved to the SD disk, this is no longer a problem.<br />
<br />
Warning: UPGRADING TO DAILY KERNELS FROM THE DEVELOPMENT BRANCH MAY BREAK THINGS. That said, assuming that your FreeRunner can access the internet (see above), the kernel and other packages can be updated with<br />
<br />
# opkg update<br />
# opkg -test upgrade<br />
# opkg upgrade<br />
<br />
The first updates the repository information, telling opkg what packages are available. The second allows you to see what the package manager wants to do. The third upgrades all packages for which a newer version is available. '''At the moment, some signature files are missing (404 errors), which opkg complains about, but this is cosmetic.''' The repositories will still update with the missing signature files.<br />
<br />
Important: If you have followed the Getting Started Guide this far, but opkg upgrades do not appear to be happening. Try checking the .conf files in the /etc/opkg/ directory. If you see four URLs pointing at<br />
<nowiki>http://buildhost.openmoko.org/</nowiki> , this is your problem. The 2007.2 repository has been moved to http://downloads.openmoko.org/repository/Om2007.2. Update your .conf files to point at equivalent directories under this repository, e.g.:<br />
<br />
# sed -i 's/buildhost.openmoko.org\/daily-feed/downloads.openmoko.org\/repository\/Om2007.2/' $(grep -l buildhost /etc/opkg/*.conf)<br />
<br />
Note that running opkg upgrade on a factory-fresh phone will upgrade dropbear (the ssh software) and various xserver packages, and neither upgrades elegantly while in use. Xserver must be updated over ssh to complete succesfully. Dropbear can be updated over ssh with the proper command:<br />
# nohup opkg upgrade dropbear &<br />
Or upgrade it directly in the FreeRunner terminal.<br />
# opkg upgrade dropbear<br />
<br />
When updating over ssh, the session will be interrupted, but the command should complete successfully(check nohup.out on your device to verify), and you should be able to reconnect within a few seconds.<br />
<br />
Another (better) option is to start a screen session before the upgrade with:<br />
<br />
# screen<br />
<br />
After loosing the ssh connection and login in again via ssh reconnect to the running screen session with:<br />
<br />
# screen -x<br />
<br />
Then connect to the FreeRunner via ssh and type:<br />
# opkg upgrade<br />
<br />
And run this command :<br />
# depmod<br />
<br />
Alternatively you can upgrade the xserver packages via ssh and then upgrade the rest from the FreeRunner's terminal.<br />
<br />
If you do your first upgrade in two installments like this, it will go more smoothly.<br />
<br />
It will be possible in the future to update uboot with opkg, but this has not yet been implemented.<br />
<br />
=== Installing multimedia, web browsing and other applications ===<br />
<br />
There are many applications you can install - check out the [[Repositories]] for a list of packages, an example of how to add a repository using scaredy cat as an example can also be found here. A list of pre-installed and available packages with descriptions can be found here - [[Available Packages]].<br />
<br />
The calendar can be installed with<br />
<br />
<pre><br />
opkg install openmoko-dates2<br />
</pre><br />
<br />
For a Media Player:<br />
<br />
<pre><br />
opkg install openmoko-mediaplayer2<br />
wget http://abraxa.dyndns.org:81/random/openmoko-mediaplayer-theme.tar.bz2<br />
tar xjf openmoko-mediaplayer-theme.tar.bz2 -C /usr/share/themes/Moko/gtk-2.0<br />
rm openmoko-mediaplayer-theme.tar.bz2<br />
</pre><br />
<br />
If you want a basic image viewer, have a look at the one from the gpe suite:<br />
<br />
<pre><br />
opkg install gpe-icons<br />
opkg install gpe-gallery<br />
</pre><br />
<br />
To obtain the standard web browser, use:<br />
<br />
<pre><br />
opkg install openmoko-browser2<br />
</pre><br />
<br />
An alternative browser, minimo, offers many more features.<br />
First download and unpack it on your GNU/Linux host:<br />
<br />
<pre><br />
wget http://www.ginguppin.de/files/minimo.tar.bz2<br />
tar jvxf minimo.tar.bz2<br />
</pre><br />
<br />
Copy it over to the FreeRunner:<br />
<pre><br />
scp minimo_* root@192.168.0.202:/tmp<br />
</pre><br />
<br />
Then on the FreeRunner:<br />
<pre><br />
opkg install /tmp/minimo_0.02\+cvs20070626-r0_armv4t.ipk<br />
</pre><br />
<br />
You'll probably also want to [[Switching Keyboards|change the keyboard]] including the [[Switching Keyboards#How_to_add_a_keyboard_toggle_button|keyboard toggle applet]]<br />
<br />
=== Importing contacts ===<br />
<br />
If you can export your contacts to VCard format, either multiple files or single file containing all of them, you may use the script on [[Import Vcf Contacts]] page to bring them to Neo.<br />
<br />
==The next steps==<br />
<br />
Congratulations for setting up your Neo FreeRunner. There are many more ressources to help free your phone:<br />
<br />
===Customize the interface===<br />
home screen clock, keyboard<br />
<br />
The stock [[Openmoko2007.2]] image flashed onto the Neo FreeRunner is really just the bare bones. For example, you don't have the clock and the quick-launch icons showing. Here's how you can change that:<br />
<br />
# dbus-launch gconftool-2 -t boolean -s /desktop/poky/interface/reduced false<br />
# /etc/init.d/xserver-nodm restart<br />
<br />
If you rather have a regular clock instead of the digital one, do this instead:<br />
<br />
# dbus-launch gconftool-2 -t boolean -s /desktop/poky/interface/reduced false<br />
# dbus-launch gconftool-2 -t boolean -s /desktop/poky/interface/digital_clock false<br />
# /etc/init.d/xserver-nodm restart<br />
<br />
REMOVE CLICK SOUND VIA /etc/pulse/session<br />
<br />
More information about today screen customization at [[Today/2007.2]].<br />
<br />
Also, if you prefer having a full keyboard, using matchbox's qwerty keybord, see [[Switching_Keyboards#Matchbox_keyboard|these instructions]]. Then you may also see [http://lists.openmoko.org/pipermail/community/2008-July/021296.html these], which describe a way to add an applet allowing the showing/hiding of that keyboard.<br />
<br />
===Use the GPS===<br />
<br />
Simple guide to get going with '''GPS''':<br />
<br />
# opkg install gpsd<br />
# echo "GPS_DEV=\"/dev/ttySAC1\"" > /etc/default/gpsd<br />
<br />
and restart gpsd, the gps daemon, with<br />
<br />
# /etc/init.d/gpsd restart<br />
<br />
To test GPS, you can use agpsui:<br />
<br />
# opkg install openmoko-agpsui<br />
<br />
For a nice map, try [[tangoGPS]]:<br />
<br />
# opkg install tangogps<br />
<br />
or download it from [http://www.tangogps.org/downloads/tangogps_0.9.3-r1_armv4t.ipk tangogps.org].<br />
<br />
There were critical [[GPS Problems]] earlier that are largely fixed in newest kernels, see the instructions above to install the updates. More information is on the [[GPS]] page.<br />
<br />
===Play with WLAN, GPRS and Bluetooth===<br />
<br />
There are plenty of development opportunities to integrate these functions in the Openmoko software.<br />
<br />
'''WLAN''': See [[Wireless Networking]]<br />
<br />
'''GPRS''': See [[Manually using GPRS]]<br />
<br />
'''Bluetooth''': See [[Manually using Bluetooth]]<br />
<br />
=== Testing a new distribution ===<br />
<br />
[[Om 2008.8]] is the successor to Om 2007.2 (and had ASU as a codename). It was launched on August 08, 2008. You may wish to test it or (if you feel adventurous) install it in place of the stock 2007.2 distribution you've just got to know.<br />
<br />
=== Welcome to the community ===<br />
<br />
The release of the FreeRunner in the summer 2008 has led the community into a new period of rapid growth. The resources available are summarized on the [[Openmoko:Community_Portal]]. These are always exciting and interesting times to live in when the balance between Chaos and Order tilts towards change.<br />
<br />
As an entry point, the [[http://lists.openmoko.org/pipermail/community/ openmoko community mailing list]] is perhaps the most active. As of July 2008, its volume amounts to dozens of messages per day. Openmoko people are there too. You may ask for help on the [[https://lists.openmoko.org/mailman/listinfo/support support mailing list]].<br />
<br />
Or if you use IRC, there is always a good group in the channel #openmoko on FreeNode.<br />
<br />
The links on the top-right of this page lead to the sister sites in the Openmoko community:<br />
* Home and Wiki lead to the same Main Page on the wiki. It needs cleaning, we know...<br />
* Doc leads to the bug ''Trac''king system.<br />
* Planet goes to the collection of Openmoko-relatd blogs.<br />
* Projects is the GForge, free hosting for application developers.<br />
* Lists is the listing of all the public mailing lists on lists.openmoko.org.<br />
<br />
== Annotated references ==<br />
<br />
* [[Neo FreeRunner]]. The top-level view of the specifications.<br />
* [[Neo FreeRunner GTA02 Hardware]]. The detailed specifications.<br />
* [[GTA02 Openness]]. Ultimate chip-level specifications, data sheets and hardware documentation.<br />
* [[Distributions]]. Strengths and weaknesses of the various distributions available for the Neo.<br />
* [[FAQ#Getting_Started_with_your_Neo_FreeRunner]]. Answers.<br />
<br />
To search this wiki with Google, use the following search term:<br />
<br />
<search term> site:http://wiki.openmoko.org/wiki/<br />
<br />
[[Category:Neo FreeRunner Hardware| ]]<br />
[[Category:Basic End User]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T18:06:35Z<p>Kostigoff: /* FreeBSD */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
<tt>/usr/local/etc/devd/cdce.conf</tt> as:<br />
<br />
<pre><br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
</pre><br />
<br />
and <tt>/usr/local/etc/devd/cdce.sh</tt> as:<br />
<br />
<pre><br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
</pre><br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T18:06:20Z<p>Kostigoff: /* FreeBSD */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
<tt>/usr/local/etc/devd/cdce.conf</tt> as:<br />
<br />
<pre><br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
</pre><br />
<br />
and <tt>/usr/local/etc/devd/cdce.sh</tt> as:<br />
<br />
<pre><br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
</pre><br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T18:04:39Z<p>Kostigoff: /* Gentoo */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
<pre><br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
</pre><br />
<br />
Create a new init script:<br />
<br />
<pre><br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
</pre><br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T18:04:02Z<p>Kostigoff: /* Automatic Configuration */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
<pre><br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
</pre><br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T18:03:22Z<p>Kostigoff: /* Manual Configuration */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
<pre><br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
</pre><br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:55:33Z<p>Kostigoff: /* Option A - Tested with FC9, FC8 & FC5 */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
<code>Bringing up interface usb0 [OK]</code><br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:55:00Z<p>Kostigoff: /* Option A - Tested with FC8 & FC5 */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC9, FC8 & FC5 ===<br />
<br />
edit file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt> to look like this:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
and restart networking service by typing:<br />
<br />
service network restart<br />
<br />
if your '''openmoko''' is connected when you restart network you should see system message:<br />
<br />
Bringing up interface usb0 [OK]<br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:48:41Z<p>Kostigoff: /* Option A - Tested with FC8 & FC5 */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC8 & FC5 ===<br />
<br />
file <tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt><br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:48:20Z<p>Kostigoff: /* Option A - Tested with FC8 & FC5 */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC8 & FC5 ===<br />
<br />
<code>/etc/sysconfig/network-scripts/ifcfg-usb0</code><br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:47:54Z<p>Kostigoff: /* Option B */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC8 & FC5 ===<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
./etc/init.d/functions<br />
cd /etc/sysconfig/network-scripts<br />
../network-functions<br />
[ -f ../network ] && . ../network<br />
CONFIG=${1}<br />
need_config ${CONFIG}<br />
source_config<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:46:24Z<p>Kostigoff: /* Option A - Tested with FC8 & FC5 */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC8 & FC5 ===<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from <nowiki>http://www.handhelds.org/moin/moin.cgi/UsbNet</nowiki><br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
<br />
. /etc/init.d/functions<br />
<br />
cd /etc/sysconfig/network-scripts<br />
. ./network-functions<br />
<br />
[ -f ../network ] && . ../network<br />
<br />
CONFIG=${1}<br />
<br />
need_config ${CONFIG}<br />
<br />
source_config<br />
<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
<br />
. /etc/init.d/functions<br />
<br />
cd /etc/sysconfig/network-scripts<br />
. ./network-functions<br />
<br />
[ -f ../network ] && . ../network<br />
<br />
CONFIG=${1}<br />
<br />
need_config ${CONFIG}<br />
<br />
source_config<br />
<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:45:56Z<p>Kostigoff: /* Option B */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC8 & FC5 ===<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from http://www.handhelds.org/moin/moin.cgi/UsbNet<br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
<br />
. /etc/init.d/functions<br />
<br />
cd /etc/sysconfig/network-scripts<br />
. ./network-functions<br />
<br />
[ -f ../network ] && . ../network<br />
<br />
CONFIG=${1}<br />
<br />
need_config ${CONFIG}<br />
<br />
source_config<br />
<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
<br />
. /etc/init.d/functions<br />
<br />
cd /etc/sysconfig/network-scripts<br />
. ./network-functions<br />
<br />
[ -f ../network ] && . ../network<br />
<br />
CONFIG=${1}<br />
<br />
need_config ${CONFIG}<br />
<br />
source_config<br />
<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoffhttp://openmoko.org/wiki/USB_NetworkingUSB Networking2008-12-09T17:44:12Z<p>Kostigoff: /* Option A - Tested with FC8 & FC5 */</p>
<hr />
<div>= Openmoko Networking Setup =<br />
<br />
In order to communicate via TCP/IP to your FreeRunner, a basic understanding of the networking expectations is required. Each end of the USB connection forms a LAN (local area network) segment, with the FreeRunner's USB networking device at one end (default 192.168.0.202) and your laptop or desktop at the other end (192.168.0.200 in this guide).<br />
<br />
Normally, your desktop machine will know how to reach the Internet, having had its gateway (the IP address of the machine or device which knows how to send packets to machines beyond your subnet) configured via DHCP or statically (probably via a router). For the FreeRunner to reach the Internet, your desktop will have to be configured to route and masquerade (NAT) packets from it.<br />
<br />
Normally, none of this is an issue, but problems can arise when the subnet between the FreeRunner and your desktop overlap with the desktop to the router (which forms a second LAN), since your desktop might not know how to route traffic properly.<br />
<br />
In other words: if your existing router and desktop have addresses 192.168.0.(something) changing them to e.g. 192.168.1.(something) might save you a lot of troubleshooting later. A discussion of this is [http://lists.openmoko.org/pipermail/support/2008-August/thread.html#1277 here].<br />
<br />
= Simple Manual Linux Configuration =<br />
Try this first (as root on your desktop, with FreeRunner attached via USB cable and booted properly, not at the Boot Menu). If it works, then you can add permanent configuration or use more sophisticated setups below.<br />
=== The shortest way ===<br />
This simple way has been tested with many Linux distributions (Fedora, SuSE, Red Hat, Debian and others) and network configurations. It was even successfully applied to connect another Linux based handhelds like TDS Nomad and surely can be recommended as the first attempt. The way assumes that you have the recent Linux distribution with USB networking enabled and also rather typical network setup. <br />
<br />
With the device connected configure usb0 interface (as root):<br />
<pre><br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
</pre><br />
If your eth0 interface is also in the same 'range' (e.g. 192.168.0.105) then you can do the following:<br />
<br />
1. ping the Neo with<br />
# ping -I usb0 192.168.0.202<br />
2. log in to the Neo (you do not need to be a root on the desktop host just to log in).<br />
# ssh root@192.168.0.202<br />
The default password is blank.<br />
<br />
Do not forget to adjust your firewall so that you can connect to the device. Also, some old or narrowly configured Linux distributions may not have USB networking support. For such cases the simple way might be just to upgrade.<br />
<br />
=== The more advanced way ===<br />
If the previously described simple approach does not work, you may try the more complex one.<br />
<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
sysctl -w net.ipv4.ip_forward=1<br />
ip addr add 192.168.0.200/24 dev usb0</pre><br />
<br />
If your Internet connection is also in the range 192.168.0.x then instead you might want to use only:<br />
<br />
<pre>ip addr add 192.168.0.200/28 dev usb0</pre><br />
<br />
(This will just map the net from 192.168.0.192 to 192.168.0.207 onto usb0. If you get the error 'Cannot find device "usb0"', double-check that your FreeRunner is turned on and connected by USB. If that doesn't work, try unplugging and replugging the USB cable.)<br />
<br />
And in this case you should enable ARP proxy on internet facing interface INSTEAD of using iptables:<br />
<br />
<pre>sysctl net.ipv4.conf.eth2.proxy_arp=1</pre><br />
<br />
This assuming that eth2 is connected to ISP.<br />
<br />
Then<br />
<pre>ifconfig usb0 up</pre><br />
<br />
Then (ideally, not as root):<br />
<br />
<pre>ssh root@192.168.0.202</pre><br />
<br />
The default password is blank.<br />
<br />
Due to the fact that in most cases your Neo will use the same dns servers as your computer uses, you can automate the process of writing dns servers to your phone:<br />
<br />
<pre>#!/bin/sh<br />
/sbin/route add -host 192.168.0.202/32 dev usb0<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
iptables -P FORWARD ACCEPT<br />
sysctl -w net.ipv4.ip_forward=1<br />
su `whoami` -c "scp /etc/resolv.conf root@192.168.0.202:/etc/resolv.conf"</pre><br />
<br />
Again if your net already is 192.168.0.0, replace the POSTROUTING statement with<br />
<pre>iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/28</pre><br />
<br />
This simple script will set up routing for your Freerunner and than copy resolv.conf with dns addresses straight to the phone.<br />
All you have to do is connect phone to the computer, run the script and enjoy internet connection from your phone.<br />
<br />
= Linux Kernel Support =<br />
<br />
Your Linux desktop/laptop needs to have suitable support, in particular, you will need to have enabled full masquerading in the kernel and USB networking options enabled. For default kernels in many Linux distributions, this will already be the case. If not, you will need to enable:<br />
<br />
* CONFIG_USB_USBNET<br />
* CONFIG_USB_NET_CDCETHER<br />
<br />
Both USB networking options are available in the<br />
<br />
''Device Drivers -> USB support -> USB Network Adapters''<br />
<br />
or<br />
<br />
''Device Drivers -> Network Device Support -> USB Network Adapters -> Multipurpose USB Networking Framework''.<br />
<br />
For more info see the [http://www.linux-usb.org/usbnet/ usbnet driver homepage].<br />
<br />
Masquerading options (tested on Linux 2.6.26.3) are found in:<br />
<br />
''Networking ---><br />
Networking options --->''<br />
<br />
To see the other options, enable<br />
<br />
* CONFIG_NETFILTER (''Network packet filtering framework (Netfilter)'')<br />
<br />
Then, from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
Core Netfilter Configuration --->''<br />
<br />
You need at least following options enabled as modules:<br />
<br />
* CONFIG_NF_CONNTRACK (''Netfilter connection tracking support'')<br />
* CONFIG_NF_CONNTRACK_FTP (''FTP protocol support'')<br />
* CONFIG_NETFILTER_XTABLES (''Netfilter Xtables support'')<br />
<br />
Rest of the needed options are found from<br />
<br />
''Networking ---><br />
Networking options ---><br />
[*] Network packet filtering framework (Netfilter) ---><br />
IP: Netfilter Configuration --->''<br />
<br />
You need to enable (again, as modules is fine):<br />
<br />
* CONFIG_NF_CONNTRACK_IPV4 (''IPv4 connection tracking support (required for NAT)'')<br />
* CONFIG_IP_NF_IPTABLES (''IP tables support (required for filtering/masq/NAT)'')<br />
* CONFIG_NF_NAT (''Full NAT'')<br />
* CONFIG_IP_NF_TARGET_MASQUERADE (''MASQUERADE target support'')<br />
<br />
= Firewall Issues =<br />
<br />
On some systems, you may have firewall rules which prevent this working - such as added by the iptables service on Fedora. You may care to stop these, and/or review any rules or policies you think might cause issues.<br />
<br />
The most relevant table is the nat table, which controls translation of addresses:<br />
<br />
iptables -L -t nat -v -n<br />
<br />
Unless you have a special setup, you'll want to see only the MASQUERADE rule that you apply below, and ACCEPT as the default policy. Also look at the filter table:<br />
<br />
iptables -L -t filter -v -n<br />
<br />
If this contains anything in the FORWARD chain, then this may prevent passing packets. It can be flushed with:<br />
<br />
iptables -t filter -F FORWARD<br />
<br />
= DNS =<br />
<br />
In addition to routing issues, to be practical, DNS will need to work. In some cases, you might already be running a DNS server on your desktop such as dnsmasq or bind9, which is the default assumption the FreeRunner makes. In other cases, you'll need to configure DNS to that of your router, or a DNS server further out on the internet such as that provided by your ISP.<br />
<br />
== Configure Default Neo DNS ==<br />
<br />
DNS is configured in /etc/resolv.conf on your FreeRunner.<br />
<br />
You should add the IP address of the DNS servers as provided by your ISP. Check your router's or PC's network status for the nameserver IP addresses.<br />
<br />
<pre>echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf</pre><br />
<br />
You can also add the public DNS server called openDNS:<br />
<pre>echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
These settings will be lost on reboot. You can set the DNS for the next connect, by adding the following to the end of the usb0 setting in /etc/network/interfaces, right above the bluetooth networking section:<br />
<pre>up echo nameserver 208.67.222.222 > /etc/resolv.conf<br />
up echo nameserver 208.67.220.220 >> /etc/resolv.conf</pre><br />
<br />
== Proxying DNS from Desktop/Laptop ==<br />
<br />
If you move about, making assumptions about the network may not be convenient, and it is possible to proxy DNS requests via your host laptop (which you are also taking with you), without running or installing a DNS server. There are a number of ways to do this:<br />
<br />
=== Proxying with dnrd ===<br />
<br />
The script is designed to use [http://dnrd.sourceforge.net/ dnrd] as the DNS proxy. The [http://buildhost.automated.it/gta01 script] and a copy of [http://buildhost.automated.it/dnrd-2.20.3.tar.gz dnrd] are available. The script also performs the initial setup of the connection as per the [[USB_Networking#Manual_method]] above.<br />
<br />
=== Proxying with a UDP forwarder ===<br />
<br />
Another easy setup is using a UDP forwarder like the one from http://www.tapor.com/udpf/ - use it with the command"<br />
<br />
<pre>udpf-elf -p=53-f=`awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf`:53</pre><br />
<br />
=== Proxying with iptables ===<br />
<br />
It is possible to forward DNS requests with iptables using the DNAT target:<br />
<br />
<pre>iptables -t nat -A PREROUTING -p tcp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1<br />
iptables -t nat -A PREROUTING -p udp -s 192.168.0.202 -d 192.168.0.200 --dport domain -j DNAT --to-destination 192.168.0.1</pre><br />
<br />
Where <tt>192.168.0.1</tt> is the IP of your router.<br />
<br />
Test if it works:<br />
<pre>ping www.google.com</pre><br />
<br />
If so, then this is sufficient for most internet access. But manual changes to resolv.conf are usually lost later if for example one uses DHCP, especially for WiFi, and so may not be convenient to configure manually.<br />
<br />
= Testing Your Connection =<br />
You should be able to connect to your Neo! Make sure you can ping your Neo to be sure.<br />
ping 192.168.0.202<br />
<br />
Then log into your Neo using ssh:<br />
ssh root@192.168.0.202<br />
The default password is blank (press enter).<br />
<br />
You can also [[scp]] files back and forth. You can telnet, SSH, SMB or do whatever you want if you install software that enables you to set up TCP/IP network over your USB connection.<br />
<br />
Now, make sure you can ping back to your desktop<br />
ping 192.168.0.200<br />
(Note that some systems like Vista, don't respond to ICMP ping by default)<br />
<br />
Try pinging the outside world (a Google IP address)<br />
ping 74.125.19.147<br />
This demonstrates that masquerading is working - your desktop is sending/receiving packets to the wider internet.<br />
<br />
Lastly, verify that DNS is correctly configured between the Neo & Network:<br />
ping www.google.com<br />
<br />
= OS or Distro Specific & Automatic Configuration =<br />
<br />
Based on [http://blog.haerwu.biz/2007/03/22/hotpluging-usbnet/ Hotplugging usbnet] by Marcin 'Hrw' Juszkiewicz.<br />
These instructions should keep you from having to run the Simple Manual Linux Configuration every time you plug in and want to connect to an Openmoko device. One run and then you're done!<br />
<br />
If the Simple Manual Linux Configuration does not work for your OS or Distro (MacOS X, MS Windows, etc) there may be instructions here that work for you.<br />
<br />
== MacOS X ==<br />
See [[MacOS_X#USB_Networking|MacOS X USB Networking]].<br />
<br />
== Windows ==<br />
See [[Neo1973_and_Windows#USB_Ethernet_emulation|Windows USB Ethernet emulation for Neo1973]].<br />
<br />
There is also a very helpful tutorial for connecting with Vista at [http://sam.curren.ws/index.cfm/2008/7/14/Using-the-Neo-FreeRunner-with-Windows-XPVista].<br />
<br />
== FreeBSD ==<br />
You need to load the cdce kernel module (if it is not already linked into your kernel). As root do:<br />
<br />
# kldload cdce<br />
<br />
The Neo should then show up as cdce0 interface and you can handle the cdce0 interface just like the usb0 device under Linux. For more information see the cdce manpage. An easy way to assign the IP address to the cdce0 interface is using the devd(8) daemon. Create the following two files,<br />
<br />
/usr/local/etc/devd/cdce.conf as:<br />
<br />
notify 1 {<br />
match "system" "IFNET";<br />
match "subsystem" "cdce0";<br />
match "type" "ATTACH";<br />
action "/usr/local/etc/devd/cdce.sh $subsystem $type";<br />
};<br />
<br />
and /usr/local/etc/devd/cdce.sh as:<br />
<br />
#!/bin/sh<br />
case $2 in<br />
'ATTACH')<br />
ifconfig cdce0 192.168.0.200 netmask 255.255.255.0<br />
exit 0 ;<br />
;;<br />
esac<br />
exit 0<br />
<br />
Then restart the devd(8) daemon with:<br />
<br />
# /etc/rc.d/devd restart<br />
<br />
If you now plugin the FreeRunner into the USB port the cdce0 interface gets created and the IP addr will be assigned.<br />
<br />
<br />
== Debian, Ubuntu and others ==<br />
<br />
Edit /etc/network/interfaces and add:<br />
<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.0<br />
network 192.168.0.0<br />
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
up echo 1 > /proc/sys/net/ipv4/ip_forward &<br />
up iptables -P FORWARD ACCEPT &<br />
down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 &<br />
<br />
</pre><br />
<br />
This is more sophisticated than the manual setup. The 'auto usb' stanza ties into the Linux hotplug system so that when the device appears and vanishes, as happens when the FreeRunner is connected via USB, this is run.<br />
<br />
In addition, the desktop-side netmask is limited to a much smaller range, so that overlapping subnets are less of a problem - Linux will use more specific routes first when deciding where to send packets.<br />
<br />
Another possible configuration that adds DNS forward and removes<br />
the iptables changes after unplugging:<br />
<br />
in /etc/network/interfaces add<br />
<pre><br />
# freerunner<br />
allow-hotplug usb0<br />
iface usb0 inet static<br />
address 192.168.0.200<br />
netmask 255.255.255.192<br />
post-up /etc/network/freerunner start<br />
pre-down /etc/network/freerunner stop<br />
</pre><br />
<br />
create file /etc/network/freerunner<br />
<pre><br />
#!/bin/sh<br />
#<br />
# configures the freerunner for internet<br />
#<br />
#<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
REMOTE_IPADDR=192.168.0.202<br />
NETMASK=255.255.255.0<br />
<br />
# get first ip for dns<br />
DNSIP=$(awk '$1 == "nameserver"{print $2; exit(0);}' /etc/resolv.conf)<br />
<br />
case "$1" in<br />
start)<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then<br />
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
stop)<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR<br />
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP<br />
<br />
if [ -f /var/run/openmoko.ip_forward ]; then<br />
rm /var/run/openmoko.ip_forward<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
fi<br />
;;<br />
esac<br />
</pre><br />
<br />
Make /etc/network/freerunner executable with<br />
chmod +x /etc/network/freerunner<br />
<br />
It is possible to use network-manager to automatically connect to the Freerunner using udev. The process uses udev to run a script when the Frerunner is plugged in. The script uses the ip command to set the mac address of the usb network interface. To begin, create /etc/udev/rules.d/80-freerunner.rules :<br />
<br />
<pre><br />
# This file causes programs to be run on device insertion.<br />
# See udev(7) for syntax.<br />
<br />
# rule to assign a fixed mac address specified in /<br />
KERNEL=="usb[0-9]*", DRIVERS=="cdc_ether", ACTION=="add", RUN+="/usr/local/sbin/freerunner-usb-add.sh %k"<br />
</pre><br />
<br />
Next, create the /usr/local/sbin/freerunner-usb-add.sh :<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
(<br />
busNum=$( printf %.2d $( expr match "$1" "usb\([0-9]*\)") )<br />
<br />
ip link set "$1" address 00:00:22:55:bb:$busNum &> /dev/null<br />
<br />
) &<br />
<br />
exit 0<br />
</pre><br />
<br />
Finally run "chmod +x /usr/local/sbin/freerunner-usb-add.sh" to make it executable. Now you can use network-manager with mac-address specific settings and get it to automatically connect.<br />
<br />
=== Ubuntu Issues ===<br />
<br />
Ubuntu 8.10 doesn't work as expected if you used /etc/network/interfaces to automate the connection. Network manager likes to latch onto the network device and add a default route through 192.168.0.202, breaking your network connection. Network manager also says you can't edit or remove this connection from its list. I'm going back to making the connection manually.<br />
<br />
Ubuntu Feisty, Gutsy and Hardy reportedly have a bug where ifdown is not run when the interface is unplugged, meaning this only works once after the system is booted. This is mentioned at https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/130437<br />
<br />
One can patch /etc/udev/rules.d/85-ifupdown.rules. Moving the DRIVERS=="*?" out of the top GOTO, to ACTION=="add" line fixes the problem.<br />
<br />
<pre><br />
SUBSYSTEM=="net", GOTO="net_start"<br />
GOTO="net_end"<br />
<br />
LABEL="net_start"<br />
<br />
# Bring devices up and down only if they're marked auto.<br />
# Use start-stop-daemon so we don't wait on dhcp<br />
ACTION=="add", DRIVERS=="?*", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto $env{INTERFACE}"<br />
<br />
ACTION=="remove", RUN+="/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifdown -- --allow auto $env{INTERFACE}"<br />
<br />
LABEL="net_end"<br />
</pre><br />
<br />
The bug is that the DRIVERS variable isn't set at all when the device is unplugged.<br />
<br />
This appears to be fixed in Ubuntu 8.04 [[User:Mattt|Mattt]] 11:38, 30 July 2008 (UTC)<br />
:Actually it appears that it's not fixed, but patching that file and disconnecting and reconnecting the phone works perfectly. --[[User:Johndoesacc|Johndoesacc]] 18:37, 20 August 2008 (UTC)<br />
:Well, yes, it must be fixed because it worked for me out-of-the-box without tweaking the udev rule on 8.04 --[[User:EtienneG|EtienneG]] November 26th, 2008<br />
=== Ubuntu Workaround ===<br />
Use [http://wicd.sourceforge.net/ wicd] instead of networkmanager:<br />
It is much further in development than networkmanager yet and doesn't make any problems with USB networking. You can use the "normal" settings in /network/interfaces.<br />
Note: Because of it's dependencies it deinstalls networkmanager.<br />
<br />
<br />
== Mandriva ==<br />
<br />
This first file configures the network system for the usb0 interface. Any time you plug in the FreeRunner the interface will be configured.<br />
<br />
<tt>/etc/sysconfig/network-scripts/ifcfg-usb0</tt>:<br />
<br />
DEVICE=usb0<br />
BOOTPROTO=static<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
NETWORK=192.168.0.0<br />
BROADCAST=192.168.0.255<br />
ONBOOT=yes<br />
METRIC=10<br />
MII_NOT_SUPPORTED=no<br />
USERCTL=yes<br />
<br />
This next file configures the static routes that we need to communicate to the subnet. Since it has "usb0" in the name, the system will automatically apply these static routes any time that the usb0 interface is configured. (i.e. when you connect the FreeRunner)<br />
<br />
<tt>/etc/sysconfig/network-scripts/usb0-routes</tt>:<br />
<br />
ADDRESS0=192.168.0.200<br />
NETMASK0=255.255.255.0<br />
<br />
Now we need to restart the network system to pick up the changes.<br />
<br />
service network restart<br />
<br />
<br />
This didn't work for me (Mandriva 2008.1), giving errors from Shorewall. However, simply using MCC, Network->Sharing Internet Access worked fine. You need to connect Neo when starting it. --[[User:Alih|Alih]] 18:50, 22 September 2008 (UTC)<br />
<br />
== SuSE ==<br />
<br />
/etc/sysconfig/network/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
STARTMODE=onboot<br />
<br />
For more information on getting USB networking up using YaST, see [[USB Networking with openSUSE]].<br />
<br />
== Fedora ==<br />
<br />
=== Option A - Tested with FC8 & FC5 ===<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
# USB configuration for PDAs (openmoko)<br />
# from http://www.handhelds.org/moin/moin.cgi/UsbNet<br />
DEVICE=usb0<br />
BOOTPROTO=none<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
ONBOOT=yes<br />
<br />
=== Option B ===<br />
<br />
This setup is probably over-complex:<br />
<br />
/etc/sysconfig/network-scripts/ifcfg-usb0:<br />
<br />
DEVICE=usb0<br />
IPADDR=192.168.0.200<br />
NETMASK=255.255.255.0<br />
<br />
/etc/sysconfig/network-scripts/ifup-usb:<br />
<br />
#!/bin/bash<br />
<br />
. /etc/init.d/functions<br />
<br />
cd /etc/sysconfig/network-scripts<br />
. ./network-functions<br />
<br />
[ -f ../network ] && . ../network<br />
<br />
CONFIG=${1}<br />
<br />
need_config ${CONFIG}<br />
<br />
source_config<br />
<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
/sbin/ip link set dev ${DEVICE} up<br />
/sbin/ip addr add dev ${DEVICE} ${IPADDR}/${NETBITS}<br />
<br />
/sbin/iptables -I POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
/sbin/sysctl net.ipv4.ip_forward=1<br />
/sbin/iptables -I FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -I FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
<br />
Set /etc/sysconfig/network-scripts/ifdown-usb:<br />
<br />
#!/bin/bash<br />
<br />
. /etc/init.d/functions<br />
<br />
cd /etc/sysconfig/network-scripts<br />
. ./network-functions<br />
<br />
[ -f ../network ] && . ../network<br />
<br />
CONFIG=${1}<br />
<br />
need_config ${CONFIG}<br />
<br />
source_config<br />
<br />
NETBITS=`ipcalc -p ${IPADDR} ${NETMASK} | awk -F'=' '{print $2;}'`<br />
<br />
/sbin/iptables -D FORWARD -d ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/iptables -D FORWARD -s ${IPADDR}/${NETBITS} -j ACCEPT<br />
/sbin/sysctl net.ipv4.ip_forward=0<br />
/sbin/iptables -D POSTROUTING -t nat -j MASQUERADE -s ${IPADDR}/${NETBITS}<br />
<br />
/sbin/ip link set dev ${DEVICE} down<br />
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null<br />
<br />
If you are using NetworkManager, restart it and enable the usb device from its menu, otherwise it will disable your connection shortly after you enable it.<br />
<br />
/sbin/service NetworkManager restart<br />
=== Option C - tested on F9 ===<br />
(worked on FC8 too, can this be called "tested"?)<br />
<br />
Plug in the usb cable. NetworkManager should detect the phone automatically but you should ignore it.<br />
Open Network Configuration tool (System -> Administration -> Network) and perform following steps:<br />
# Click '''New''' button on top bar<br />
# Click '''Forward'''<br />
# Select OpenMoko from device list<br />
# Click '''Forward'''<br />
# Select 'Statically set IP address:' and enter address: 192.168.0.200, netmask 255.255.255.0 (or use 255.255.255.240 if you want only route ip range 192.168.0.192-192.168.0.207). Leave gateway empty.<br />
# Click '''Forward'''<br />
# Click '''Apply''' to close add dialog<br />
# Select newly added usb0 device from the device list.<br />
# Click '''Edit''' button on top bar<br />
# You might want to remove a tick from 'Activate device when computer starts' check box.<br />
# Click '''Ok''' to close window dialog.<br />
Save settings and close the window.<br />
<br />
Open Firewall Configuration (System -> Administration -> Firewall) and enable masquerading:<br />
# Select '''Masquerading''' from left panel<br />
# Check device(s) which you'd like to share internet connection. Typically eth0 or wlan0.<br />
# Click '''Apply''' and close application<br />
<br />
Open terminal and perform (as root user):<br />
# ifdown usb0<br />
# ifup usb0<br />
The first command will remove any existing settings given by the NetworkManager and second command brings the device up with appropriate settings.<br />
<br />
Now you should be able to ping e.g. 74.125.39.99 [www.google.com] from OpenMoko. Configure /etc/resolv.conf and you should have full a internet access.<br />
<br />
==== Troubleshooting ====<br />
If Network Configuration tool cannot see the the usb0 try to unplug the usb cable for a few seconds and wait until the NetworkManager finds it again.<br />
<br />
NetworkManager will assign a new ip address for the OpenMoko if link goes down for a while. You can fix this by issuing '''ifup usb0''' again.<br />
<br />
== Red Hat or Similar (tested with Workstation 5) ==<br />
<br />
Edit /etc/sysconfig/network-scripts/net.hotplug:<br />
<br />
After this command:<br />
<br />
<pre><br />
case $INTERFACE in<br />
# interfaces that are registered after being "up" (?)<br />
</pre><br />
<br />
add<br />
<br />
<pre><br />
usb0)<br />
ifconfig usb0 192.168.0.200 netmask 255.255.255.0<br />
route add 192.168.0.202 usb0<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
exit 0<br />
;;<br />
</pre><br />
<br />
== Gentoo ==<br />
<br />
Open /etc/conf.d/net and add:<br />
<br />
# Neo<br />
config_usb0=( "192.168.0.200 netmask 255.255.255.0" )<br />
routes_usb0=( "192.168.0.202/32 via 192.168.0.200" )<br />
<br />
Create a new init script:<br />
<br />
cd /etc/init.d<br />
ln -s net.lo net.usb0<br />
<br />
=== Manual Configuration ===<br />
<br />
Put iptables into use:<br />
<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
<br />
Store them:<br />
<br />
/etc/init.d/iptables save<br />
<br />
If you want the routing by default:<br />
<br />
rc-update add iptables default<br />
<br />
You must also inform the kernel, to start forwarding.<br />
<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
<br />
=== Automatic Configuration ===<br />
One way to automate all this is to create /etc/conf.d/net.usb0 as follows. It sets IP forwarding and the iptables rules all in one go. It removes the iptables rules and disables ip forwarding when the FreeRunner is unplugged.<br />
<br />
preup() {<br />
echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT<br />
iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT<br />
iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
postdown() {<br />
echo 0 > /proc/sys/net/ipv4/ip_forward<br />
iptables -D INPUT -s 192.168.0.202 -j ACCEPT<br />
iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT<br />
iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24<br />
return 0<br />
}<br />
<br />
== Slackware (tested with 12.1) ==<br />
<br />
Following is based on [http://www.enricozini.org/2008/tips/autodock-freerunner.html Enrico Zini's solution].<br />
<br />
Create a new udev rules file <tt>/etc/udev/rules.d/91-openmoko.rules</tt>:<br />
<br />
<pre><br />
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="1457", ATTRS{idProduct}=="5122", RUN+="/sbin/om-usb $env{INTERFACE} start"<br />
SUBSYSTEM=="net", ACTION=="remove", ENV{INTERFACE}=="usb[0-9]", RUN+="/sbin/om-usb $env{INTERFACE} stop"<br />
</pre><br />
<br />
Then create the script <tt>/sbin/om-usb</tt>:<br />
<br />
<pre><br />
#!/bin/sh<br />
INTERFACE=$1<br />
ACTION=$2<br />
<br />
# udev fails silently when the script fails, e.g. due to commands not<br />
# being found<br />
PATH=/usr/sbin:/sbin:/usr/bin:/bin<br />
<br />
case $ACTION in<br />
'start')<br />
# Put all your setup here<br />
;;<br />
'stop')<br />
# Put all your tear down here<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop}"<br />
exit 1<br />
;;<br />
esac<br />
</pre><br />
<br />
The <tt>INTERFACE</tt> will be <tt>usb0</tt> in most cases.<br />
<br />
== Archlinux ==<br />
Following is based on [http://xenos.altervista.org/blogs/index.php?blog=3&title=openmoko-usb-networking-su-archlinux furester's solution].<br />
<br />
Install package [http://aur.archlinux.org/packages.php?ID=20220 openmoko-usb-networking] from AUR:<br />
<br />
$ yaourt -S openmoko-usb-networking<br />
<br />
= SSH Extras =<br />
<br />
Reportedly, the ssh daemon (dropbear 0.49) on the FreeRunner appears to have a bug when sending the exit status back to the client. From time to time you receive an exit status of 255.<br />
<br />
To avoid ssh adding a new line for every ssh host-key to your known_hosts you can add the following to the phone section in ~/.ssh/config (or see the snippet at : [[USB Networking#Changing_host_keys]] bellow)<br />
<br />
UserKnownHostsFile /dev/null<br />
<br />
You might want to use keys to bypass the login prompt too.<br />
<br />
== SSH Keys ==<br />
<br />
== From desktop to FreeRunner ==<br />
<br />
To generate ssh keys for use as a login mechanism type:<br />
<br />
user@host$ ssh-keygen -t rsa<br />
<br />
When prompted for a password either hit enter for no password (''not really a good idea'') or enter a password for this key. ssh into the phone and create ~/.ssh:<br />
<br />
root@phone# mkdir ~/.ssh<br />
<br />
Then from your desktop copy the '''.pub''' file to the phone.<br />
<br />
user@host$ scp ~/.ssh/id_rsa.pub root@phone:~/.ssh/authorized_keys<br />
<br />
You should now be able to ssh directly into the phone without a password prompt using a command like 'ssh root@phone' from the account user@host because the public key in the file user@host:~/.ssh/id_rsa.pub is contained in the list of keys which have access in the file root@phone:~/.ssh/authorized_keys (since scp is used, only one key exists, but you can grant access to the phone from more than one account, for example user@host, user@laptop).<br />
<br />
To make ssh login as root by default, add the following lines to ~/.ssh/config:<br />
<br />
Host phone<br />
User root<br />
<br />
Replace ''phone'' with the hostname or ip of your phone. You should now be able to ssh into the phone without having to type ''root@'' every time.<br />
<br />
To disable password logins ('''after setting up key access''') edit /etc/init.d/dropbear and change the following line:<br />
<br />
DROPBEAR_EXTRA_ARGS=<br />
<br />
to<br />
<br />
DROPBEAR_EXTRA_ARGS="-s"<br />
<br />
You will need to restart dropbear for this to take effect.<br />
<br />
=== From FreeRunner to Desktop ===<br />
<br />
Generate the key:<br />
<br />
dropbearkey -t rsa -f id_rsa<br />
<br />
The output will look something like this:<br />
<br />
Will output 1024 bit rsa secret key to 'id_rsa'<br />
Generating key, this may take a while...<br />
Public key portion is:<br />
ssh-rsa AAAAB3Nza[...]<br />
Fingerprint: md5 ca:e8:f0:b7:f6:7b:c2:b6:b9:71:e4:45:86:a9:ff:b8<br />
<br />
Copy and paste the one line (in this example, starting with 'ssh-rsa' onto the end of the host's authorized_keys file (often in ~/.ssh/).<br />
<br />
From the phone, ssh with -i:<br />
<br />
ssh -i id_rsa user@host<br />
<br />
=== Changing host keys ===<br />
<br />
If you reflash, your hosts keys will change. Try this ~/.ssh/config snippet:<br />
<br />
Host moko<br />
HostName 192.168.0.202<br />
StrictHostKeyChecking no<br />
UserKnownHostsFile /dev/null<br />
User root<br />
<br />
This is suggested because ssh on your desktop may complain if the key matching a certain IP changes (stored in .ssh/known_hosts). Now you have set this, you can issue the following command to connect to your moko :<br />
<br />
ssh root@moko<br />
<br />
== GUI on desktop through SSH ==<br />
<br />
To get the GUI on the FreeRunner onto the desktop via USB, you can use ssh as follows:<br />
<br />
ssh -l root -X -v 192.168.0.202<br />
<br />
Using this, run openmoko-finger-demo for example, and it will open up on the desktop. To get landscape view, just resize the GUI window on the desktop.<br />
<br />
If you get an error like this:<br />
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to<br />
autolaunch D-Bus session: Autolaunch requested, but X11 support not compiled in.<br />
you need to set the DBUS_SESSION_BUS_ADDRESS environment variable to the value on the FreeRunner before launching the process from your desktop. You can find the value of this variable by using a command such as<br />
ps auxwwwwe | grep -m 1 DBUS_SESSION_BUS_ADDRESS<br />
Note that you must run that command on the FreeRunner. Back on your desktop, run the process you want with the ''env'' command like this:<br />
env DBUS_SESSION_BUS_ADDRESS=''dbus_address'' ''process'' #(isn't the "env" redundant here?)<br />
<br />
==Display Remote Applications on FreeRunner==<br />
<br />
To get desktop apps to show up on your FreeRunner, first log in:<br />
<br />
ssh -l root 192.168.0.202<br />
<br />
Then run:<br />
<br />
DISPLAY=:0 xhost +192.168.0.200<br />
<br />
After this you can close the ssh session. Back on the desktop computer, run:<br />
<br />
DISPLAY=openmoko:0 xclock<br />
<br />
Note that the xhost command will allow remote applications on 192.168.0.200 to access the X server. It will allow anyone on the desktop machine to access the X server of the neo, including snooping anything you type on it. To disallow remote applications again, run this in the neo:<br />
<br />
DISPLAY=:0 xhost -192.168.0.200<br />
<br />
== sftp ==<br />
After you get the SSH connection working, it is possible to use Konqueror, Nautilus or another sftp - enabled tool to browse the phone filesystem and deploy the test applications. Just enter sftp://root@192.168.0.202 into address bar.<br />
<br />
==Automated setup network and mounting partitions==<br />
<br />
See [https://bugs.launchpad.net/ubuntu/+bug/289548 Ubuntu bug report in launchpad].<br />
<br />
<span id="bottom"></span><br />
{{Languages|USB Networking}}<br />
<br />
[[Category:USB]]<br />
[[Category:Implemented]]<br />
[[Category:Networking]]</div>Kostigoff