Author Archives: alfred
Grab the gateway of ppp0
OLDGW=`route -n | grep "ppp0" | awk -F: '{print $1}' | grep "UH" | awk '{print $1}'`
Install Munin using docker
docker run -dit --restart unless-stopped -p 8080:80 -e TZ="Asia/Hong_Kong" -e NODES="1867:172.17.0.1" occitech/munin:latest
Set CentOS 7 as a router
firewall-cmd --add-masquerade --permanent sudo firewall-cmd --reload firewall-cmd --add-port=port-number/port-type
- Make the new settings persistent:
$ sudo firewall-cmd --runtime-to-permanent
Reference: https://linuxhint.com/centos7_router/
Change to use a free jsdelivr
cd /www/wwwroot/ && find -type f -name "*.tpl" | xargs sed -i 's/jsdelivr.example.com/cdn.jsdelivr.net/'
How to install ntop
docker run -dit --restart unless-stopped -p 3000:3000 -v $(pwd)/ntopng.license:/etc/ntopng.license:ro --net=host ntop/ntopng:latest -i eth0 docker run -dit --cpuset-cpus="2" --restart unless-stopped -p 3000:3000 -v $(pwd)/ntopng.license:/etc/ntopng.license:ro --net=host ntop/ntopng:latest -i eth0 -i eth1 -i tap_biz
How to copy docker image from a host to another one
docker save -o <path for generated tar file> <image name>
docker load -i <path to copied image file>
Docker can’t be started: Error initializing network controller: list bridge addresses failed
Solution:
Create docker network interface manually using the following commands:
ip link add name docker0 type bridge
ip addr add dev docker0 172.x.y.z/16
How to install BBR on CentOS 7
Since CentOS 7 ships with the 3.10.x kernel, which does not include BBR by default, we need to upgrade to a newer kernel version on your machine to use BBR.
For this, we install the ELRepo repo,
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Output:
[root@vps ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@vps ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Retrieving http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Retrieving http://elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:elrepo-release-7.0-4.el7.elrepo ################################# [100%]
[root@vps ~]#
To install kernel using the ELRepo repo,
yum --enablerepo=elrepo-kernel install kernel-ml -y
Output:
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
kernel-ml x86_64 5.12.9-1.el7.elrepo elrepo-kernel 53 M
Transaction Summary
================================================================================
Install 1 Package
.
.
.
Installed:
kernel-ml.x86_64 0:5.12.9-1.el7.elrepo
Complete!
Now check the stable kernel installation by using the following command,
rpm -qa | grep kernel
Note: If the installation is successful, you should see kernel-ml-5.xx.xx.elrepo.x86_64 among the output list:
Output:
[root@vps ~]# rpm -qa | grep kernel
kernel-3.10.0-1160.el7.x86_64
kernel-tools-3.10.0-1160.el7.x86_64
kernel-ml-5.12.9-1.el7.elrepo.x86_64
kernel-tools-libs-3.10.0-1160.el7.x86_64
[root@vps ~]#
Boot into the newer Kernel
Next, you need to boot into the latest kernel by setting it as the default grub2 boot entry.
Command to show all entries in the grub2 menu,
egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
Output:
[root@vps ~]# egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
CentOS Linux 7 Rescue 13f95ded0c4147935ac6afed832cfb0a (5.12.9-1.el7.elrepo.x86_64)
CentOS Linux (5.12.9-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-dd1973a114f84ea8bbf37b494513d3f7) 7 (Core)
Use the following command to set the default boot entry,
Note: The count starts from 0 and the latest stable kernel is on the second line thus we set it to 1
For example,
[root@vps ~]# egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
CentOS Linux 7 Rescue 13f95ded0c4147935ac6afed832cfb0a (5.12.9-1.el7.elrepo.x86_64) <-- 0
CentOS Linux (5.12.9-1.el7.elrepo.x86_64) 7 (Core) <-- 1
CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core) <-- 2
CentOS Linux (0-rescue-dd1973a114f84ea8bbf37b494513d3f7) 7 (Core) <-- 3
grub2-set-default 1
Reboot the server
shutdown -r now
Once the server is back online, confirm that you are using the correct kerne.
uname -r
Output:
[root@vps ~]# uname -r
5.12.9-1.el7.elrepo.x86_64
Enable Google BBR.
You need to modify systctl as follows to enable the Google BBR algorithm.
echo 'net.core.default_qdisc=fq' | tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' | tee -a /etc/sysctl.conf
sysctl -p
Output:
[root@vps ~]# echo 'net.core.default_qdisc=fq' | tee -a /etc/sysctl.conf
net.core.default_qdisc=fq
[root@vps ~]# echo 'net.ipv4.tcp_congestion_control=bbr' | tee -a /etc/sysctl.conf
net.ipv4.tcp_congestion_control=bbr
[root@vps ~]# sysctl -p
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
Run the following command to verify if BBR is enabled,
sysctl net.ipv4.tcp_available_congestion_control
Output:
[root@vps ~]# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = reno cubic bbr
Finally, execute the following command to verify the Google BBR,
lsmod | grep bbr
Output:
[root@vps ~]# lsmod | grep bbr
tcp_bbr 20480 1
Congratulations! You have successfully installed TCP BBR Congestion Control.
Reference: https://wiki.crowncloud.net/?How_to_Enable_Google_BBR_on_CentOS_7
Install Zabbix Agent from Source on Linux
1
2
|
groupadd zabbix useradd -g zabbix zabbix |
Download and install latest version of zabbix from source.
1. cd /usr/local/src 2. wget http://freefr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz 3. tar -zxvf zabbix-3.0.3.tar.gz 4. cd zabbix-3.0.3 5. ./configure --enable-agent 6. make install |
Edit Zabbix agent configuration file at
1
|
vi /usr/local/etc/zabbix_agentd.conf |
Add Zabbix server IP address to the file.
1
|
Server = 127.0.0.1, ZABBIX_SERVER_IP |
Start zabbix_agentd
1
|
[root@server ~]# zabbix_agentd |
Verify Zabbix agent log for errors.
1
|
tail /tmp/zabbix_agentd.log |
Then login to Zabbix Dashboard on zabbix server and add a new host by entering the following details.
1
2
3
|
Host name: client host name Groups: Linux Servers IP address: client host IP |
Enable Zabbix Agent to start on Boot CentOS
1
2
3
4
|
[root@server ~]# cd /usr/local/src/zabbix-*/ [root@server zabbix-3.0.3]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/zabbix_agentd [root@server zabbix-3.0.3]# chkconfig --add zabbix_agentd [root@server zabbix-3.0.3]# chkconfig zabbix_agentd on |
If everything is alright, you should see 3:on like below when running the following command.
1
2
3
|
[root@server ~]# chkconfig | grep zabbix zabbix_agentd 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@server ~]# |
Enable Zabbix Agent to start on Boot (Ubuntu/Debian)
1
2
3
4
|
cd ~/zabbix-source/zabbix-*/ cp misc/init.d/debian/zabbix-agent /etc/init.d chmod 755 /etc/init.d/zabbix-agent update-rc.d zabbix-agent defaults |
Reference: https://blog.hostonnet.com/install-zabbix-agent-from-source-linux