How to: Set/Configure Static IP Address/DHCP for Ubuntu Server/Desktop 18.04/19.04/19.10 via Terminal using netplan

Before starting the process, make sure you have other ways/backup method to access your server/desktop rather than over LAN/WAN in case if the connect is lost.

Using netplan

(For older versions we can use “sudo apt install netplan.io” to install netplan)

netplan is a YAML network configuration tool [1]

1 First we need to check is there is existing configuration file

# Change current directory to /etc/netplan
cd /etc/netplan
 
# List files under that folder
ls
/etc/netplan folder
/etc/netplan folder

Here we have a file “50-cloud-init.yaml” which we can use

If the folder is empty, we can create the file by using

touch config.yaml

2 Editing the file

(In this example we use default file which is “50-cloud-init.yaml”, if you have created “config.yaml” file it will be empty)

sudo nano 50-cloud-init.yaml

We will see following contents

Note: ens33 is the Ethernet interface, yours can be different don’t change it!!!!

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: true                                                                                                     
    version: 2
Editing yaml file for netplan
Editing yaml file for netplan

Now, we can see on interface ens33, it is configured to use dhcp version 4. (dhcp4: true)

If we want to use DHCP for this server/desktop, then this setting is fine, we do not need to change anything. (We can use Ctrl + X to exit the nano program)

If we want to configure a static IP address for this server/desktop, here is what we need to change (We only need to look at “Before” and “After” sections, “Different format” “If we have workgroup” and “Or two domains” are extended reading)

Note: The spaces in front of “ethernets, ens33” etc. etc. they are actually spaces not Tab, we can’t use Tab for those and these spaces are actually indentation, so they are very important as well, do not change indentation or use Tab, otherwise the configuration file will not work.

The yaml is quite self-explanatory:

dhcp4 yes|no|true|false: Enable/Disable DHCP v4

addresses: Static IP Address

gateway4: IPv4 Gateway

nameservers: DNS resolvers

search: domain to search/workgroup

Before

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: true                                                                                                     
    version: 2

After

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: no
            addresses: [192.168.247.129/24]
            gateway4: 192.168.247.2
            nameservers:
              addresses: [192.168.247.2, 8.8.8.8]                                                                                                     
    version: 2

Different format

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: no
            addresses:
            - 192.168.247.129/24
            gateway4:
            - 192.168.247.2
            nameservers:
              addresses:
              - 192.168.247.2
              - 8.8.8.8                                                                                                    
    version: 2

If we have workgroup

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: no
            addresses: [192.168.247.129/24]
            gateway4: 192.168.247.2
            nameservers:
              addresses: [192.168.247.2, 8.8.8.8]
              search: [workgroup]                                                                                                     
    version: 2

Or two domains

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: no
            addresses: [192.168.247.129/24]
            gateway4: 192.168.247.2
            nameservers:
              addresses: [192.168.247.2, 8.8.8.8]
              search: [domain1.example.com, domain2.example.com]                                                                                                     
    version: 2

3 Save the file

Once finished with editing, we use Ctrl + X, then hit Y, Enter key to exit nano and save the file

4 Apply the changes

sudo netplan apply

5 To check the IP address

ip a
 
or
 
ip addr
 
or 
 
ip address
ip a
ip a

Resources

[1] “Netplan configuration examples”, Netplan.io, 2020. [Online]. Available: https://netplan.io/examples.

How to: Create Docker Swarm Cluster (With 3 servers) Easily (And install portainer to manage them)

Purpose of this guide

We will learn how to create a docker swarm cluster with 1 manager node and 2 worker nodes

What do we need to follow this guide

  • A spare computer with Windows operating system (Windows/macOS/Linux) as working PC
  • 3 up to date Ubuntu Server 19.10 /Linux servers (Can be real server can be virtual machines, in this guide we are using Ubuntu server 19.10) [Tips: Virtual machine is recommended for this guide, since we can easily take snapshots and restore easily if something goes wrong]
  • Each of them should at least have 2 GB RAM
  • Servers and the working PC have access to internet
  • Server must be connected to a same LAN
  • SSH client on the working PC (It’s will be easier when copy/paste join tokens among servers)

