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.

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to https://piggybank.cloud

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<UP,BROADCAST,RUNNING,MULTICAST>  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 	<link>
        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<UP,LOOPBACK,RUNNING>  mtu 65536
inet 127.0.0.1  netmask 255.0.0.0
inet6 ::1  prefixlen 128  scopeid 0x10<host>
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<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
        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<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        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

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to https://piggybank.cloud

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

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to https://piggybank.cloud

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

How to add a user to a group Linux CLI

This is a quick reference guide on how to check your network interfaces on Linux Based Operating Systems.

1. ifconfig -a

root@FTP1:~# addgroup ftpgroup user1
addgroup: The user `ftpgroup' does not exist.
root@FTP1:~# adduser user1 ftpgroup
Adding user `user1' to group `ftpgroup' ...
Adding user user1 to group ftpgroup
Done.
root@FTP1:~# adduser user2 ftpgroup
Adding user `user2' to group `ftpgroup' ...
Adding user user2 to group ftpgroup
Done.

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to https://piggybank.cloud

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

How to change group ownership of a file Linux CLI

This is a quick reference guide on how to change group ownership of a file on Linux Based Operating Systems.

1. Change group ownership of a file using chgrp command

[root@vps1 ~]# chgrp root file1
[root@vps1 ~]# ls -l file1
-rw-r--r-- 1 root root 0 Jun  4 11:06 file1
[root@vps1 ~]# chgrp vpsuser file1
[root@vps1 ~]# ls -l file1
-rw-r--r-- 1 root vpsuser 0 Jun  4 11:06 file1

2. Check the file permission using ls -l

root@vps:~# ls -l file1
-rwxr-x--x 1 root root 0 Jun  3 08:17 file1

A dash (-) indicates that the file is a regular file.

The letter (d) indicates that the file is a directory as per below:

A letter (l) preceding indicates a special file type called a symlink. A symlink is a pointer to another location in the file system.

drwxr-xr-x 3 root root       4096 Oct 18  2018 ufw

The first three letters above refer to the permission of the user so in this case rwx, so read, write, and execute.

The next three letters is for group r-x, so read and execute, but not write as indicated by the dash.

The next three letters is for other r-x, so read and execute, but not write as indicated by the dash. (so the same as group in this example)

The number 3 in this example after the permissions indicates the number of files or sub-directories contained within this particular directory.

The first name after the number (directory and file number) in the example below is the user or file owner. “vpsuser”

The second name refers to the files group. “group1”

-rwxr-x--x 1 vpsuser group1 0 Jun  3 08:17 file1
root@vps:~#

The remainder of the file details are the size of the file, the date and time that the file was created or last modified, and the file name.

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to https://piggybank.cloud

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

How to show interface statistics using netstat -i command Linux CLI

This is a quick reference on how to show interface statistics using the netstat -i command on Linux Based Operating Systems.

1. netstat -i

root@GNS3-Server:~# netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
docker0    1500 0         0      0      0 0             0      0      0      0 BMU
eth0       1500 0       572      0      0 0           359      0      0      0 BMRU
eth1       1500 0        43      0      0 0            37      0      0      0 BMRU
lo        65536 0      3172      0      0 0          3172      0      0      0 LRU
tun1194    1500 0         0      0      0 0             0      0      0      0 MOPRU
virbr0     1500 0         0      0      0 0             0      0      0      0 BMU
root@GNS3-Server:~#

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to https://piggybank.cloud

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

How to show established tcp connections using the netstat command Linux CLI

This is a quick reference on how to show established tcp connections using the netstat command on Linux Based Operating Systems.

1. netstat

root@GNS3-Server:~# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 172.16.253.1:3080       172.16.253.1:43486      ESTABLISHED
tcp        0      0 172.16.253.1:43486      172.16.253.1:3080       ESTABLISHED
tcp        0      0 10.0.125.10:ssh         90.240.10.190:59675     ESTABLISHED

If you are new to the world of Linux, an avid Linux enthusiast or a student why not try our 0.99p per month Linux VPS.

Simply click on the screen shot below to find out more or navigate to https://piggybank.cloud

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