Raspberry Pi / Linux – Console/Terminal Server Access Point

Super easy out-of-band access to all your lab devices!

Wow!

Parts List

Install Raspbian (from linux)

Find drive letter:

df- lh
sudo fdisk -l

 

Unmount (using sdb as example):

umount /dev/sdb1

 

Extract image to SD card (takes a while):

dd bs=4M if=2019-09-26-raspbian-buster-full.img of=/dev/sdb

 

Boot the SD then update:

sudo apt update
sudo apt upgrade
sudo reboot

 

Change hostname:

sudo nano /etc/hostname

 

If file manager crashes:

sudo apt full-upgrade

 

Setup serial ports

Install ser2net:

sudo apt install ser2net

 

Find out where USB to Serial is connected:

dmesg | grep tty

 

Edit the ser2net configuration:

sudo nano /etc/ser2net.conf

 

File example:

BANNER:banner:\r\nMr Brays Terminal Server port \p device \d [\s] \r\n\r\n
DEFAULT:max-connections:300
4001:telnet:600:/dev/termserv0:9600 8DATABITS NONE 1STOPBIT banner
4002:telnet:600:/dev/termserv1:9600 8DATABITS NONE 1STOPBIT banner
4003:telnet:600:/dev/termserv2:9600 8DATABITS NONE 1STOPBIT banner
4004:telnet:600:/dev/termserv3:9600 8DATABITS NONE 1STOPBIT banner
4005:telnet:600:/dev/termserv4:9600 8DATABITS NONE 1STOPBIT banner
4006:telnet:600:/dev/termserv5:9600 8DATABITS NONE 1STOPBIT banner
4007:telnet:600:/dev/termserv6:9600 8DATABITS NONE 1STOPBIT banner
4008:telnet:600:/dev/termserv7:9600 8DATABITS NONE 1STOPBIT banner

 

Make sure Ser2Net starts up automatically:

sudo nano /etc/rc.local

 

Add the following above exit 0:

/usr/local/sbin/ser2net -n -c /etc/ser2net.conf

 

Create a log directory for ser2net sessions:

sudo mkdir /var/log/ser2net

 

Make persistent names for the serial ports

View the attributes you can use:

udevadm info -a -n /dev/ttyUSB0

 

Create and edit a rules file for persistant names:

sudo nano /etc/udev/rules.d/99-usb-serial.rules

 

Create your rules (matching via USB port location):

SUBSYSTEM=="tty", KERNELS=="1-1.2:1.0", SYMLINK+="termserv0"
SUBSYSTEM=="tty", KERNELS=="1-1.2:1.1", SYMLINK+="termserv1"
SUBSYSTEM=="tty", KERNELS=="1-1.2:1.2", SYMLINK+="termserv2"
SUBSYSTEM=="tty", KERNELS=="1-1.2:1.3", SYMLINK+="termserv3"
SUBSYSTEM=="tty", KERNELS=="1-1.4:1.0", SYMLINK+="termserv4"
SUBSYSTEM=="tty", KERNELS=="1-1.4:1.1", SYMLINK+="termserv5"
SUBSYSTEM=="tty", KERNELS=="1-1.4:1.2", SYMLINK+="termserv6"
SUBSYSTEM=="tty", KERNELS=="1-1.4:1.3", SYMLINK+="termserv7"

 

Setup as an AP

Install new software:

sudo apt install dnsmasq hostapd

 

Stop new software:

sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

 

Edit dhcpcd config:

sudo nano /etc/dhcpcd.conf

 

Add to the end:

interface wlan0
    static ip_address=192.168.1.1/24
    nohook wpa_supplicant

 

Restart dhcpcd:

sudo service dhcpcd restart

 

Configure DHCP:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf

 

Add to file:

interface=wlan0
dhcp-range=192.168.1.2,192.168.1.254,255.255.255.0,24h

 

Reload dnsmasq to use the updated configuration:

sudo systemctl reload dnsmasq

 

Configure the host access point:

sudo nano /etc/hostapd/hostapd.conf

 

Add the information below to the configuration file.

interface=wlan0
driver=nl80211
ssid=NameOfNetwork
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AardvarkBadgerHedgehog
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

 

We now need to tell the system where to find this configuration file:

sudo nano /etc/default/hostapd

 

Find the line with #DAEMON_CONF, and replace it with this:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

 

Now enable and start hostapd:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

 

Do a quick check of their status to ensure they are active and running:

sudo systemctl status hostapd
sudo systemctl status dnsmasq

 

Configure routing and masquerade:

sudo nano /etc/default/hostapd

 

Uncomment this line:

net.ipv4.ip_forward=1

 

Add a masquerade for outbound traffic on eth0:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

 

Save the iptables rule.

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

 

Edit /etc/rc.local:

sudo nano /etc/rc.local

 

Add this just above “exit 0” to install these rules on boot.

iptables-restore < /etc/iptables.ipv4.nat

 

Reboot and check if it works. lol.

 

Enable SSH (and VNC)

  1. Enter sudo raspi-config in a terminal window
  2. Select Interfacing Options
  3. Navigate to and select SSH
  4. Choose Yes
  5. Select Ok
  6. Do the same for VNC if needed.
  7. Choose Finish
  8. Increase VNC Resolution
    1. Uncomment: framebuffer_width=1900 and framebuffer_height=1024  in /boot/config.txt

 

 

 

 

NOTE: Web GUI section below is still being worked.

 

Web GUI

install Node.js

Check ARM version:

uname -m

 

Find the link to your appropriate download:
https://nodejs.org/en/download/

 

Download it:

wget https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-armv7l.tar.xz

 

Extract:

tar -xf node-v12.13.1-linux-armv7l.tar.xz

 

Copy to /usr/local:

cd node-v12.13.1-linux-armv7l/
sudo cp -R * /usr/local/

 

Confirm node/npm:

node -v
npm -v

 

Update:
npm install -g npm

<current snapshot end>

Make project folder:
sudo mkdir /srv/web-terminal

 

To be continued…..

Leave a Reply

Your email address will not be published. Required fields are marked *