[G1 Android Development] billc.cn:
If you have any experience with *nix, you may want to look at Cyanogen's original usb tether shell script:

http://github.com/cyanogen/android_vendor_cyanogen/blob/master/bin/usb-tether

Basically you could use the internet connection sharing function that comes with all popular OSes and access your uni's network on your phone. You must have Cyanogen mod or another mod using his kernel. Not yet working on OSX for some reason. Tested under Windows 7.

First you'll need to figure out what IP address range your computer's DHCP server is using. This is normally fixed for each OS. For Windows 7, it's always 192.168.137.0/24.

For OSX or Linux, you can setup connection sharing (for some other connection because we don't have the USB interface yet) and ifconfig.

Second is to enable the USB connection on the phone's side. Type the following command in any console program, like Connectbot. (You must use a console program as opposed to adb because you will lose USB debugging once the USB network interface is enabled.)

su
cd /sys/devices/virtual/net/usb0
ifconfig usb0 192.168.137.200 mask 255.255.255.0
echo 1 > enable

The first line makes you the superuser. (Skip if the command prompt is #)

The second line land you in usb0's directory under sys. We'll need to type the disable command later, so it's easier if we're here.

The third line brings up the virtual usb network interface and sets its IP address.

The IP address should be in the same network (i.e. IP address range) you obtained in step 1. Say if the original is 192.168.137.1 in a /24, you can use 192.168.137.2 through 192.168.137.254

This actually enables the usb interface.

You will now see a new network adapter is recognized by your computer. Set up connection sharing to share your internet TO that adapter.

Make sure you have connection by pinging your computer from your phone.

For example:

ping 192.168.137.1

Now you'll have to change the routes so traffic go through the USB cable instead of the mobile network.(# is the command prompt, do not enter)

# busybox route

check the line starting with "default". Write down the ip address after it; call it IP1.

# getprop net.dns1

Call the IP returned IP2.

busybox route del default gw IP1
busybox route add -host IP2 rmnet0
busybox route add default gw 192.168.137.1

The first line deletes the old default route via the mobile network.

The second line adds an "exception" for your carrier's DNS server.

The third line adds the new route via USB. You should replace the address at the end with the IP address from the first step.

Your network should be working now. Test by visiting some website that is only available on campus or by traceroute.

You must make sure the mobile network is always connected though. This is because domain names are still resolved by your mobile carrier. If you ever lose your mobile connection, the routing table will be changed as well.

To disconnect:

Make sure you're still in /sys/devices/virtual/net/usb0.(Use pwd if unsure.)

netcfg usb0 down
echo 0 > enable

The usb interface will disappear on your computer.

Now switch the phone to airplane mode and back to re-enable mobile network.

The disconnect step should always restore your phone's state.

// This is written at 3am, so use it at your own risk...