How to show and clear DHCP bindings on the LAN Huawei VRP (Versatile routing platform) CLI

This is a quick reference guide for clearing DHCP bindings Huawei VRP CLI.

1. display ip pool

The following command will display all the dhcp bindings depending on how it is configured. It will either be interface or pool name. DHCP can either be configured on the interface or globally.

Cisco equivalent “sh ip dhcp binding

display ip pool interface vlanif21 used

display ip pool name testdhcp used

[Huawei]display ip pool ?
   interface     Information of interface pool
   name          Pool name
   vpn-instance  Show IP pool bind the VPN-instance
   |             Matching output

display ip pool interface vlanif21 used  
   Pool-name      : vlanif21
   Pool-No        : 0
   Lease          : 1 Days 0 Hours 0 Minutes
   Domain-name    : -
   DNS-server0    : 8.8.8.8         
   DNS-server1    : 8.8.8.4         
   NBNS-server0   : -               
   Netbios-type   : -               
   Position       : Interface       Status           : Unlocked
   Gateway-0      : 192.168.1.254   
   Mask           : 255.255.255.0
   VPN instance   : --
 
      Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 
  192.168.1.1   192.168.1.254   253     1        252(0)         0        0
 
 Network section : 
 
 Index              IP               MAC      Lease   Status  
 
 252   192.168.1.253    5489-9877-235d      78724   Used

2. Reset ip pool

Cisco equivalent would be “clear ip dhcp binding“.

reset ip pool interface vlanif21 ?
   X.X.X.X   Start IP address
   all       All IP address
   conflict  Conflict IP address
   expired   Expired IP address
   used      Used IP address

or

By pool name

reset ip pool ?
   interface  Interface pool
   name       Pool name




Thank you for reading – please feel free to leave a comment

How to Format a HDD/Storage device in Linux and mount it

Intro

Whether you want to wipe everything off your disk or you need to change the filesystem type formatting a disk in Linux is not like Windows. My use case is: I have a disk already formatted to work with my Xbox console. I now don’t need it but I want to use it in my unRaid system as a backup location.

How to?

1 – Plug your device in
Using whatever connection you have, mine was a USB3.0 device so I plugged it in via USB, the same applies if this is SATA/e-SATA or SAS etc.

2 – SSH to your device
First ssh onto your server/device using putty or any other ssh client.
Log in.

You will be prompted as follows:

SSH to your device

In my case the server’s name is BRIERLEYS and I have logged in using the root account.

3 – Find your device

You need to see if your device has been recognised. If it is a new device use the following:

Command

Output
In this example I have removed my other disks from the output but you will see something along these lines. If you have multiple devices you need some way of identifying it physically. A good way is the drive size, and only add one at a time. Logically the letter will increment. So the next disk or storage device I put in will be sdg.

root@BRIERLEYS:~# fdisk -l | grep '^Disk'
Disk /dev/sdf: 1.84 TiB, 2000398933504 bytes, 3907029167 sectors
Disk model: Expansion

The command above uses fdisk and we use | and grep to essentially filter the output. Theres a little bit of regex which is saying anything beginning with Disk. The carrot (^) means start with.

Keep a note of the disk e.g. /dev/sdf in this example.

* If using a VM it will be something like vd or whatever the drive prefix you have setup.

4 – Format disk

Now we have identified our disk we can format it. You should pick your filesystem. I could use ext4 as this is a stable filesystem used by default for most Linux Distoros. Its the replacement for EXT3 which is older.
However as this is an external drive and I want to use it for backing up files I will use exFAT, this is a Microsoft filesystem but will work on Linux also. It supports files over 4GB and it means if I need to pull data from it I can just move it to any laptop without having to mess around.

The command I will use is:


mkfs.ntfs -F /dev/sdf

Note the -F flag, this will force mkfs to make a filesystem even if the disk is an entire device, use this if you are sure and you don’t mind everything being wiped.

Your output will be something similar to:

