Managing Nodes in PNETlab: Checking Status, Stopping, and Starting Nodes in Offline Mode

Welcome to this tutorial on managing nodes in PNETlab! Whether you’re a network engineer, a student, or a cybersecurity enthusiast, understanding how to interact with your virtual lab environment programmatically can be extremely useful. In this guide, we’ll walk through how to check node status, stop nodes, and start nodes using Python scripts in PNETlab, specifically when running in offline mode.

Prerequisites

  1. Access to PNETlab: Ensure you have administrative access to your PNETlab instance.
  2. Scripts: Download the necessary Python scripts from our GitHub repository.
  3. Python Environment: Make sure you have Python installed on your machine.

Step 1: Set PNETlab to Offline Mode

Before you can run scripts against your PNETlab environment, you need to configure PNETlab for offline mode:

  1. Log into PNETlab: Open your web browser and log into your PNETlab instance.
  2. Navigate to System Settings:
    • Click on System in the top menu.
    • Go to System Mode.
  3. Disable Captcha:
    • Under Offline Mode, ensure Captcha is disabled. This is crucial as Captcha can block script-based interactions with your lab.

Step 2: Create a User for Script Operations

You need a dedicated user account to perform node management tasks. Follow these steps:

  1. Go to User Management:
    • Navigate to Accounts.
    • Click on User Management.
  2. Add a New User:
    • Click Add to create a new user.
    • For our example, we’ll use the username LabNodeManager with the password pnet. Be sure to use a secure password in a real environment.
    • Save the new user account.

Step 3: Download and Configure Scripts

We have provided scripts that will help you manage your nodes. Here’s how to get and configure them:

  1. Download Scripts:
  2. Edit Scripts:
    • Open the downloaded scripts in a text editor.
    • Modify the base_url, user, and passwd variables to match your PNETlab instance’s IP address, the username (LabNodeManager), and the password (pnet).
    • Save the changes to the script.

Step 4: Run the Scripts

Depending on the action you want to perform, use the following scripts:

  1. Check Node Status:
    • Run the script that retrieves node statuses to see the current state of all nodes.
  2. Stop All Nodes:
    • Use the script designed to stop all nodes. This will iterate through all nodes and stop those that are currently powered on.
  3. Start All Nodes:
    • Similarly, use the script to start all nodes. This will start nodes that are powered off.

Step 4: Run the Scripts

Depending on the action you want to perform, use the following scripts:

  1. Check Node Status:
    • Run the script that retrieves node statuses to see the current state of all nodes.
  2. Stop All Nodes:
    • Use the script designed to stop all nodes. This will iterate through all nodes and stop those that are currently powered on.
  3. Start All Nodes:
    • Similarly, use the script to start all nodes. This will start nodes that are powered off.

Conclusion

By following these steps, you can effectively manage your nodes in PNETlab using Python scripts. This approach is not only efficient but also helps in automating repetitive tasks, making your lab management easier and more streamlined. For more details and additional scripts, check out our GitHub repository.

Leave a Reply