Skip to content

NAT Router

Oliver Schmidt edited this page Feb 2, 2021 · 1 revision

Enable IPv4 packet forwarding with

sudo nano /etc/sysctl.conf

Remove the # from the line below, then save (Ctrl-O, Enter) and exit (Ctrl-X).

net.ipv4.ip_forward=1

Provide a static IPv4 address for the Ethernet interface with

sudo nano /etc/dhcpcd.conf

Add the lines below, then save and exit.

interface eth0
static ip_address=10.10.10.10/8

Install and configure Dnsmasq, a lightweight DHCP and DNS server, with

sudo apt install dnsmasq
sudo nano /etc/dnsmasq.conf

Add the lines below, then save and exit.

interface=eth0
dhcp-range=10.20.30.40,10.20.30.40,2m

Activate NAT (and forwarding of incoming TCP connections on ports 23, 80 and 6502 to the Apple II) with

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp -m multiport --dports 23,80,6502 -j DNAT --to 10.20.30.40

Install and use NAT persistence with

echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean false | sudo debconf-set-selections
sudo apt install iptables-persistent

Reboot with

sudo reboot

Use an Ethernet cable to connect the Apple II directly to the RPi. Apple II TCP/IP software behaves like it were directly connected to your network. Check it out with the Contiki web browser.

Download contiki-apple2.zip from Contiki Releases and extract contiki-apple2.po or contiki-apple2-1.dsk. Make the disk image accessible to the Apple II. First run ETHCONFI.SYSTEM, then IPCONFIG.SYSTEM and finally WEBBROWS.SYSTEM. Use Ctrl+C to quit the web browser. Find more information in the Contiki Wiki.

Note: When you want to connect to a server type program on the Apple II (like the Contiki web server or the Contiki Telnet server) you can't use the IPv4 address shown on the Apple II (10.20.30.40). Rather you have to connect to the WiFi IPv4 address of the RPi (the one you connect to with the SSH client). By default these connections are limited to TCP ports 23, 80 and 6502.

Clone this wiki locally