/dev/sdf is entire device, not just one partition.
mkntfs forced anyway.
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes:   0%

Let it complete and we can then use fdisk to setup a partition
5 – Use fdisk
Next we will use fdisk, this utility allows us to setup the partitions. fdisk is always my preffered option as for example parted (Another way) is not always included with your Linux system and saves having to install something else.
We have our disk so we use this now.

root@BRIERLEYS:~# fdisk /dev/sdf

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x690ab6b7.

Command (m for help):

Once you hit enter fdisk will launch. Hitting m followed by enter will show you the available options. But basic usage is:

  • m – print help
  • p – print the partition table
  • n – create a new partition
  • d – delete a partition
  • q – quit without saving changes
  • w – write the new partition table and exit

Hit the P key followed by enter to see the current partition table. We know it will be blank but just so we can see.

root@BRIERLEYS:~# fdisk /dev/sdf

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf1173745.

Command (m for help): p
Disk /dev/sdf: 1.84 TiB, 2000398933504 bytes, 3907029167 sectors
Disk model: Expansion
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf1173745

Command (m for help):

Now we can create a new partition, we basically enter n then p followed by enter untill its done

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-3907029166, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-3907029166, default 3907029166):

Created a new partition 1 of type 'Linux' and of size 1.8 TiB.

Keep note of the sector sizes, if you don’t want to use all of your disk for this partition then amend the Last sector. If you have another partition and you re-run this the first sector will be the next available sector after the last sector of the other partition.

  • NOW SAVE – whilst still in fdisk enter w followed by hitting return it should then drop you out of fdisk and provide some output as follows
Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

root@BRIERLEYS:~#

7 – Mount (If required)

This step is optional, for me I don’t need to mount this as I do it all on unRAID itself, if you need to mount the disk to the current system the best way is adding it to fstab, this way it is permeant as this will run at boot.

Add to FSTAB

edit fstab

nano /etc/fstab

Append this to the bottom

/dev/sdf               /mountpoint           filesystem    defaults        1 2

Amend to match your details. The mountpoint must exist, this is where you will access it. Please bare in mind that if you are logged on as a user for example bob and you don’t have access to /root for example then you cannot mount it here it will fail.

8 – test fstab

To test your fstab without rebooting just enter

mount -a

This will mount all your mounts specified (Hence the a for all)

Closing thoughts

As with anything Linux there are a number of different ways to do something. make sure you pay close attention to the output and if you are stuck or have any questions please let us know.

Thanks for reading

How to install GNS3-Server on Ubuntu 20.04

This is a quick reference guide on how to install GNS3-Server on Ubuntu 20.04

1. Install GNS3-Server

1.1 Update and add GNS3 repository

sudo apt-get update
sudo add-apt-repository ppa:gns3/ppa

1.2 Install GNS3-Server and GNS3-GUI

sudo apt-get install gns3-server gns3-gui

2. Create configuration File

Create file gns3_server.conf in directory /root/.config/GNS3/2.2/

cd /root/.config/GNS3/2.2/
nano gns3_server.conf

Paste the following configuration

[Server]
; IP where the server listen for connections
host = 0.0.0.0
; HTTP port for controlling the servers
port = 3080

; Option to enable SSL encryption
ssl = False
certfile=/home/gns3/.config/GNS3/ssl/server.cert
certkey=/home/gns3/.config/GNS3/ssl/server.key

; Path where devices images are stored
images_path = /home/gns3/GNS3/images

; Path where user projects are stored
projects_path = /home/gns3/GNS3/projects

; Path where user appliances are stored
appliances_path = /home/gns3/GNS3/appliances

; Path where custom device symbols are stored
symbols_path = /home/gns3/GNS3/symbols

; Option to automatically send crash reports to the GNS3 team
report_errors = True

; First console port of the range allocated to devices
console_start_port_range = 5000
; Last console port of the range allocated to devices
console_end_port_range = 10000

