Configuring Static IP addresses for the DreamPi and Dreamcast

Technical help for Dreamcast console, accessories and games only. Ask questions and find answers here. For Online help see the Online Forum

Moderator: pcwzrd13

User avatar
thecodygriffin
undertow
Posts: 31

Configuring Static IP addresses for the DreamPi and Dreamcast

Post#1 » Sat Mar 03, 2018 10:20 pm

I have an updated guide that you can find later in this thread at viewtopic.php?f=42&t=10888&p=178533#p178533

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.

  1. Navigate to the /etc/network directory

    Code: Select all

    cd /etc/network
  2. Open the interfaces file in the nano text editor

    Code: Select all

     sudo nano interfaces
  3. 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
  4. 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
  5. Close the interfaces file by pressing Ctrl + X
  6. Save the interfaces file by responding with "y" and pressing Enter
  7. 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.

  1. Navigate to the /usr/local/bin directory

    Code: Select all

     cd /usr/local/bin
  2. Open the dreampi file in the nano text editor

    Code: Select all

     sudo nano dreampi
  3. Upon opening the dreampi file, find the line of code that reads

    Code: Select all

        this_ip = find_next_unused_ip(".".join(subnet) + ".100")
  4. 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")
  5. Close the interfaces file by pressing Ctrl + X
  6. Save the interfaces file by responding with "y" and pressing Enter
  7. 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.
Last edited by thecodygriffin on Wed Aug 16, 2023 3:01 pm, edited 2 times in total.

User avatar
pcwzrd13
Seen Any Sailors?
Posts: 7081
Contact:

Re: Configuring Static IP address for DreamPi

Post#2 » Sun Mar 04, 2018 7:41 am

Nice tutorial and all but the idea behind it is incorrect. You port forward / DMZ to the Dreamcast's IP, NOT the Pi's IP. The Dreamcast's IP is already statically set to .98 (or .97 if .98 is not available).
PSO Characters:
Teal'c - lvl 119 HUcast - GC# 11666
Alto - lvl 39 FOnewm - GC# 12964

YouTube Channel : Dreamcast Live

User avatar
thecodygriffin
undertow
Posts: 31

Re: Configuring Static IP address for DreamPi

Post#3 » Sun Mar 04, 2018 11:38 am

pcwzrd13, I found that out late last night. I am going to update it accordingly today.

User avatar
thecodygriffin
undertow
Posts: 31

Re: Configuring Static IP addresses for the DreamPi and Dreamcast

Post#4 » Sun Mar 04, 2018 1:23 pm

Any suggestions on how this can be accomplished in a better way would be highly appreciated.

kazade
Developer
Posts: 264

Re: Configuring Static IP addresses for the DreamPi and Dreamcast

Post#5 » Sun Mar 04, 2018 4:53 pm

In case anyone was interested why the IPs are what they are:

- .98 and .99 are suitably far away from .1 to hopefully avoid conflicting on an average home network
- but mainly, and primarily, Dreamcast launch years :)

User avatar
HuntrRose
Vagabond
Posts: 727

Re: Configuring Static IP addresses for the DreamPi and Dreamcast

Post#6 » Sun Mar 04, 2018 5:04 pm

haha nice!

User avatar
pcwzrd13
Seen Any Sailors?
Posts: 7081
Contact:

Re: Configuring Static IP addresses for the DreamPi and Dreamcast

Post#7 » Sun Mar 04, 2018 5:22 pm

kazade wrote: - .98 and .99 are suitably far away from .1 to hopefully avoid conflicting on an average home network
- but mainly, and primarily, Dreamcast launch years :)


That was my idea. ;) Is it not .97 as well? I know at least one person had to set their DMZ to .97 at one point.
PSO Characters:
Teal'c - lvl 119 HUcast - GC# 11666
Alto - lvl 39 FOnewm - GC# 12964

YouTube Channel : Dreamcast Live

User avatar
thecodygriffin
undertow
Posts: 31

Re: Configuring Static IP addresses for the DreamPi and Dreamcast

Post#8 » Sun Mar 04, 2018 5:25 pm

If I read the script right, it could theoretically be .97, .96, and so on depending on the existing IP address leases. However, that would be very unlikely.

User avatar
thecodygriffin
undertow
Posts: 31

Re: Configuring Static IP addresses for the DreamPi and Dreamcast

Post#9 » Sun Mar 04, 2018 5:28 pm

Kazade, is there a better way to modify the dreampi script so that I wouldn’t need to change the /etc/network/interfaces configuration from dhcp to static, but would ALWAYS result in IP address ending in .19 and .18 for the DreamPi and Dreamcast respectively?

I ask because what I did feels like a hack based on a partial understanding of a greater whole.

1nick9
Anarki
Posts: 87

Re: Configuring Static IP addresses for the DreamPi and Dreamcast

Post#10 » Sun Mar 04, 2018 10:34 pm

thecodygriffin wrote:Kazade, is there a better way to modify the dreampi script so that I wouldn’t need to change the /etc/network/interfaces configuration from dhcp to static, but would ALWAYS result in IP address ending in .19 and .18 for the DreamPi and Dreamcast respectively?

I ask because what I did feels like a hack based on a partial understanding of a greater whole.

for the pi resulting in one of these why not setup a dhcp lease?? guess cause clashes with reservered ips for static from ya dhcp server range. still would need to manually config the dailup ip to resolve desired ip.
quick question why it not work modifying this section of script alone?? without knowning anything about the scripts on dreampi im guessing just modifying this would make it detect subnet range n add 20 to it.
this_ip = find_next_unused_ip(".".join(subnet) + ".20")

  • Similar Topics
    Replies
    Views
    Last post

Return to “Support”

Who is online

Users browsing this forum: No registered users