Welcome to the PiMP OS and Miner.farm forum.

How to configure Network on PiMP 2.8.x and above using Netplan


  • Staff

    How to configure Network on PiMP 2.8.x and above using Netplan

    How to Use the Netplan Network Configuration Tool on PiMP OS and other modern Linux distros

    Netplan is a command line utility for the configuration of networking on certain Linux distributions including Ubuntu 18.04 LTS which PiMP 2.8 and higher are built on.

    On PiMP 2.6 and older, we have configured the network connection via the desktop GUI or from within the /etc/network/interfaces file.

    Now in PiMP 2.8 due to changes in Ubuntu, the configuration and control of networking has changed considerably. Instead of the interfaces file and script, we now turn to Netplan. Netplan is a command line utility for the configuration of networking on certain Linux distributions. Netplan uses YAML description files to configure network interfaces and, from those descriptions, will generate the necessary configuration options for any given renderer tool.

    This guide will show you how to use Netplan on PiMP to configure a static IP address and a DHCP address. Another word of warning, the .yaml files you create for Netplan must be consistent in spacing, otherwise they’ll fail to work. You don’t have to use a specific spacing for each line, although we use and recommend 4 space indents (NO TABS) it just has to remain consistent.

    AGAIN: YAML is sensitive to spaces and indents. 4 space indents - NO TABS.

    The configuration files

    Open a terminal window or login SSH. You will find the new configuration files for Netplan in the /etc/netplan directory. Change into that directory with the command cd /etc/netplan. Once in that directory, you will probably only see a single file:

    01-netcfg.yaml

    You can create a new file or edit the default. If you opt to edit the default, I suggest making a copy with the command:

    cp /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.old

    With your backup in place, you’re ready to configure.

    Network Device Name

    Before you configure your static IP address, you’ll need to know the name of device to be configured. To do that, you can issue the command ip a and find out which device is to be used.

    We will be configuring eth0 for a static IP address.

    Configuring a Static IP Address

    Open the original .yaml file for editing with the command:

    nano /etc/netplan/01-netcfg.yaml

    0_1538097173741_netplan01.png

    The layout of the file looks like this:

    # This file describes the network interfaces available on your system
    # For more information, see netplan(5).
    network:
      version: 2
      renderer: networkd
      ethernets:
        eth0:
    # DHCP: Default
          dhcp4: yes
    # STATIC IP: Comment the dhcp4: lines above, and
    #  Uncomment all of the following:
    #      addresses: [192.168.0.77/32]
    #      gateway4: 192.168.0.1
    #      nameservers:
    #        addresses: [8.8.8.8, 8.8.4.4]
    

    Where:

    yes/no is an option to enable or disable dhcp4.

    0_1538097332167_netplan02.png

    Edit the above to fit your networking needs. Save and close that file.

    To set static IP, comment out (block) the dhcp line and uncomment (unblock) the static IP lines.

    0_1538097376046_netplan03.png

    Notice the netmask is no longer configured in the form 255.255.255.0. Instead, the netmask is added to the IP address with slash notation. /32 for one ip, /24 for a 255.255.255.0 netmask.

    0_1538097384542_netplan04.png

    When using nano, use Control+X to save the file. Hit Y to say Yes and then Enter to save with the same filename.

    0_1538097416942_netplan05.png

    0_1538097424807_netplan06.png

    Testing the Configuration

    Before we apply the change, let’s test the configuration. To do that, issue the command:

    netplan try

    The above command will validate the configuration before applying it. If it succeeds, you will see Configuration accepted. In other words, Netplan will attempt to apply the new settings to a running system. Should the new configuration file fail, Netplan will automatically revert to the previous working configuration. Should the new configuration work, it will be applied.

    0_1538097444077_netplan07.png

    Applying the New Configuration

    Once you are certain of your configuration file, you can apply the new options. The command for this is:

    netplan apply

    At this point, you can issue the command ip a to see that your new address configurations are in place.

    Configuring DHCP

    If you want the rig to always have the same IP but don't want to configure static IP, another way is: you could configure the device for DHCP, get an IP address, and then reconfigure that address as static, or set a DHCP reservation in the router's settings if you like.

    To use DHCP with Netplan, the configuration file would look like the example / default file above. You do not need to change the file to use DHCP as it is the default.

    Should you have more than one interface, you could name the second .yaml configuration file 02-netcfg.yaml. Netplan will apply the configuration files in numerical order, so 01 will be applied before 02. Create as many configuration files as needed for your rig. (Or your server, as this technique applies to all modern linux boxes using netplan.)

    That’s All There Is

    Believe it or not, that’s all there is to using Netplan. Although it is a significant change to how we’re accustomed to configuring network addresses, it’s not all that hard to get used to. But this style of configuration is here to stay... so you will need to get used to it.

    Credit: linux.com


 



Want 10% more hash from your rigs?



We promise to keep your email safe and never spam you.



Copyright (c) 2012-2018 PiMP LLC. All rights Reserved.