; First VNC console port of the range allocated to devices.
; The value MUST BE >= 5900 and = 5900 and <= 65535
vnc_console_end_port_range = 10000

; First port of the range allocated for inter-device communication. Two ports are allocated per link.
udp_start_port_range = 20000
; Last port of the range allocated for inter-device communication. Two ports are allocated per link
udp_end_port_range = 30000

; uBridge executable location, default: search in PATH
;ubridge_path = ubridge

; Option to enable HTTP authentication.
auth = False
; Username for HTTP authentication.
user = gns3
; Password for HTTP authentication.
password = gns3

; Only allow these interfaces to be used by GNS3, for the Cloud node for example (Linux/OSX only)
; Do not forget to allow virbr0 in order for the NAT node to work
allowed_interfaces = eth0,eth1,virbr0

; Specify the NAT interface to be used by the NAT node
; Default is virbr0 on Linux (requires libvirt) and vmnet8 for other platforms (requires VMware)
default_nat_interface = vmnet10

[VPCS]
; VPCS executable location, default: search in PATH
;vpcs_path = vpcs

[Dynamips]
; Enable auxiliary console ports on IOS routers
allocate_aux_console_ports = False
mmap_support = True
; Dynamips executable path, default: search in PATH
;dynamips_path = dynamips
sparse_memory_support = True
ghost_ios_support = True

[IOU]
; Path of your .iourc file. If not provided, the file is searched in $HOME/.iourc
iourc_path = /home/gns3/.iourc
; Validate if the iourc license file is correct. If you turn this off and your licence is invalid IOU will not start and no errors will be shown.
license_check = True

[Qemu]
; !! Remember to add the gns3 user to the KVM group, otherwise you will not have read / write permissions to /dev/kvm !! (Linux only, has priority over enable_hardware_acceleration)
enable_kvm = False
; Require KVM to be installed in order to start VMs (Linux only, has priority over require_hardware_acceleration)
require_kvm = False
; Enable hardware acceleration (all platforms)
enable_hardware_acceleration = True
; Require hardware acceleration in order to start VMs (all platforms)
require_hardware_acceleration = False

3. Start GNS3-Server

Simply type gns3server in your home directory to run application.

gns3server

The following example will show that GNS3 has started and is working. You will need to ensure that the Server and Client are on the same version or the client will not be able to connect with the GNS3-Server.

root@ur-buntub:~# gns3server
2021-02-11 20:06:12 INFO run.py:219 GNS3 server version 2.2.17
2021-02-11 20:06:12 INFO run.py:221 Copyright (c) 2007-2021 GNS3 Technologies Inc.
2021-02-11 20:06:12 INFO run.py:224 Config file /root/.config/GNS3/2.2/gns3_server.conf loaded
2021-02-11 20:06:12 INFO run.py:243 Running with Python 3.8.5 and has PID 8822
2021-02-11 20:06:12 INFO run.py:79 Current locale is en_US.UTF-8
2021-02-11 20:06:13 INFO web_server.py:318 Starting server on 0.0.0.0:3080
2021-02-11 20:06:13 INFO __init__.py:62 Load controller configuration file /root/.config/GNS3/2.2/gns3_controller.conf
2021-02-11 20:06:13 INFO __init__.py:66 Controller is starting
2021-02-11 20:06:13 INFO compute.py:64 Create compute local
2021-02-11 20:06:13 INFO compute.py:364 Connecting to compute 'local'
2021-02-11 20:06:13 INFO web_log.py:233 127.0.0.1 [11/Feb/2021:20:06:13 +0000] "GET /v2/compute/capabilities HTTP/1.1" 200 552 "-" "Python/3.8 aiohttp/3.6.2"
2021-02-11 20:06:13 INFO notification_handler.py:50 New client has connected to compute WebSocket
2021-02-11 20:06:13 INFO compute.py:434 Connected to compute 'local' WebSocket 'http://127.0.0.1:3080/v2/compute/notifications/ws'
^C2021-02-11 20:06:23 WARNING web_server.py:170 Server has got signal SIGINT, exiting...
2021-02-11 20:06:23 INFO web_server.py:113 Closing 1 websocket connections...
2021-02-11 20:06:23 INFO compute.py:460 Connection closed to compute 'local' WebSocket 'http://127.0.0.1:3080/v2/compute/notifications/ws'
2021-02-11 20:06:23 INFO notification_handler.py:59 Client has disconnected from compute WebSocket
2021-02-11 20:06:23 INFO __init__.py:130 Controller is stopping

