Jump to content

RPi3 B+ headless indi-server with dhcp-server on both interfaces


Recommended Posts

Lots of guides out there on how to make a wifi hotspot with a RPi, and even some on how to make a headless indi-server. Combining those are piece-of-cake, but I wanted a setup where I could choose if I want to connect on wifi or cabled as long as my own device was configured to receive IP's on the interface I wanted to use. That meant that the headless Pi had to offer IP's on BOTH wifi and cable.

Not well tested, but it worked wih my Canon 450D connected to my Raspberry Pi3 B+. For us nerds,  work in progress, open for suggestions.

Next episode will deal with images, sizes and compression. For backup and distribution. If there is some interest out there......

indiserver-hotspot-1.0
-----------------------
# THIS IS NOT A BASH SCRIPT, though it looks like one.
# Default user is <pi> and default password used when SSH'ing in is <raspberry>

# How to put together an image for Raspberry Pi3 B+ that handles out
# IP's on both interfaces, accepts SSH connections and serves as a headless INDI-server.

# Base image: 2021-05-07-raspios-buster-armhf-lite.img
# Can be found at
https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-05-28/2021-05-07-raspios-buster-armhf-lite.zip
# Unzip and flash to SD-card.

# Config files enlosed in ---------------------------

# After first boot the Pi will expand the file system to use the whole
# SD-card and reboot by itself.
# After this reboot, start with theese commands (with monitor & keyboard):

# Set locale, keyboard layout & countrycode for wifi
# Activate SSH
sudo raspi-config

# Fresh start
sudo apt update
sudo apt upgrade
sudo reboot

# We install the software needed.
# First hostapd
# hostapd makes the wifi able to deal out ip's.
sudo apt install hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd

# Then dnsmasq
sudo apt install dnsmasq

# This is my config file for dhcpcd. Edit with nano.
# When finished, Ctrl+O Enter Ctrl+X Enter
# Some options may be removed, but this works for me. No expert.
sudo nano /etc/dhcpcd.conf
---------------------------
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option interface_mtu
require dhcp_server_identifier
slaac private
interface wlan0
    static ip_address=192.168.50.2/24
    nohook wpa_supplicant
interface eth0
    static ip_address=192.168.50.1/24
---------------------------

# The config for the dhcp server.
# Same here,this file might be trimmed down some.
sudo nano /etc/dnsmasq.conf
---------------------------
interface=wlan0
dhcp-range=192.168.50.10,192.168.50.20,255.255.255.0,24h
domain=indiserver
address=/pi.indiserver/192.168.50.2
interface=eth0
dhcp-range=192.168.50.30,192.168.50.40,255.255.255.0,24h
domain=indi
address=/pi.indi/192.168.50.1
---------------------------

# Unlocks the wifi. Not sure if this is needed. Better safe than sorry.
sudo rfkill unblock wlan

# Config for the wireless hotspot. Feel free to use own SSID/password
# Also, use your own countrycode.
sudo nano /etc/hostapd/hostapd.conf
---------------------------
country_code=NO
interface=wlan0
ssid=indiserver
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
---------------------------

# Get repo key and add the astroberry repo
wget -O - https://www.astroberry.io/repo/key | sudo apt-key add -
sudo su -c "echo 'deb https://www.astroberry.io/repo/ buster main' > /etc/apt/sources.list.d/astroberry.list"
sudo apt update

# Theese are the drivers I need.
# For the complete set, use "sudo apt install indi-full"
# Adds about 15 mb of space
sudo apt install indi-asi indi-gphoto indi-eqmod

# Clean apt cache
sudo apt clean

# A reboot. Now the dhcp-server should work on both interfaces.
# At this point the Pi don't have access to the internet.
# Remove keyboard. Keep the monitor just in case, to catch any boot errors.
# From now on, the Pi is truly headless.
sudo systemctl reboot

# You should be able to SSH in either wireless or on a LAN cable directly connected
# I was able to connect on both Ip's on two terminal windows at the same time.
#
# The whole point of this setup is to be able to choose between wifi and cabled.
# When my StarTracker is just outside my house, the weather is warm and the signal is strong
# it's convenient to use the wifi. The Pi runs of the same 12V battery (via a cigarette lighter USB adapter)
# as my dew heater. And sometimes my tracker to, via an adapter like the one for the Pi.
# When I set up in the same spot for several nights, I use a cable and connect directly.
# It gives faster download times and less hazzle.
# The download speed on wifi will vary with your signal and equipment.
# Do some read-up on the option "hw_mode" in /etc/hostapd/hostapd.conf
# The RPi3 B+ that I use is somewhat crippled, but the RPi4 should give good speed on wifi,
# along with two USB3-ports.
#
# As seen in /etc/hostapd/hostapd.conf the wifi SSID is <indiserver> and the password is <raspberry>
# The machine you use to connect with must accept IP's via dhcp on the interface you use.
# The Pi's IP on wlan0 is 192.168.50.2 and on eth0 192.168.50.1
# Use theese to SSH in.

# The INDI-server(s) don't start automagically. I prefer to SSH in and start them in the shell.
# It gives valuable feedback, and it's easy to stop them with Ctrl+C
# Just as easy to start again, usually I use Arrow+Up and Arrow+Down to parse bash history
# INDI-servers can be started one at a time or several at once:
#
indiserver indi_canon_ccd indi_asi indi_eqmod
# for my imaging rig or just
indiserver indi_canon_ccd
# when I use my DSLR on my startracker.

# ALWAYS TURN ON YOUR EQUIPMENT BEFORE YOU START THE INDI-SERVERS
# Good practice. The Pi is the last thing powered on outside.
# I also wait a minute for it to settle before I power on my laptop
# that runs KStars/Ekos. Lot easier when the hotspot is up and running.

 

Edited by Rallemikken
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.