|
|
(3 intermediate revisions by the same user not shown) |
Line 4: |
Line 4: |
| | | |
| For issues with connectivity, visit [[RaspberryPi:DebuggingConnectivity]] | | For issues with connectivity, visit [[RaspberryPi:DebuggingConnectivity]] |
− |
| |
− | = Static IPs =
| |
− | Setting a static IP makes it easy to access the Pi and ensures that the IP address of the Pi is always known. In this wiki, we assign the Pi an IP address of 192.168.137.15. The reason for this is that when using network sharing on Windows, Windows asserts a domain of 192.168.137.x, with the host PC being assigned 192.168.137.1. Keep in mind that all devices will need to be on the same subnet.
| |
− |
| |
− | == Setting a static IP on your Desktop ==
| |
− | === Windows ===
| |
− | <span class="mw-customtoggle-WindowsIP" style="font-size:small; display:inline-block; "><span class="mw-customtoggletext" data-expandtext="Illuminate" data-collapsetext="Deluminate">[Show/hide]</span></span>
| |
− | <div id="mw-customcollapsible-WindowsIP" class="mw-collapsible mw-collapsed">
| |
− | To change the IP of your Ethernet port on Windows 10, complete the following steps:
| |
− |
| |
− | * Right click on your network option in Windows taskbar
| |
− | * Select“Open Network & Internet Settings”, on the lower right hand side of the screen.
| |
− | * Select “Change Adapted Options”
| |
− | * Right click on the Ethernet Connection and select “Properties”
| |
− | * Select “Internet Protocol Version 4 (TCP/IPv4) and click ”Properties"
| |
− | * Select “Use the following IP address:” and enter in the following options:<br />
| |
− | - IP Address: 192.168.137.1<br />
| |
− | - Subnet Mask: 255.255.255.0
| |
− | * You have successfully changed the IP of the Ethernet card on your computer. It is suggested that you now ensure connectivity by attempting to ping the Pi.
| |
− |
| |
− | [[File:windowsIPConfig.png|thumb|none|alt=|The IPv4 configuration screen in Windows 10]]
| |
− | </div>
| |
− | === Ubuntu ===
| |
− | <span class="mw-customtoggle-UbuntuIP" style="font-size:small; display:inline-block; "><span class="mw-customtoggletext" data-expandtext="Illuminate" data-collapsetext="Deluminate">[Show/hide]</span></span>
| |
− | <div id="mw-customcollapsible-UbuntuIP" class="mw-collapsible mw-collapsed">
| |
− | To change the IP of your Ethernet port on Ubuntu, complete the following steps:
| |
− |
| |
− | * Click the network interface icon on the status bar and select Wired Settings
| |
− | * Click the gear button of the interface you’d like to change
| |
− | * Select the IPv4 Tab, and change the IPv4 method to Manual
| |
− | * Under “Addresses” enter in the following:<br />
| |
− | - IP Address: 192.168.137.1<br />
| |
− | - Subnet Mask: 255.255.255.0
| |
− | * You can leave Gateway and DNS blank
| |
− |
| |
− | [[File:Ubuntustaticip.png|thumb|none|alt=|The IPv4 configuration screen in Ubuntu 18.10]]
| |
− | </div>
| |
− |
| |
− | == Setting a static IP on the Pi ==
| |
− | To set a static IP on the Pi, you have multiple options. You can do it before first boot by addling a line to cmdline.txt on the boot partition of the SD card, or once the Pi is running by editing dhcpcd.
| |
− | === From the boot partition ===
| |
− | <span class="mw-customtoggle-PiStaticBoot" style="font-size:small; display:inline-block; "><span class="mw-customtoggletext" data-expandtext="Illuminate" data-collapsetext="Deluminate">[Show/hide]</span></span>
| |
− | <div id="mw-customcollapsible-PiStaticBoot" class="mw-collapsible mw-collapsed">
| |
− | <ol>
| |
− | <li><p>Insert the SD card into your computer and navigate to the BOOT partition</p></li>
| |
− | <li><p>Open “cmdline.txt” and append the following to the line (don’t create a new line)</p>
| |
− | <pre> ip=192.168.137.15 </pre>
| |
− | <p>This tells the Raspberry Pi to configure the Ethernet port to use the IP address 192.168.137.15</p></li>
| |
− | <li><p>Enable SSH as per Section [sec:SSH].</p></li>
| |
− | <li><p>You need to configure your PC to use the same subnet as the Pi. To do so, see the information below in the section on Assigning a static IP to the Pi.</p></li></ol>
| |
− | </div>
| |
− | === In dhcpcd (while the Pi is running)===
| |
− | <span class="mw-customtoggle-PiStaticDHCPCD" style="font-size:small; display:inline-block; "><span class="mw-customtoggletext" data-expandtext="Illuminate" data-collapsetext="Deluminate">[Show/hide]</span></span>
| |
− | <div id="mw-customcollapsible-PiStaticDHCPCD" class="mw-collapsible mw-collapsed">
| |
− | Once you’ve successfully SSH’d into your Pi, it’s a good idea to configure the networking options in the config files directly. You will need to set a static IP on the computer first if you are SSH'ing through an Ethernet connection.
| |
− |
| |
− | Use a text editor such as nano to open /etc/dhcpcd.conf as sudo user, and edit it to the following:
| |
− |
| |
− | <pre># Static IP profile for eth0
| |
− | profile static_eth0
| |
− | static ip_address=192.168.137.15/24
| |
− | static routers=192.168.137.1
| |
− | static domain_name_servers=192.168.137.1 8.8.8.8
| |
− |
| |
− | # Ethernet interface configuration
| |
− | interface eth0
| |
− | fallback static_eth0
| |
− |
| |
− | # Wireless configuration
| |
− | interface wlan0
| |
− | metric 200</pre>
| |
− | </div>
| |
− |
| |
− | = Providing your Pi with wireless Internet Access =
| |
− |
| |
− | There are two possible methods of this that will be presented, each with it’s own advantages and disadvantages.
| |
− |
| |
− | The first is using Ethernet passthrough from your computer to the Raspberry Pi. This leaves the WiFi free to host your own access point, and you can host services such as a Node-Red server or media center on the Pi.
| |
− |
| |
− | The second involves connecting to a wireless network. In the example we give you, we're only going to add a connection to Eduroam. While you could host other services on the Pi when using WiFi connectivity, it would require some access to port forwarding and other things that ICTS unfortunately won’t allow.
| |
− |
| |
− | == Using WiFi to Ethernet passthrough to give your Pi internet access ==
| |
− |
| |
− | There may be a situation in which you want your Pi to work as an access point rather than using the WiFi interface to provide the Pi with internet access. In this situation, you need to get internet access through the ethernet port. If you’re connected to Windows, you can use network sharing. Complete the following to enable network sharing:
| |
− |
| |
− | === Windows ===
| |
− | # Ensure the Pi is unplugged
| |
− | # Right click on your network option in Windows taskbar
| |
− | # Select “Open Network & Internet Settings”, on the lower right hand side of the screen.
| |
− | # Select “Change Adapted Options”
| |
− | # Right click on your WiFi network and select “Properties”
| |
− | # Click the “Sharing” tab, and enable the first checkbox <ref>This setting is what forces us to have to use the subnet 192.168.137.x.</ref>
| |
− | # Select the Ethernet connection that your Pi will be using in the drop down box (Usually just “Ethernet”, but may be different if there are multiple Ethernet posts on your system)
| |
− |
| |
− | [[File:Windowspassthrough.png|thumb|none|alt=|Using WiFi to Ethernet passthrough in Windows]]
| |
− |
| |
− | === Ubuntu ===
| |
− | # Ensure the Pi is unplugged and turned off.
| |
− | # Open a terminal and run <code>nm-connection-editor</code>
| |
− | # Select the wired connection you’d like to share your WiFi to
| |
− | # Select the IPv4 settings tab
| |
− | # Under Method, select “Shared to other computers”
| |
− | # under the IP addresses, click “Add” and enter in an address of 192.168.137.1, and a netmask of 24
| |
− | # Select “Save”, and close the windows
| |
− | # Plug in the Pi, start an SSH session and see if you can ping google.co.za
| |
− |
| |
− | [[File:Nm-connection-editor.png|thumb|none|alt=|nm-connection-editor in Ubuntu 18.10]]
| |
− |
| |
− | == Eduroam Connectivity ==
| |
− | Connecting to Eduroam requires a fair amount of configuration which depends on your operating system. Generally though, edits to wpa_supplicant.conf and dhcpcd.conf are sufficient.
| |
− | === Raspbian Buster (Raspbian Site) ===
| |
− | '''Note:''' There have been updates to the Buster code base, and roll back of wpasupplicant might not be required. However this is currently unable to be tested due to the lockdown. If someone has the chance to test, please update this page acoordingly.
| |
− | These instructions come from [https://www.raspberrypi.org/forums/viewtopic.php?p=1501822#p1501822 here].<br />
| |
− | Unfortunately, when you use bleeding edge technology, you may end up cutting yourself. Raspbian Buster updates <code>wpa_supplicant</code> to a version that doesn’t have support for the authentication method used by Eduroam. So we need to roll back <code>wpa_supplicant</code> to an older version. Ensure your Pi has internet access through a method such as Ethernet passthrough, and run the following:
| |
− |
| |
− | <pre>$ sudo apt-get remove wpasupplicant</pre>
| |
− | Edit /etc/apt/sources.list :
| |
− |
| |
− | <pre>$ sudo nano /etc/apt/sources.list</pre>
| |
− | And change
| |
− |
| |
− | <pre>deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi</pre>
| |
− | to
| |
− |
| |
− | <pre>deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi</pre>
| |
− | Run
| |
− |
| |
− | <pre>$ sudo apt-get update
| |
− | $ sudo apt-get install wpasupplicant</pre>
| |
− | This will install the correct version of <code>wpa_supplicant</code>. Check that '''version 2.4''' is installed by running
| |
− |
| |
− | <pre>$ wpa_supplicant -v</pre>
| |
− | Now, change the sources file back.
| |
− |
| |
− | <pre>$ sudo nano /etc/apt/sources.list</pre>
| |
− | And edit the contents to contain
| |
− |
| |
− | <pre>deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi</pre>
| |
− | Finally, run
| |
− |
| |
− | <pre>$ sudo apt-get update</pre>
| |
− | To update sources The correct version of <code>wpa_supplicant</code> should now be installed, and you can configure your Pi for WiFi as you would if you were using Raspbian Stretch as explained in below.
| |
− |
| |
− | === Raspbian Stretch (Vula) ===
| |
− |
| |
− | This section provides the instructions on how to configure the Pi to use Eduroam. It is possible to do using the GUI through VNC, but we will not cover that here.
| |
− |
| |
− | <ol>
| |
− | <li><p>SSH into your Pi.</p></li>
| |
− | <li><p>Generate a hash for your password. Take note of it as it is needed in a later step</p>
| |
− | <pre>
| |
− | $ echo -n your_uct_password_here | iconv -t utf16le | openssl md4
| |
− | </pre></li>
| |
− | <li><p>Open /etc/wpa_supplicant/wpa_supplicant.conf</p>
| |
− | <pre>$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf</pre></li>
| |
− | <li><p>Edit it so it looks as follows:</p>
| |
− | <pre>
| |
− | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
| |
− | update_config=1
| |
− | country=ZA
| |
− |
| |
− | network={
| |
− | ssid="eduroam"
| |
− | key_mgmt=WPA-EAP
| |
− | identity="studentnumber@wf.uct.ac.za"
| |
− | password=hash:generated_hash_from_earlier
| |
− | }
| |
− | </pre></li>
| |
− | <li><p>Save the file</p></li>
| |
− | <li><p>Open <code>/etc/dhcpcd.conf</code></p>
| |
− | <pre> $ sudo nano /etc/dhcpcd.conf</pre></li>
| |
− | <li><p>Make sure the following lines are in the document:</p>
| |
− | <pre>interface wlan0
| |
− | metric 200
| |
− | </pre></li>
| |
− | <li><p>Reboot your Pi</p></li>
| |
− | <li><p>WiFi Generally takes a little longer to initialize than Ethernet, so give it time. You can see if it’s ready by running</p>
| |
− | <pre>$ ifconfig </pre>
| |
− | <p>And seeing if an IPv4 address (“inet”) has been given.</p></li>
| |
− | <li><p>Test your configuration by pinging from the WiFi interface:</p>
| |
− | <pre>$ ping google.com -I wlan0</pre></li></ol>
| |
| | | |
| = Configuring the Pi to Act as an Access Point = | | = Configuring the Pi to Act as an Access Point = |
Line 263: |
Line 82: |
| <pre>iptables-restore < /etc/iptables.ipv4.nat</pre></li></ol> | | <pre>iptables-restore < /etc/iptables.ipv4.nat</pre></li></ol> |
| </div> | | </div> |
− |
| |
− | = TTL over USB =
| |
− |
| |
− | '''Note:''' The Pi uses 3.3V logic levels. Using a 5V logic module will permanently damage the pins.
| |
− |
| |
− | This option allows you to use a USB to UART converter such as a FT232R or CP2102. Begin by removing the SD card, and insert it into a computer. Make the following changes on the boot partition:
| |
− |
| |
− | cmdline.txt: add the following (on the same line)
| |
− |
| |
− | <pre>console=serial0,115200 </pre>
| |
− | config.txt
| |
− |
| |
− | <pre>uart_enable=1
| |
− | dtoverlay=pi3-disable-bt</pre>
| |