Project

General

Profile

USBNetworking » History » Version 27

Denis 'GNUtoo' Carikli, 09/22/2020 06:56 PM
Fix bug #2127

1 26 dl lud
h1. USB Networking
2 9 Paul Kocialkowski
3 23 Wolfgang Wiedmeyer
{{>toc}}
4
5 17 Wolfgang Wiedmeyer
This page explains how to connect your Replicant device to the Internet via an USB connection to a computer connected to the Internet.
6 14 Paul Kocialkowski
7 17 Wolfgang Wiedmeyer
h2. Replicant 6.0
8 1 Paul Kocialkowski
9 27 Denis 'GNUtoo' Carikli
Replicant USB Networking requires a script: "usb_networking_device.sh":https://git.replicant.us/replicant/vendor_replicant-scripts/plain/networking/usb/usb_networking_device.sh
10 19 Wolfgang Wiedmeyer
Make sure to have [[ADB]] installed and to have the [[ADB#Accessing-root-shell|host daemon running as root]].
11 17 Wolfgang Wiedmeyer
12
h3. Preparing the device
13
14
Push the script on the device, make it executable and run the first part of the script:
15
16
<pre>
17
adb push usb_networking_device.sh /data/
18
adb shell chmod a+x /data/usb_networking_device.sh
19
adb shell /data/usb_networking_device.sh start1
20
</pre>
21
22
h3. Setting up the connection on the PC
23
24
The network manager applet on your PC (usually accessible through the network icon on your taskbar) should now display the device as a new wired interface. Below the name of the device should be a list of available connections. Depending on your network configuration, the list might be empty or offers one or more entries.
25
26
If your PC is connected to the Internet via Ethernet, a connection with the name "Auto-Ethernet" or a similar name could be available. Selecting this option should be enough to configure the connection and you can skip most of the steps below and continue with step 5. If there are issues with your connection, you will have to start again and do the rest of the steps, too.
27
28
If your PC uses Wi-Fi and Ethernet-based connections are suggested for your device, selecting one of them will likely not work. You will have to set up a new Ethernet-based connection.
29
30
The following steps are required to set up a new network connection for the device:
31
32
1. In the network manager applet, create a new "Ethernet" or "Wired" connection.
33
2. In the tab for IPv4 settings, select the method "Shared to other computers".
34 18 Wolfgang Wiedmeyer
3. Save the connection, preferably with a distinguishable name (The name can be changed at the top of the edit window).
35 17 Wolfgang Wiedmeyer
4. Select this connection for your device.
36
5. Now run the second part of the script on the device:
37
38
<pre>
39
adb shell /data/usb_networking_device.sh start2
40
</pre>
41
42
The connection should now work.
43
44
The new connection is saved on your PC and you don't have to recreate it when connecting the device again. It is then only necessary to run the first part of the script, selecting the network connection for the device in case it is not auto-selected and to run the second part of the script.
45
46
h3. Stopping the network connection
47
48
To disconnect the device, run:
49
50
<pre>
51
adb shell /data/usb_networking_device.sh stop
52
</pre>
53
54
h2. Replicant 4.2
55
56
h3. Using reverse_tether.sh
57
58 15 Paul Kocialkowski
The @reverse_tether.sh@ script is part of AOSP and can be downloaded from: "reverse_tether.sh":https://raw.github.com/CyanogenMod/android_development/cm-10.1/scripts/reverse_tether.sh
59 1 Paul Kocialkowski
In order to start basic NAT networking between the host and the device, make sure to have installed [[ADB]] and to have the host daemon running as root. Then, use @reverse_tether.sh@ the following way:
60 15 Paul Kocialkowski
<pre>
61
./reverse_tether.sh rndis
62 1 Paul Kocialkowski
./reverse_tether.sh nat
63
</pre>
64 15 Paul Kocialkowski
65 17 Wolfgang Wiedmeyer
h3. Using the Replicant USB Networking scripts
66 15 Paul Kocialkowski
67 27 Denis 'GNUtoo' Carikli
Replicant USB Networking requires two scripts: "usb_networking_device.sh":https://git.replicant.us/replicant/vendor_replicant-scripts/plain/networking/usb/usb_networking_device.sh?h=replicant-4.2 "usb_networking_host.sh":https://git.replicant.us/replicant/vendor_replicant-scripts/plain/networking/usb/usb_networking_device.sh?h=replicant-4.2
68 1 Paul Kocialkowski
However, you can avoid the host part if your network manager can manage a shared connection.
69
70 15 Paul Kocialkowski
Make sure to have installed [[ADB]] and to have the host daemon running as root.
71 1 Paul Kocialkowski
72 15 Paul Kocialkowski
Push the device part on the device and make it executable:
73
<pre>
74 17 Wolfgang Wiedmeyer
adb push usb_networking_device.sh /data/
75
adb shell chmod a+x /data/usb_networking_device.sh
76 1 Paul Kocialkowski
</pre>
77
78 17 Wolfgang Wiedmeyer
*Using a network manager shared connection*
79 15 Paul Kocialkowski
80 1 Paul Kocialkowski
1. On your Linux PC, in the network manager applet (where you normally set up wired or wireless network connections), create a new "Shared" "Wired" connection, with default settings (connection type = Shared). (This is independent of the device, and only needs to be created once.)
81 15 Paul Kocialkowski
2. Disconnect any other network connections (Wifi, 3G data) on the device.
82
3. Run the first part of the device-side script:
83
<pre>
84 17 Wolfgang Wiedmeyer
adb shell /data/usb_networking_device.sh start1 dhcp
85 12 Paul Kocialkowski
</pre>
86 1 Paul Kocialkowski
4. The device should appear in the host's network manager applet as a new "wired" network connection. Connect this to the "Shared" connection that you created above (it should be in the list of choices given by the applet).
87 15 Paul Kocialkowski
5. Now run the second part of the script on the device:
88 1 Paul Kocialkowski
<pre>
89 17 Wolfgang Wiedmeyer
adb shell /data/usb_networking_device.sh start2 dhcp
90 1 Paul Kocialkowski
</pre>
91 15 Paul Kocialkowski
92 1 Paul Kocialkowski
The connection should now work. To disconnect the device, run:
93 15 Paul Kocialkowski
<pre>
94 17 Wolfgang Wiedmeyer
adb shell /data/usb_networking_device.sh stop
95 7 Paul Kocialkowski
</pre>
96 15 Paul Kocialkowski
97 17 Wolfgang Wiedmeyer
*Using the host script*
98 15 Paul Kocialkowski
99
1. Disconnect any other network connections (Wifi, 3G data) on the device.
100
2. Run the first part of the device-side script:
101 1 Paul Kocialkowski
<pre>
102 17 Wolfgang Wiedmeyer
adb shell /data/usb_networking_device.sh start1 static
103 15 Paul Kocialkowski
</pre>
104 1 Paul Kocialkowski
3. Wait for the interface to show up
105 15 Paul Kocialkowski
4. Configure the device interface:
106
<pre>
107 17 Wolfgang Wiedmeyer
adb shell /data/usb_networking_device.sh start2 static
108 15 Paul Kocialkowski
</pre>
109
5. Configure the host interface:
110
<pre>
111 17 Wolfgang Wiedmeyer
sudo ./usb_networking_host.sh start
112 15 Paul Kocialkowski
</pre>
113 12 Paul Kocialkowski
114 15 Paul Kocialkowski
The connection should now work. To disconnect the device, run:
115
<pre>
116 17 Wolfgang Wiedmeyer
adb shell /data/usb_networking_device.sh stop
117 15 Paul Kocialkowski
</pre>
118
Cleanup the host:
119
<pre>
120 17 Wolfgang Wiedmeyer
sudo ./usb_networking_host.sh stop
121 15 Paul Kocialkowski
</pre>