Tasks in this guide

  1. Before creating the docker swarm cluster, we will need to configure static IP address for each server
  2. Install docker on each server
  3. Configure Manager node
  4. Configure worker node 1
  5. Configure worker node 2
  6. Check docker nodes connection
  7. Bonus: Install portainer to manage a Linux swarm cluster with portainer server and the portainer agent (Not required for the docker swarm cluster)

Begin the journey

1 Configure static IP addresses for 3 servers

(Important Note: You do not have to use same IP address as in this guide, the IP address assigned form your router’s DHCP can be used to configure as static IP address on the server as a temporary solution, e.g. if your computer is getting address like 10.0.0.10, you can use 10.0.0.100, 10.0.0.101, 10.0.0.102 as their static address. For long term usage, we should take those address out of the DHCP address pool, or IP address conflict/duplicate IP address issue can occur, you can also configure static IP address from your router as well rather than on the server although configure on the server is preferred )

Manager node – 192.168.247.129

If you don’t understand or can’t follow Step 1.1 to Step 1.6, have a look on this guide first to understand how to use netplan/configure static IP address with netplan: How to: Set/Configure Static IP Address/DHCP for Ubuntu Server/Desktop 18.04/19.04/19.10 via Terminal using netplan then continue from here

1.1 Change current directory to “/etc/netplan”

cd /etc/netplan

1.2 List files within the folder

ls

There should be a file ending with “.yaml”, in this example we have “50-cloud-init.yaml” your might be different, if so, use that one from your directory

1.3 We need to modify that file to configure static IP address

sudo nano 50-cloud-init.yaml

1.4 Change from “Before” to “After”, make sure you have correct IP address configured, again, you do not need to use the same IP address form here, make sure you have configured IP address, gateway4 and nameservers correctly.

Before

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: true                                                                                                     
    version: 2

After

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: no
            addresses: [192.168.247.129/24]
            gateway4: 192.168.247.2
            nameservers:
              addresses: [192.168.247.2, 8.8.8.8]                                                                                                     
    version: 2

1.5 Use Ctrl + X, then Hit Y, then hit Enter key to save and exit the nano editor

1.6 Apply changes

sudo netplan apply

1.7 Make sure the IP address is configured correctly

ip a
ip a
ip a

1.8 Make sure the configured IP and DNS works by using following commands

# Check DNS server, IP address should be returned
dig bing.com
 
# Check the network, time of round trip should be returned
ping bing.com -c 5

Worker node 1 – 192.168.247.130

1.9 Same step as from Step 1.1 to Step 1.7 but with different IP address

Worker node 2 – 192.168.247.131

1.10 Same step as from Step 1.1 to Step 1.7 but with different IP address

2 Install docker on each server

Manager node – 192.168.247.129

2.1 Install docker

sudo apt install -y docker.io

Worker node 1 – 192.168.247.130

2.2 Install docker

sudo apt install -y docker.io

Worker node 1 – 192.168.247.131

2.3 Install docker

sudo apt install -y docker.io

3 Configure Manager node – 192.168.247.129

3.0 Preparation/Suggestion for using SSH client

(Use SSH client to connect to the server from the working PC, for Windows we can use PowerShell or Windows Terminal with ssh command, for Linux and macOS we can just use terminal with ssh command)

e.g.

(To connect to 192.168.247.129, we can use following command, then type yes, hit Enter key, type password to connect)

# Format
ssh [email protected]
 
# Example For this guide
ssh [email protected]

3.1 Initialize docker swarm manager [1]

sudo docker swarm init
sudo docker swarm init
sudo docker swarm init

