These changes are done in the computer where you plug the USB connection into!
Kernel
First, you need to build your custom kernel. This is important.
I assume you have already set up your USB working so that you can
connect USB devices to your computer.
Ensure that the following settings are as shown:
- Device Drivers / USB support:
- Support for host-side USB: Y. This must not be a module!
- USB network adapters:
- Multi-purpose USB Networking framework: Y.
- Host for RNDIS devices: Y. This must not be a module!
If rndis is built as a module, usbcore will ignore RNDIS devices, and your ethn device cannot be found.
- Networking / Networking options:
- 802.1d Ethernet Bridging: Y or M.
It is not mandatory to use bridging (you could set up NAT instead),
but I chose this option, and this documentation is based on that.
Compile the kernel with these changes, and reboot.
You must reboot for the changes in RNDIS+usbcore to take effect;
modprobe/rmmod won't help.
Software
Install
bridge-utils.
If you use Gentoo like I do, the command is:
USE=sysfs emerge bridge-utils.
The USE flag is not necessary, but I chose it for possible future purposes.
_-Setting up the bridge
This is a quick HOW-TO on bridges on Linux.
- I had: eth0, which is an Ethernet card, and has address 10.104.4.15.
- I had: eth1, which is the rndis interface, which represents the cellular phone.
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1
ifconfig eth0 0.0.0.0
ifconfig eth1 0.0.0.0
ifconfig br0 10.104.4.15 <-- this is the IP eth0 previously had
route add default gw 10.104.4.14 <-- this is the router's IP, aka. gateway address
Explanation: A bridge connects multiple network interfaces together, making
them act as one. This command sequence assimilates the settings of eth0
into br0 (which was created here).
Peers behind eth0 will observe that your ethernet pipe hosts two IP addresses:
the one you configured to the bridge, and the traffic that comes through your
phone.
Now try to access Internet using your phone, using the interface
you created (by the name you gave).
Note: If your kernel crashes in a kernel-panic when you do that, try the following
workarounds, which helped:
- Compile your network card driver into the kernel instead of having it as a module.
- Cease all network access (including NFS mounts) before creating the bridge.
- In Gentoo, /etc/init.d/nfs stop
- After creating the bridge, remount the NFS shares if necessary. (/etc/init.d/nfs start)
This resolved the issue for me.
Every time you disconnect and reconnect your phone to the USB cable,
you need to repeat these commands:
brctl addif br0 eth1
ifconfig eth1 0.0.0.0