4. Configure GNS3 Client

Click Edit and then Preferences

Thank you for reading – please do not hesitate to leave a comment if you have any questions.

How to configure a static IP address on Ubuntu 20.04 CLI

This is a quick reference guide on how to configure a static IP address on Ubuntu 20.04

1. Check interfaces by typing ifconfig -a

root@VPS:~# ifconfig -a
eth0: flags=4163&amp;lt;UP,BROADCAST,RUNNING,MULTICAST&amp;gt;  mtu 1500
inet 10.10.0.102  netmask 255.255.255.0  broadcast 10.10.0.255
inet6 fe80::7ff:fe59:9a16  prefixlen 64  scopeid 0x20 	&amp;lt;link&amp;gt;
        ether 02:00:07:59:9a:16  txqueuelen 1000  (Ethernet)
RX packets 226  bytes 23624 (23.6 KB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 95  bytes 14736 (14.7 KB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&amp;lt;UP,LOOPBACK,RUNNING&amp;gt;  mtu 65536
inet 127.0.0.1  netmask 255.0.0.0
inet6 ::1  prefixlen 128  scopeid 0x10&amp;lt;host&amp;gt;
loop  txqueuelen 1000  (Local Loopback)
RX packets 2  bytes 78 (78.0 B)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 2  bytes 78 (78.0 B)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

You will need to specify the interface that you would like to statically assign an IP address to. In this scenario the interface is eth0.

2. Create a yaml file in /etc/netplan

Use nano to create and edit files – simply run the following command if you do not have it installed.

apt-get install nano

Create a yaml file under /etc/netplan – I have used network_config.yaml as my file name.

root@VPS:~# cd /etc/netplan/
root@VPS:/etc/netplan# nano network_config.yaml

Enter the following into network_config.yaml file using nano – make sure you change the interface to your ifconfig -a output (the interface you would like to configure your static IP on). My interface in this scenario is eth0.

You will also need to specify your default gateway and your dns servers. These are configured under the following headings: gateway4 and nameservers respectively.

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 10.0.125.10/24
      gateway4: 10.0.125.254
      nameservers:
          search: [mydomain, otherdomain]
          addresses: [10.10.0.1, 1.1.1.1]

3. Apply Netplan

root@VPS:/etc/netplan# sudo netplan apply

4. Check that you have received an IP address on the interface you have specified by running ifconfig.

root@VPS:/etc/netplan# ifconfig
eth0: flags=4163&amp;lt;UP,BROADCAST,RUNNING,MULTICAST&amp;gt;  mtu 1500
        inet 10.10.0.102  netmask 255.255.255.0  broadcast 10.10.0.255
        inet6 fe80::7ff:fe59:9a16  prefixlen 64  scopeid 0x20&amp;lt;link&amp;gt;
        ether 02:00:07:59:9a:16  txqueuelen 1000  (Ethernet)
        RX packets 770  bytes 77688 (77.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 271  bytes 38562 (38.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&amp;lt;UP,LOOPBACK,RUNNING&amp;gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10&amp;lt;host&amp;gt;
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 78 (78.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 78 (78.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Thank you for reading and please feel free to leave any feedback.

How to perform throughput testing using iPerf3 on Ubuntu 20.04 CLI

This is a detailed guide on how to perform throughput testing using IPERF on Linux Based Operating Systems.

1. Install iPerf3

You will need to have iPerf3 installed on both endpoints. iPerf3 works using a client and server model.

apt install iperf3

2. iPerf3 Server

Once installed you will need one end point to listen for iPerf traffic. By default this will listen on port 5201.

2.1 iperf3 -s

This command will start the iPerf server

root@FTP:/etc/conf.d# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

2.2 iperf3 -s -p

This will specify which port to listen on. You will need to ensure that this is specified on both client and server.

root@FTP:/etc/conf.d# iperf3 -s -p 5002
-----------------------------------------------------------
Server listening on 5002
-----------------------------------------------------------

3. iPerf3 Client

Command examples:

Replace 10.0.x.x with the server IP address.

iperf3 -c 10.0.x.x -t 5 -l 1000k
iperf3 -c 10.0.x.x -t 5 -l 1000k -w 2.5m
iperf3 -c 10.0.x.x -t 5 -l 1000k -w 2.5m -P 5
iperf3 -c 10.0.x x -t 60 -l 1000k -w 2.5m -P 5
iperf3 -c 10.0.x.x -t 60 -l 1000k -w 2.5m -P 10 
iperf3 -c 10.0.x.x -t 5 -l 1000k -R
-t, –time nThe time in seconds to transmit for. iPerf normally works by repeatedly sending an array of len bytes for time seconds. Default is 10 seconds.
-l, –length n[KM]The length of buffers to read or write. iPerf works by writing an array of len bytes a number of times. Default is 128 KB for TCP, 8 KB for UDP
-w, –window n[KM]Sets the socket buffer sizes to the specified value. For TCP, this sets the TCP window size. (this gets sent to the server and used on that side too)
-R, –reverseRun in reverse mode (server sends, client receives).

4. Testing using Wondershaper (Traffic Shaper)

You can install wondershaper to shape the client or servers interface bandwidth.

4.1 Install Wondershaper

apt install wondershaper

IMPORTANT: The following installation will create the directory for where the traffic shaping configuration will go.

cd bin
git clone https://github.com/magnific0/wondershaper.git
cd wondershaper
make install

4.2 Edit /etc/conf.d/wondershaper.conf

nano /etc/conf.d/wondershaper.conf

Example configuration:

You will need to specify which interface and what the bandwidth is restricted to in kbps.

[wondershaper]
# Adapter
#
IFACE="eth0"

# Download rate in Kbps
#
DSPEED="10240"

# Upload rate in Kbps
#
USPEED="10240"

4.3 Restart Wondershaper

service wondershaper restart

5. iPerf Before and after Wondershaper.

root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38860 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   115 MBytes   968 Mbits/sec    0   3.03 MBytes
[  4]   1.00-2.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   2.00-3.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   3.00-4.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   4.00-5.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   5.00-6.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   6.00-7.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   7.00-8.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   8.00-9.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   9.00-10.00  sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.10 GBytes   942 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  1.09 GBytes   939 Mbits/sec                  receiver

iperf Done.
root@FTP:~# service wondershaper start
root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38864 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  1.71 MBytes  14.3 Mbits/sec    0    102 KBytes
[  4]   1.00-2.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   2.00-3.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   3.00-4.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   4.00-5.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   5.00-6.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   6.00-7.00   sec  1.06 MBytes  8.86 Mbits/sec    0    102 KBytes
[  4]   7.00-8.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   8.00-9.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   9.00-10.00  sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  11.7 MBytes  9.83 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  11.1 MBytes  9.31 Mbits/sec                  receiver

iperf Done.

Thank you for reading and please feel free to leave any feedback.

How to shape traffic using Wondershaper on Ubuntu 20.04 CLI

This is a quick reference guide on how to shape traffic using Wondershaper on Linux Based Operating Systems.

1. Install Wondershaper

apt install wondershaper

IMPORTANT: The following installation will create the directory for where the traffic shaping configuration will go.

cd bin
git clone https://github.com/magnific0/wondershaper.git
cd wondershaper
make install

2. Edit /etc/conf.d/wondershaper.conf

nano /etc/conf.d/wondershaper.conf

Example configuration:

You will need to specify which interface and what the bandwidth is restricted to in kbps.

[wondershaper]
# Adapter
#
IFACE="eth0"

# Download rate in Kbps
#
DSPEED="10240"

# Upload rate in Kbps
#
USPEED="10240"

3. Restart Wondershaper

service wondershaper restart

4. iPerf Before and after Wondershaper.

root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38860 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   115 MBytes   968 Mbits/sec    0   3.03 MBytes
[  4]   1.00-2.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   2.00-3.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   3.00-4.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   4.00-5.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   5.00-6.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   6.00-7.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   7.00-8.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   8.00-9.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   9.00-10.00  sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.10 GBytes   942 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  1.09 GBytes   939 Mbits/sec                  receiver

iperf Done.
root@FTP:~# service wondershaper start
root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38864 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  1.71 MBytes  14.3 Mbits/sec    0    102 KBytes
[  4]   1.00-2.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   2.00-3.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   3.00-4.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   4.00-5.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   5.00-6.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   6.00-7.00   sec  1.06 MBytes  8.86 Mbits/sec    0    102 KBytes
[  4]   7.00-8.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   8.00-9.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   9.00-10.00  sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  11.7 MBytes  9.83 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  11.1 MBytes  9.31 Mbits/sec                  receiver

iperf Done.

Thank you for reading and please feel free to leave any feedback.

How to add a static route on Ubuntu 20.04 CLI

This is a quick reference guide on how to add a persistent static route on on Ubuntu 20.04

1. Edit yaml file in /etc/netplan

At this point you should already have a netplan yaml file created either for dhcp or a statically assigned interface IP address.

root@VPS2:~# cd /etc/netplan/
root@VPS2:/etc/netplan# ls
network_config.yaml
root@VPS2:/etc/netplan# nano network_config.yaml

2. Define routes in yaml file.

IMPORTANT: It is extremely important to place all the configuration in the correct columns otherwise the configuration will not take. You should be able to copy, edit and paste the configuration example below and this will place the configuration correctly into your file.

The example below shows me pointing all traffic destined for 10.1.1.0/24 to go via 192.168.1.2.

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            addresses:
                - 192.168.1.100/24
            gateway4: 192.168.1.1
            nameservers:
                addresses:
                - 8.8.8.8
                search:
                - mydomain.net
            routes:
                    - to: 10.1.1.0/24
                      via: 192.168.1.2

3. Apply Netplan

root@VPS2:/etc/netplan# netplan apply

3. Check that the route is in the routing table using “route -n”

root@VPS2:/etc/netplan# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

Thank you for reading and please feel free to leave any feedback.

How to shape traffic using Wondershaper on Ubuntu 18.04 CLI

This is a quick reference guide on how to shape traffic using Wondershaper on Linux Based Operating Systems.

1. Install Wondershaper

apt install wondershaper

IMPORTANT: The following installation will create the directory for where the traffic shaping configuration will go.

cd bin
git clone https://github.com/magnific0/wondershaper.git
cd wondershaper
make install

2. Edit /etc/conf.d/wondershaper.conf

nano /etc/conf.d/wondershaper.conf

Example configuration:

You will need to specify which interface and what the bandwidth is restricted to in kbps.

[wondershaper]
# Adapter
#
IFACE="eth0"

# Download rate in Kbps
#
DSPEED="10240"

# Upload rate in Kbps
#
USPEED="10240"

3. Restart Wondershaper

service wondershaper restart

4. iPerf Before and after Wondershaper.

root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38860 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   115 MBytes   968 Mbits/sec    0   3.03 MBytes
[  4]   1.00-2.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   2.00-3.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   3.00-4.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   4.00-5.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   5.00-6.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   6.00-7.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   7.00-8.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   8.00-9.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   9.00-10.00  sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.10 GBytes   942 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  1.09 GBytes   939 Mbits/sec                  receiver

iperf Done.
root@FTP:~# service wondershaper start
root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38864 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  1.71 MBytes  14.3 Mbits/sec    0    102 KBytes
[  4]   1.00-2.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   2.00-3.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   3.00-4.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   4.00-5.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   5.00-6.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   6.00-7.00   sec  1.06 MBytes  8.86 Mbits/sec    0    102 KBytes
[  4]   7.00-8.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   8.00-9.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   9.00-10.00  sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  11.7 MBytes  9.83 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  11.1 MBytes  9.31 Mbits/sec                  receiver

iperf Done.

Thank you for reading and please feel free to leave any feedback.

How to configure a static IP address on Ubuntu 18.04 CLI

This is a quick reference guide on how to configure a static IP address on Ubuntu 18.04

1. Check interfaces by typing ifconfig -a

root@VPS:~# ifconfig -a
eth0: flags=4163&amp;lt;UP,BROADCAST,RUNNING,MULTICAST&amp;gt;  mtu 1500
inet 10.10.0.102  netmask 255.255.255.0  broadcast 10.10.0.255
inet6 fe80::7ff:fe59:9a16  prefixlen 64  scopeid 0x20 	&amp;lt;link&amp;gt;
        ether 02:00:07:59:9a:16  txqueuelen 1000  (Ethernet)
RX packets 226  bytes 23624 (23.6 KB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 95  bytes 14736 (14.7 KB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&amp;lt;UP,LOOPBACK,RUNNING&amp;gt;  mtu 65536
inet 127.0.0.1  netmask 255.0.0.0
inet6 ::1  prefixlen 128  scopeid 0x10&amp;lt;host&amp;gt;
loop  txqueuelen 1000  (Local Loopback)
RX packets 2  bytes 78 (78.0 B)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 2  bytes 78 (78.0 B)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

You will need to specify the interface that you would like to statically assign an IP address to. In this scenario the interface is eth0.

2. Create a yaml file in /etc/netplan

Use nano to create and edit files – simply run the following command if you do not have it installed.

apt-get install nano

Create a yaml file under /etc/netplan – I have used network_config.yaml as my file name.

root@VPS:~# cd /etc/netplan/
root@VPS:/etc/netplan# nano network_config.yaml

Enter the following into network_config.yaml file using nano – make sure you change the interface to your ifconfig -a output (the interface you would like to configure your static IP on). My interface in this scenario is eth0.

You will also need to specify your default gateway and your dns servers. These are configured under the following headings: gateway4 and nameservers respectively.

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 10.0.125.10/24
      gateway4: 10.0.125.254
      nameservers:
          search: [mydomain, otherdomain]
          addresses: [10.10.0.1, 1.1.1.1]

3. Apply Netplan

root@VPS:/etc/netplan# sudo netplan apply

4. Check that you have received an IP address on the interface you have specified by running ifconfig.

root@VPS:/etc/netplan# ifconfig
eth0: flags=4163&amp;lt;UP,BROADCAST,RUNNING,MULTICAST&amp;gt;  mtu 1500
        inet 10.10.0.102  netmask 255.255.255.0  broadcast 10.10.0.255
        inet6 fe80::7ff:fe59:9a16  prefixlen 64  scopeid 0x20&amp;lt;link&amp;gt;
        ether 02:00:07:59:9a:16  txqueuelen 1000  (Ethernet)
        RX packets 770  bytes 77688 (77.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 271  bytes 38562 (38.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&amp;lt;UP,LOOPBACK,RUNNING&amp;gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10&amp;lt;host&amp;gt;
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 78 (78.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 78 (78.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Thank you for reading and please feel free to leave any feedback.

How to make a shell script executable Linux CLI

This is a quick reference guide on how to make a shell script executable on Linux Based Operating Systems.

1. chmod +x

root@FTP:~# ./shell.sh
-bash: ./shell.sh: Permission denied
root@FTP:~# chmod +x shell.sh
root@FTP:~# ./shell.sh

Thank you for reading and please feel free to leave any feedback.