Skip to content
/ do-ddns Public

a simple bash script and helper to accept incoming ssh traffic using port forwarding on router using a dynamic dns through digital ocean

Notifications You must be signed in to change notification settings

O-R-G/do-ddns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

30 June 2020

A simple Bash script and helper to accept incoming SSH traffic using port forwarding on a router, with a dynamic DNS through DigitalOcean.

Following: DigitalOcean DDNS Guide



Requirements

  • DigitalOcean account
  • API token for DNS updates
  • A local machine with SSH server enabled ("Remote Login")
  • Router capable of port forwarding (example: Apple Airport Base Station)

Setup Instructions

1. Get a DigitalOcean API Token

Create a Personal Access Token

2. Set Up a Project

Example: Use O-R-G as your project name.

3. Add DNS Record (A)

Point basement.o-r-g.net to your IP. This DNS record will be updated by a local Bash script.

4. Get ID of the DNS Record

Use the get-dns-id.sh script:

./get-dns-id.sh

5. Update DNS

Add the DNS record ID and API token to .zshrc as enviroment variables then run update-dns.sh:

nano /Users/me/.zshrc
./update-dns.sh

6. Set Up a Cron Job

Keep the DigitalOcean DNS record updated every 5 minutes:

crontab -e

Add the following line:

*/5 * * * * /usr/local/bin/update-do-ddns >> /Users/me/log.txt

7. Configure Port Forwarding on Router (Airport Base Station)

Following Apple Discussions: Port Mapping

Steps:

  • Reserve a DHCP static IP for the local computer.
  • Forward external port 22 to this static IP.

Requirements:

  • MAC address (System Preferences → Network).
  • Static local IP.

List all local IPs and MAC addresses:

arp -a

Example output:

xx:xx:xx:xx:xx:xx
10.0.1.x

Set up port forwarding:

  • Choose "Remote Login - SSH" (public TCP, port 22 points to local static IP).
  • Restart the Base Station.

7. Set static ip

Set static ip for local computer with MAC address specified in Step 7: System Settings : Network : Wifi : Details : TCP/IP : Configure IPv4 : Using DHCP with Manual Address

8. Connect via SSH

Ensure sshd is running locally ("Remote Login" enabled in Sharing).

Connect using:

ssh someone@somewhere.com

9. Install update-dns.sh to /usr/local/bin

cp update-do-ddns.sh /usr/local/bin/update-do-ddns

10. Set Local Computer to Stay Awake

Run on startup:

caffeinate -d

✅ Your system should now accept incoming SSH traffic dynamically using DDNS and port forwarding.

About

a simple bash script and helper to accept incoming ssh traffic using port forwarding on router using a dynamic dns through digital ocean

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages