[Epic 4G Themes] mkasick:
Attached is a somewhat-crude shell script that enables wired USB networking ("reverse tethering") on the Epic. Sadly it's not a standalone app, and it doesn't have perfect application compatiblity either. However, some folks may find it useful in order to get Internet where neither cellular nor WiFi service is available.

Requirements:

Rooted Epic with busybox (one-click root satisfies this).

Host PC with Internet sharing capabilities.

ConnectBot or another terminal emulator.

The attached "usbnet.sh" script.

Initial setup:

First, setup the host PC for Internet sharing on the USB network interface:

On Windows, you'll need to install the Samsung USB drivers (if you already did for the one-click root or Wired Tether, you should be OK). The remaining part of the ICS setup on Windows has to be done the first time the script is ran on the phone, so it's covered below.

On Linux, you'll need to setup netfilter (for NAT), install & configure dnsmasq or another DHCP server, and enable IP forwarding. Details on those are outside the scope of this thread, but it's essentially the same as setting up network sharing for an Ethernet connection.

On the phone, install ConnectBot or an alternate terminal emulator. Unfortunately USB ADB and RNDIS can't be used simultaneously, so the script can't be run via "adb shell".

Next, copy usbnet.sh to the phone. It can go anywhere, although it can't be run from /sdcard directly. Good places are /data/local or /data/local/tmp. For example:

adb push usbnet.sh /data/local
adb shell chmod 755 /data/local/usbnet.sh

If you're using ConnectBot (recommended), create a "host" for the usbnet script. Enter "usbnet" in the bottom-of-the-screen input box, select "local" from the drop-down menu to the left, and press enter. At the "$" prompt, enter "exit", and close the session. Now "usbnet" will appear in the host list, long-press it, and select "Edit host". Select "Post-login automation" and enter:

exec su -c /data/local/usbnet.sh

substituting the appropriate path for "/data/local/usbnet.sh". Also, make sure to press Return to create a newline, otherwise the script won't execute automatically. Alternatively, if you're not using ConnectBot, you can run the script manually after su-ing to root.

Directions for use:

Before using, make sure "USB debugging" is disabled on the phone (unless you're running a patched custom kernel). Also make sure the USB cable is disconnected.

Next, disable WiFi, 4G, and the cellular data connection (long-press power and select either "Data network mode", which lets you still receive calls and SMSes, or "Airplane mode", which doesn't) as these interfere with the wired connection.

Open ConnectBot, and select the "usbnet" entry. Press "Allow" at the su prompt if it comes up. Now, connect the USB cable to the host PC, and select "Charging" from the "Select USB mode" menu.

If the host PC is running Windows, and this is the first time using the wired connection, you'll have to finish the inital setup. On Windows 7, go to Control Panel -> Network and Internet -> Network and Sharing Center -> Change adapter settings. Once the USB cable is plugged in a new "Local Area Connection" should appear (e.g, "Local Area Connection 3") for the phone. You can unplug and replug the USB cable to verify which is the phone's connection, it will disappear and reappear.

Now, right-click the other network adapter that's providing the Internet connection for the host PC. It's likely "Local Area Connection" for Ethernet, and "Wireless Network Connection" if wireless. Select Properties, and click on the Sharing tab. Check "Allow other network users to connect through this computer's Internet connection", and if it asks to select a "Home networking connection" (which it should if you have three or more adapters, including the phone, in total), select the phone's adapter (e.g., "Local Area Connection 3"). Then click OK.

Note that, on Windows, to setup sharing the phone's network adapter must be present, which is why it must be done after first running the usbnet script. The sharing setting does persist across disconnects, so the previous setup only needs to be done once unless sharing is manually disabled.

No additional setup should be required if the host PC is running Linux, although you may have to manually assign an IP address to the USB network interface (host side) and manually start dnsmasq/dhpd depending on your configuration.

At this point, the phone should report "netcfg usb0 dhcp ... wait ..." while it attempts to acquire an IP address from the host PC. On Windows, this may take a minute or longer. If for some reason it's unable to get an IP address (may happen during first time setup on Windows) it will report "action 'dhcp' failed (Timer expired)". If it does, unplug the USB cable, select the "usbnet" entry again, and replug the USB cable.

Once the phone acquires an IP address, the usbnet script will print out a table of network adapters and IP addresses (one of which includes the address for usb0) and exit. The connection should be working now.

To disconnect, run "usbnet" from ConnectBot again, which will bring down the connection, reset the USB mode, and exit. Now you can unplug the USB cable, and reenable the cellular ("Data network mode"), WiFi, or 4G connections.

Known issues:

Since the usbnet script operates below the Android framework, it can't tie into the connectivity service and notify waiters than a network connection is available. This doesn't matter for most apps, and they should work just fine. Others won't "believe" a network connection is available and refuse to work. In testing I found that ConnectBot, Maps, Market, and Opera Mobile all work, but that the Amazon Appstore does not. I'm uncertain, but I think sync services (e.g., Calendar) may not work either. To my knowledge, there's no obvious place to tie into the framework to increase application compatibility. Hopefully this is still useful for most of the purposes of folks wanting wired connectivity.

The Linux rndis_host driver is rather finicky, even more so then when using Wired Tether. In testing, I found between half to 2/3rds of connection attempts to a Linux host would fail, but once connected, it seems to work fine.

Again, on Windows, getting an IP address is very slow, I'm not sure if anything can be done about that.

Also, I've only been able to test on EC05 (Froyo). I'm unlikely to be able to test this on Gingerbread before the official release hits.

Mirror link (does not require forum login):

usbnet.sh