Many of the games supported by the DreamPi require port forwarding or DMZ allocation for a game play connection to be established between players. In order to configure port forwarding or DMZ allocation, the IP address assigned to the Dreamcast, not the DreamPi, must be known and leased without regularly changing. Otherwise, one would have to potentially update their port forwarding or DMZ allocation network configuration every time the Dreamcast was reconnected to the network through the DreamPi.
For the vast majority of users, the DreamPi successfully mitigates this issue through its auto configuration script. It determines the first 3 octets (e.g. the "192.168.1" part of "192.168.1.1") of your local network and then finds an available IP address checking in increments of -1 starting at .100. My assumption here is that this implementation method was implemented because the DHCP range configured for most router manufacturers start with the final octet of .100. The typical result is a DreamPi IP address ending in .99 (e.g. 192.168.1.99) through the eth0 interface and a Dreamcast IP address ending in .98 (e.g. 192.168.1.98) through the ppp0 interface, neither of which conflicts with the DHCP range and subsequently other devices.
However, for those of us with a non-factory router network configuration, this could cause issues depending on how many devices are regularly connected and disconnected from the network. In my case, I have 50+ devices regularly connecting and disconnecting to my network with the following configuration:
- router IP address (e.g. the gateway): 192.168.1.1
- IP addresses reserved for static uses (e.g. access points and servers): 192.168.1.2 - 192.168.1.19
- DHCP IP address range: 192.168.1.20 - 192.168.1.254
Over the course of the first week while owning my DreamPi, I encountered IP address conflicts because the IP address of 192.168.1.98 was already leased by another device on my network. The simplest solution was to restart my router, ensure that my DreamPi and Dreamcast were two of the first devices connected so they would lease the appropriate IP addresses, and then use the built-in DHCP reservation functionality on my router to indefinitely reserve those IP addresses for the DreamPi and Dreamcast respectively. However, I am very particular about my network configuration and this feels like a work-around fix. In such cases, I prefer to avoid DHCP reservation and assign a static IP address on the device itself.
The solution? Configure the DreamPi eth0 interface with a static IP address and ensure that the auto configuration script results in a pseudo-static IP address assigned to the Dreamcast ppp0 interface when a connection is established! Although it is relatively simple to do, there are a few particular details worth documenting. Without further ado...
Assumptions
The following assumes that you are familiar with a Linux terminal environment, understand basic networking concepts, and the have the knowledge of how to restore your DreamPi installation if anything goes wrong. If you are unsure about any of these three, do not continue.
From this point forward, in my code examples, the references are tailored to my desired network configuration. You should replace them as necessary based on your desired network configuration.
Booting the DreamPi
Connect your DreamPi to a monitor and a keyboard. Once done, boot it up, and wait for the dreampi login prompt.
DreamPi Credentials
The following are the dreampi login credentials (courtesy of pcwzrd13).
- Username: pi
- Password: raspberry
Update the /etc/network/interfaces file configuration
The current /etc/network/interfaces file is configured for dhcp IP address allocation, but since the dhcpcd service does not start upon boot, it is effectively ignored by the stock DreamPi configuration. The original will need to modified for static DreamPi IP address configuration, and then saved.
- Navigate to the /etc/network directory
Code: Select all
cd /etc/network
- Open the interfaces file in the nano text editor
Code: Select all
sudo nano interfaces
- Upon opening the interfaces file, it should read
Code: Select all
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
dns-nameserver 127.0.0.1 - Modify the interfaces file so that it reads the following
Code: Select all
auto eth0
iface eth0 inet static
address 192.168.1.19
netmask 255.255.255.0
gateway 192.168.1.1 - Close the interfaces file by pressing Ctrl + X
- Save the interfaces file by responding with "y" and pressing Enter
- Navigate back to the DreamPi root
Code: Select all
cd /
Disable dhcpcd
Once you modify the interfaces file from dhcp to static, the dhcpcd service will start upon boot and cause a conflict with the dnsmasq service used to reroute all traffic from the DreamPi to the alternate DNS server required for it to correctly operate. It will also result in two IP addresses being assigned to the DreamPi - one automatically by dhcpcd and one static per the interfaces file configuration. Therefore, the dhcpcd service must be disabled as documented on http://sizious.com/2015/08/28/setting-a-static-ip-on-raspberry-pi-on-raspbian-20150505/.
Code: Select all
sudo update -rc.d -f dhcpcd remove
Update the dreampi auto configuration script
The dreampi auto configuration script is written to set two relevant variables this_ip for the DreamPi eth0 interface and dreamcast_ip for the Dreamcast ppp0 interface based on a starting final octet of .100. This will updated to a new starting point based on the DHCP IP address range.
- Navigate to the /usr/local/bin directory
Code: Select all
cd /usr/local/bin
- Open the dreampi file in the nano text editor
Code: Select all
sudo nano dreampi
- Upon opening the dreampi file, find the line of code that reads
Code: Select all
this_ip = find_next_unused_ip(".".join(subnet) + ".100")
- Change ".100" to the first IP address in your DHCP IP address range, in my case ".20"
Code: Select all
this_ip = find_next_unused_ip(".".join(subnet) + ".20")
- Close the interfaces file by pressing Ctrl + X
- Save the interfaces file by responding with "y" and pressing Enter
- Navigate back to the DreamPi root
Code: Select all
cd /
Reboot and Confirm It is Working
Reboot DreamPi and confirm that it works as expected.
Code: Select all
sudo shutdown -r -t sec now
After DreamPi has completed the reboot process, the modem connected to it will be active and in its waiting state. If the configuration is incorrect, something along the lines of the following will be displayed on screen.
Code: Select all
My IP address is 192.168.1.19 192.168.1.115
[ FAIL ] startpar: service(s) returned failure: dreampi ... failed!
Raspbian GNU/Linux 7 dreampi ttyl
dreampi login:
Attempt to connect to a game server with any Dreamcast game of your choosing. Once connected, validate that your IP address configuration for both the DreamPi eth0 and Dreamcast ppp0 interfaces are correct.
Code: Select all
ifconfig
If the configuration is correct, something along the lines of the following will be displayed on screen.
Code: Select all
eth0 Link encap:Ethernet HWaddr b8:27:eb:3b:3e:45
inet addr:192.168.1.19 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:423 errors:0 dropped:0 overruns:0 frame:0
TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32077 (31.3 KiB) TX bytes:18769 (18.3 KiB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:192.168.1.19 P-t-P:192.168.1.18 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:19 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:916 (916.0 B) TX bytes:1018 (1018.0 B)
Now that you have your IP addresses configured, just update your port forwarding or DMZ allocation in your router's network configuration settings.