3.2 Copy the command for adding a worker to this swarm, the following is for this guide, yours will be different, you will have to use yours

docker swarm join --token SWMTKN-1-5vphj6kj8t6z5yz45jq97vpe742avhl7md4905o796kkupnu1t-5oypobnbtpb3kksvv5s2k15f5 192.168.247.129:2377

Note: If you have missed that token somehow, in order to show the token again

# Show token for adding worker
sudo docker swarm join-token worker
 
# Show token for adding manager
sudo docker swarm join-token manager
Show docker swarm token for adding worker and manager nodes
Show docker swarm token for adding worker and manager nodes

4 Configure worker node 1 – 192.168.247.130

4.1 Adding worker node 1 to swarm as a worker (Execute following command on worker node 1) (The command was copied from Step 3.2)

sudo docker swarm join --token SWMTKN-1-5vphj6kj8t6z5yz45jq97vpe742avhl7md4905o796kkupnu1t-6mrz20tzuovi3rivfw3ivm6wv 192.168.247.129:2377
Successfully executed command on worker node 1, worker node 1 added to swarm as a worker
Successfully executed command on worker node 1, worker node 1 added to swarm as a worker

5 Configure worker node 2 – 192.168.247.131

5.1 Adding worker node 2 to swarm as a worker (Execute following command on worker node 2) (The command was copied from Step 3.2)

sudo docker swarm join --token SWMTKN-1-5vphj6kj8t6z5yz45jq97vpe742avhl7md4905o796kkupnu1t-6mrz20tzuovi3rivfw3ivm6wv 192.168.247.129:2377
Successfully executed command on worker node 2, worker node 2 added to swarm as a worker
Successfully executed command on worker node 2, worker node 2 added to swarm as a worker

6 Check docker nodes connection

6.1 Execute following command on manager node

sudo docker node ls
sudo docker node ls output on manager node
sudo docker node ls output on manager node

Now the docker swarm cluster is created and ready for use

7 Bonus: Install portainer to manage a Linux swarm cluster with portainer server and the portainer agent (Not required for the docker swarm cluster)

7.1 Execute following commands on the manager node [2]

curl -L https://downloads.portainer.io/portainer-agent-stack.yml -o portainer-agent-stack.yml
 
docker stack deploy --compose-file=portainer-agent-stack.yml portainer
Install portainer to manage the LLLinux swarm cluster with portainer server and the portainer agent
Install portainer to manage the LLLinux swarm cluster with portainer server and the portainer agent

