Post

Portracker - Ports Monitoring Auto Discovery Dashboard For Your Homelab

In a self-hosted environment or homelab, managing and monitoring open ports becomes a crucial yet challenging task. Portracker, an open-source tool, aims to ....

# Portracker - Ports Monitoring Auto Discovery Dashboard For Your Homelab

In a self-hosted environment or homelab, managing and monitoring open ports becomes a crucial yet challenging task. Portracker, an open-source tool, aims to simplify this process by providing an automated port discovery dashboard. This guide will walk you through the installation, configuration, usage, and troubleshooting of Portracker in your homelab.

Introduction

Portracker helps you keep track of all open ports on your servers, reducing the need for manual maintenance and updates. It’s essential for maintaining a secure and organized homelab by ensuring that only necessary services are exposed and providing visibility into potential security risks.

Prerequisites

  • Operating System: Ubuntu 20.04 LTS or later versions (64-bit)
  • Hardware Requirements: Minimum 2GB RAM, 10GB storage
  • Required Software: Go (version 1.16 or higher)
  • Network Requirements: Your homelab’s network should be properly segmented and configured to allow communication between Portracker servers and the machines you want to monitor. Ensure that firewalls are set up to allow traffic on port 9000 (default for Portracker).
  • User Permissions: Run Portracker as a non-root user with appropriate permissions to access network interfaces and run necessary commands.

Installation & Setup

  1. Install Go:
    1
    2
    3
    4
    
    wget https://golang.org/dl/go$GOVERSION.linux-amd64.tar.gz && tar -xvf go$GOVERSION.linux-amd64.tar.gz
    mv go /usr/local
    export GOROOT=$HOME/go
    PATH=$GOROOT/bin:$PATH
    
  2. Clone the Portracker repository and navigate to its directory:
    1
    2
    
    git clone https://github.com/portainer/portracker.git
    cd portracker
    
  3. Build and run Portracker:
    1
    2
    
    make
    ./portracker --config config.yaml
    
  4. Configure environment variables (optional):
    1
    2
    
    export PORTTRACKER_API_KEY=your-api-key
    export PORTTRACKER_DATABASE_URI="mysql://user:password@host:port/dbname?parseTime=true"
    
  5. Verify the installation by visiting http://localhost:9000 in your web browser or by using the command curl http://localhost:9000.

Configuration

The configuration file (config.yaml) allows you to customize Portracker to suit your needs. You can adjust settings such as the API key, database connection details, and the interval at which scans are performed.

1
2
3
4
5
6
7
8
9
10
# Example config.yaml file
apiKey: "your-api-key"
database:
  uri: "mysql://user:password@host:port/dbname?parseTime=true"
  maxOpenConns: 10
  maxIdleConns: 5
  maxIdleConnsPerIP: "1"
  connMaxLifetime: "30s"
scanner:
  interval: "60s"

Usage & Operations

  • Monitoring: Visit the Portracker web interface at http://localhost:9000 to view a list of open ports and associated services.
  • Maintenance: Regularly update your configuration file to add new servers or remove unused services from the scan.
  • Backup and Recovery: Use standard backup strategies for your database and configuration files.
  • Scaling: Portracker is designed to be horizontally scalable, allowing you to run multiple instances for monitoring larger environments.

Troubleshooting

Common issues include connection errors, incorrect configurations, or firewall issues. Consult the official documentation for troubleshooting tips and best practices.

Conclusion

This guide has walked you through installing, configuring, and using Portracker to monitor ports in your homelab. By learning how to use this powerful tool, you can enhance the security and organization of your self-hosted environment. For advanced topics and further learning resources, visit the Portracker documentation.

This post is licensed under CC BY 4.0 by the author.