7.2 Open portainer web GUI, configure username and password (http://manager node’s IP address:9000) then click on “Create user”

In this guide it is http://192.168.247.129:9000

portainer web GUI
portainer web GUI
portainer home page
portainer home page

Now the portainer installation and configuration is done for managing Linux swarm cluster with portainer server and portainer agent

Click on “primary” we can view the dashboard

portainer dashboard
portainer dashboard

Click on “Go to cluster visualizer” we can see the swarm cluster details

Swarm, Cluster visualizer
Swarm, Cluster visualizer

App Templates – stack

App Templates - stack
App Templates – stack

Stacks

Stacks
Stacks

Services

Services
Services

Containers

Containers
Containers

Images

Images
Images

Networks

Networks
Networks

Volumes

Volumes
Volumes
Volumes
Volumes

Configs

Configs
Configs

Secrets

Secrets
Secrets

Swarm

Swarm
Swarm

Resources

[1] “Run Docker Engine in swarm mode”, Docker Documentation, 2020. [Online]. Available: https://docs.docker.com/engine/swarm/swarm-mode.

[2] “Installation”, Portainer.io, 2020. [Online]. Available: https://www.portainer.io/installation


How to: Fix Ubuntu Server 19 “Cockpit Cannot refresh cache whilst offline” and “Cannot refresh cache whilst offline” Errors

The Error

When cockpit is installed on Ubuntu Server 19, we might get following errors

Cockpit Cannot refresh cache whilst offline

Cannot refresh cache whilst offline

The Fix

By disabling the network-manager, we can resolve those errors (Yes, It’s more of workaround rather than fix)

Warning: Do not run these commands on production server, unless you know what you are doing.

1 Disable network-manager service and stop it immediately, then restart the system

sudo systemctl disable network-manager.service
 
sudo systemctl stop network-manager.service
 
sudo reboot

2 Now, get back to cockpit, errors won’t be there anymore


How to: Install Portainer on Ubuntu (Linux etc.) (Single node/Standalone Linux Docker host/Single node swarm cluster)

What is portainer?

An lightweight, open source and easy to use tool for managing Docker environment with web GUI, it can also manage docker swarm cluster.

If you are after some heavy weight management software alternatives, Rancher can be a good one to look into. It’s an open source multi-cluster orchestration platform.

How to Install portainer from scratch?

1 Install docker first

# For Ubuntu
sudo apt install docker.io

2 Install portainer

$ sudo docker volume create portainer_data
$ sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

3 Check server IP address

ip a

4 Login to portainer and configure desired Username and Password, then click on “Create user” to proceed

http://ipaddress:9000
Configure portainer login details
Configure portainer login details

5 If you know what you are doing you can configure portainer by selecting “Remote” or “Agent” or “Azure” otherwise, we select “Local” then click on “Connect”

Configure portainer - Local
Configure portainer – Local

6 We have successfully installed, configured and logged into portainer

portainer home screen
portainer home screen

Bonus

portainer – Home

portainer - home
portainer – home

portainer – Local Dashboard

portainer - local Dashboard
portainer – local Dashboard

portainer – App Templates

portainer - App Templates
portainer – App Templates

portainer – Stacks

portainer - Stacks
portainer – Stacks

portainer – Containers

portainer - Containers
portainer – Containers

portainer – Images

portainer - Images
portainer – Images

portainer – Networks

portainer - Networks
portainer – Networks

portainer – Volumes

portainer - Volumes
portainer – Volumes

portainer – Events

portainer - Events
portainer – Events

portainer – Host

portainer - Host
portainer – Host

Resources

portainer: https://www.portainer.io

Rancher: https://rancher.com


How to: Fix “Could not get lock…” “Unable to lock directory…” in OpenMediaVault (OMV)

The Error

Sometimes when we want to install some tools/program with “sudo apt install program” in OMV via terminal/SSH we encounter following error which blocks us from installing the program

E: Could not get lock /var/cache/archives/lock – open (11: resource temporarily unavailable)
E: Unable to lock directory /var/cache/apt/archives

The Fix

Usually, that means we have new updates waiting to be installed

1 Navigate to OMV web UI via http/https://your-OMV-hostname-or-IP-address

2 Navigate to “System” click on “Update Management”

OMV - Update Management
OMV – Update Management

3 Check all available updates then click on “Install” button

4 Wait till all updates are done

5 Now get back to terminal/SSH and try to install program again, this time there should be no errors

Bonus

Here are some useful apps/programs/utilities can be installed via “sudo apt install” and can be used easily for managing/monitoring OMV from terminal/SSH

htop – Similar to top, with more info

htop
htop

nethogs – Real-time network/traffic usage

nethogs
nethogs

iftop – Another traffic monitoring program

iftop
iftop

glances – Comprehensive monitoring

glances
glances

How to: Find “Quarantine” in new Office 365 admin center?

Where is “Quarantine” page which we can use to review and release false-positive spam/phishing emails?

To Navigate to “Quarantine” page in the new Office 365 admin center.

Method 1 – Through clicks

1 Login to Office 365 Security & Compliance: https://protection.office.com/

2 Navigate to “Thread management – Review”

3 Double click on “Quarantine”

Navigate to Review, double click on Quarantine
Navigate to Review, double click on Quarantine

Method 2 – Direct URL

1 Click on the following link and sign in to Office 365

https://protection.office.com/quarantine

2 Now you should have Quarantine page right in front of you

More useful Office 365 admin quick links can be found here: Microsoft Office 365/O365 Administration links (Admin links, admin centers, Quarantine etc.)


How to: Add/Include folder to Windows 10 Library Remove/Delete folder from Windows 10 Library

If the Library icon is missing from “This PC” please refer to this guide to show it:

How to Fix: Windows 10 Library missing/Missing Library icon in “This PC” & How to: Hide Library in Windows 10

Add/Include folder to Windows 10 Library

1 Open “This PC” or Navigate to the folder that we want to include in the Libraries

2 Right click on the folder that we want to include in the Libraries, Navigate to “Include in library” then select existing library or click on “Create new library” to include it to a new library

Include in library
Include in library

3 In this example we include the “xampp” folder to “Documents” library

Include xampp folder in Documents library
Include xampp folder in Documents library

Remove/Delete/Exclude folder from Windows 10 Library (This will not delete the folder itself)

1 Open “This PC”

2 Navigate to the library which include the folder which we want to remove from, “Documents” library in this case

Library – Documents

3 Right click on the library which includes the folder which we want to remove/delete from, “Documents” in this case, then click on “Properties”

Right on the library, Documents in this case
Right on the library, Documents in this case

4 Click on the folder which we want to remove from library then click on “Remove” button, finally click on “OK” button

Documents Properties
Documents Properties

5 Now the folder is removed from the library

xampp folder removed from Documents library
xampp folder removed from Documents library

Warning: If you right click on the folder then click on Delete from Library, the folder will be deleted!!! (That’s not delete from the library, it actually deletes the folder itself and of course it will disappear from the library as well, sine the folder is gone completely by deleting it). So be careful.


How to Fix: Windows 10 Library missing/Missing Library icon in “This PC” & How to: Hide Library in Windows 10

What is Windows 10 Library in short

The “Libraries” in the red rectangle is Windows 10 Library

Windows 10 - This PC - Libraries
Windows 10 – This PC – Libraries

How to bring it back/Show it, if it’s not there?

1 Right click in one of the areas marked in red rectangle

Windows 10 - This PC - Libraries missing
Windows 10 – This PC – Libraries missing

2 Click on “Show libraries”

Windows 10 - This PC - Show libraries
Windows 10 – This PC – Show libraries

3 Now the Libraries folder is back in This PC

Windows 10 - This PC - Libraries
Windows 10 – This PC – Libraries

How to hide “Libraries” in This PC?

1 Right click in one of the areas marked in red rectangle

Windows 10 - This PC - Hide Libraries
Windows 10 – This PC – Hide Libraries

2 Click on “Show libraries” to uncheck it (Which means hide it)

Windows 10 - This PC - Click on Show libraries to unheck and hide it
Windows 10 – This PC – Click on Show libraries to unheck and hide it

How to: Find out “lost/missing” document/file from Microsoft Office 365 (Document/File saved to wrong place in SharePoint/OneDrive)

Warning: This simple guide is for people who actually saved file or document to wrong place without paying attention and want to find out the file.

Sometimes, when we saving files to SharePoint, especially when the path is very long, we can save to wrong spot without knowing, until we want to use the file again.

Here are some easy ways to find the “lost” file or documents.

Method 1 – Open from Word/Excel/PowerPoint

1 Launch the corresponding software/program if we were editing the file/document in Word, Excel or PowerPoint.

2 Looking at the “Recent” section in the Office program.

3 Once identified the wanted document, underneath the file name, usually it’s the path of the file in SharePoint

Method 2 – Search for file/document

If you still remember the partial file name

1 Sign into office.com

2 In the top search box, search for the file

3 The file might appear in search results

4 Click on the folder/path of that file, not the file name

5 Now the folder contains the file/document will be in front of you