nyuuzyou/wikis huggingface dataset:
Setting up MRTG and Smokeping to Monitor Bandwidth Usage and Network Latency

Notes for smokeping(in progress):
Lighttpd - do not execute CGIs with interpreter
Need perl-rrd
Need perl CPAN URI::Escape
Paths within smokeping scripts (/etc/smokeping/*, smokeping.cgi, perl libs, scripts in bin)
Setup monitoring hosts
Notes for MRTG (in progress):
Deps: gd-dev, libpng-dev, zlib-dev
configure --prefix=/usr/local/mrtg-2
make && make install
/usr/local/mrtg-2/bin/cfgmaker --global 'WorkDir: /path/to/work/dir' --global 'Options[_]: bits,growright' --output /path/to/config/file/mrtg.cfg snmp-community@host
Check that output folder is accessible via web server (ie /var/www/localhost or whatever you have configured)
To test: /usr/local/mrtg-2/bin/mrtg /path/to/config/file/mrtg.cfg
Once working, add to crontab to run as often as desired (ie 5 min)
Category:Monitoring
Setting up NRPE daemon

Install daemon:
 
Set up config file to bind to local IP, only allow needed hosts to connect (in /etc/nrpe.cfg):
 server_address=10.14.8.3
 allowed_hosts=10.14.8.149,10.14.8.150
Add a definition for a check command to /etc/nrpe.cfg, for example:
 command[check_routes]=/usr/bin/check_routes.sh
Create the above script, and populate:
 #!/bin/sh
 #
 numroutes_ok=80
 numroutes_warn=15
 
 NUMROUTES=`ip route | grep -n | awk -F ':' '{print $1}' | tail -n 1`
 if [ -z "$NUMROUTES" ]; then
 echo "WARNING: No routing information received"
 exit 1
 elif [ $NUMROUTES -ge $numroutes_ok ]; then
 echo "OK: $NUMROUTES routes in routing table"
 exit 0
 elif [ $NUMROUTES -ge $numroutes_warn ]; then
 echo "WARNING: $NUMROUTES routes in routing table"
 exit 1
 else
 echo "CRITICAL: $NUMROUTES routes in routing table"
 exit 2
 fi
Restart NRPE.
Allow port 5666 (or whatever port you've specified for nrpe in /etc/nrpe.cfg) through Shorewall (in /etc/shorewall/rules) through to monitoring hosts.
On the monitoring host, run the following command to test, where 10.14.8.3 is the IP of the host to monitor:
You should get output like:
 OK: 173 routes in routing table
If you are having trouble, enable debugging in /etc/nrpe.cfg, and check /var/log/messages for errors. Most likely error(s) has to do with permissions of what you are trying to execute.
Example of monitoring opennhrp connection: 
 #!/bin/sh 
 # $1 is hostname to check
 
 if [ -z "$1" ]; then
 echo "Hostname must be specified as argument"
 exit 1 
 fi
 
 # The 5 second wait is in case tunnel wasn't up, this will act as a keepalive when run often enough
 ping -c 1 -w 5 $1 > /dev/null 
 
 HOSTOUTPUT="`host $1`" 
 # The final awk will grep for a /16 network range
 HOSTNETWORK="`echo $HOSTOUTPUT | awk -F ' ' '{print $NF}' | awk -F '.' '{print $1"."$2}'`" 
 ROUTETONETWORK="`ip route | grep $HOSTNETWORK'\.'`" 
 NEXTHOP="`echo $ROUTETONETWORK | awk -F ' ' '{print $3}'`" 
 # This assumes that up/down is last entry on line which it was in testing
 TUNNELSTATUS="`/usr/sbin/opennhrpctl show | grep -A 3 $NEXTHOP | grep Flags | awk -F ' ' '{print $NF}'`"
 
 echo $TUNNELSTATUS
Category:Monitoring
Category:Networking
Setting up Smokeping

Smokeping is a network latency monitor webapp. 
Install smokeping and lighttpd from main repository.
In lighttpd.conf uncomment line: include "mod_cgi.conf", save and exit 
Assign cgi to run with /usr/bin/perl in /etc/lighttpd/mod_cgi.conf (by default it's only in cgi-bin virtual host): 
 cgi.assign = (
 ".cgi" => "/usr/bin/perl"
 )
And uncomment the use of mod.cgi in /etc/lighttpd/lighttpd.conf.
=== FastCGI Support ===
Smokeping is slow, and fastcgi can help , especially on constrained devices. 
install
lighttpd.conf:
 include "mod_fastcgi.conf"
mod_fastcgi.conf:
 server.modules += ("mod_fastcgi")
 fastcgi.server = (
 ".fcgi" =>
 ((
 "bin-path" => "/usr/share/webapps/smokeping/smokeping.fcgi",
 "host" => "localhost",
 "port" => 8001,
 )),
 )
== Setup URLs for Smokeping ==
Softlink /usr/share/webapps/smokeping -> /var/www/localhost/htdocs/smokeping
Softlink /var/lib/smokeping/.simg -> /var/www/localhost/htdocs/img
Make /smokeping/ work
lighttpd.conf:
 index-file.names = ("smokeping.fcgi", "smokeping.cgi", "index.php", "index.html", "index.htm", "default.htm")
== Setup Probes & Permissions ==
If using a version of Alpine older than 2.1_rc2, edit /usr/share/perl5/vendor_perl/Qooxdoo/Services/Tr.pm and on line 34: add "sudo", to beginning so that line looks like:
 system "sudo","traceroute","-I","-q","1",$host;
This is because in Alpine, regular user can't run a traceroute
Add sudo package, then add the following to /etc/sudoers using visudo command:
 lighttpd ALL=(ALL) NOPASSWD: /usr/bin/traceroute
Change permissions on /var/lib/smokeping/.simg to 777. 
Set fping to using setuid: 
== Configure Targets ==
Add hosts to be monitored in /etc/smokeping/config and remove example hosts
The cache configured must be linked to /var/www/localhost/htdocs/smokeping/cache
== Activate Smokeping Service at Boot ==
Set lighttpd to autostart and start the daemon.
Set smokeping to autostart and start the daemon.
For further information on configuration, see the smokeping homepage https://oss.oetiker.ch/smokeping/doc/index.en.html.
Category:Monitoring
Setting up Streaming an Asterisk Channel

= Streaming an Asterisk Channel HOW-TO =
== Introduction ==
The Asterisk is well known as VoIP service. Obviously, the nature of VoIP technology requires a real time communication, which makes certain requirements to a network connectivity layer in such regards as link speed/bandwidth, IP packet prioritization/control and network latency. 
In some cases it is desireable to provide at least one way communication possibility. For example, this idea could be used to give an ability at least "to listen" to a corporate work meeting/conferece, which is organized by means Asterisk MeetMe conference feature to those Remote Locations that still have relatively poor network connectivity layer with a Head Office. Another application is streaming an Asterisk channel to the Internet.
== How does it work? ==
The Asterisk is used with conjunction with sound streaming software such as Icecast2 server. The streaming technology provides "caching/buffering" capabilities. So broadcasted/recieved sound is being buffered, which helps overall sound quality to remain high surviving most of problems in network bandwidth and latencies.
The Asterisk system places an automatic call to connect two extensions. One extension provides an Asterisk channel sound (MusicOnHold, Playback, MeetMe adn etc.), the second one starts the Asterisk Ices application and merges sound to it. The Ices Application depends on Icecast Ices, which is a source of sound to Icecast2 service.
After sound is merged to Icecast Service by means Icecast Ices and Asterisk Ices Applications it could be listened as ogg sound stream by WinAmp, VLC media players. The stream cache parameter should be ajusted according local needs to achieve the acceptable sound quality.
== Setup Asterisk Ices Application ==
First of all, we need to install asterisk :
As we are planning to use MeetMe functions we also need a timer :
We then need to make sure the module is loaded at startup:
Asterisk runs by default under the asterisk user. The dahdi pseduo device's owner is root. We need to change that :
Note : every time you'll reboot the rights will be reset. So you need to put that command into a script that runs after a startup.
Finally add asterisk as a startup service :
Optionnaly we could install the samples for asterisk :
Don't forget to reboot to load the dahdi modules (see note above).
== Setup Icecast Ices Source ==
Ices2 package is in Edge/testing repository (see Edge to activate it).
Alternatively you can compile it from the source. 
For that we need the compiler's package :
Then we need the appropriate dependencies for ices to compile :
We get the source code :
Decompress :
Compile and install :
== Setup Icecast2 Service ==
There is already a package build for Icecast2 :
We add Icecast server at startup :
Edit /etc/icecast.xml to your needs.
Icecast runs by default as Icecast user. In some cases it might be usefull to run as Asterisk user :
And change these settings in icecast.xml :
== Using Media Players ==
== More Information ==
Category:Telephony
Setting up Transmission (bittorrent) with Clutch WebUI

== Introduction ==
This document will show you how you can setup Transmission BitTorrent client on Alpine Linux and control it with a nice HTTP web-interface. It is assumed that you know the basics of Alpine Linux (package management and internals) and you have enough storage available for your downloaded media (i.e. USB hard drive) and, of course, a working internet connection.
== Setting up Transmission ==
Lets install it:
This should install latest available version of Transmission (available on Alpine). After the installation is complete you should have default configuration file for init in .
By default, Transmission will run as the user transmission. If you need to make changes, do so, and save them. You can restart transmission-daemon and see if all is working as desired:
To configure the transmission settings (including the download location), edit the configuration file here: 
If everything is working, you should see transmission-daemon running with the following command:
If you change the download location in the settings, remember to transfer ownership to the transmission user and group.
It may also be convenient for the root user to be able to access the files when administering the server. An easy way to do this is to add the root user to the transmission group:
Let's add transmission to our system start:
The transmission web GUI will run on http://<IP_ADDRESS>:9091/transmission
== Saving your changes to disk ==
Now is a good time to write your changes to disk:
Category:Server
Setting up Transparent Content Filter on Gateway with Privoxy

These instructions set up a transparent web content filter on the gateway, using privoxy. By default Privoxy contains a crude parental-controls filter that can filter many pornographic sites. Its not perfect, but nothing is.
This is significantly lighter weight than squid+dansguardian or squid+squark; and may be suitable for a small home network.
== Install Privoxy ==
* Install privoxy
* Edit the /etc/privoxy/config file, and edit the listen-address:
listen-address :8080 
# We will be doing intercepting proxying
accept-intercepted-requests 1 
* Edit /etc/privoxy/default.filter. The default "sex" rule matches lots of javascript, like "trendsexplorer".Search for "parental", and change the line regarding "sex" to:
s%^.*(?<!middle)(?<!sus)(?<!es)sexy.*$%<html><head><title>Blocked</title></head><body>\
Blocked by Privoxy's crude-parental filter due to possible adult content.</body></html>%is
This is going to loosen the rules a bit, but should still block most stuff.
* Edit /etc/privoxy/user.action file, and add the following to the end
# Content filter everything
{+filter{crude-parental}} 
/.*
 
# Anything here gets whitelisted
{-filter{crude-parental}} 
wiki.alpinelinux.org
* If you do not want to advertise you are using privoxy, edit /etc/privoxy/default.filter, search for the parental-crude filter, and change the text as you like.
* Start privoxy
* add privoxy to the startup scripts
* To test, set your browser to use 192.168.1.1:8080 as the proxy, and enter "http://config.privoxy.org" - you should go to the privoxy page. 
* Unset your browser's proxy settings.
== Set up Transparent Proxy Redirection ==
* Add awall
* Create /etc/awall/optional/home-firewall.json - Change the interfaces in the zones as appropriate:
{
"description": "Home Firewall",
"zone": {
 "inet" : { "iface" : "eth1" },
 "loc" : { "iface" : "eth0" }
 },
"policy": [
 { "in": "_fw", "action": "accept" },
 { "in": "loc", "out": "inet", "action": "accept" },
 { "in": "loc", "out": "_fw", "action": "accept" }
 ],
"snat": [
 { "out": "inet" }
 ],
"dnat": [
 { "in": "loc", "service": "http", "to-port": 8080 }
 ]
}
* Enable the firewall
 
* Activate it
 
* Surf, again, you can still use http://config.privoxy.org to verify the intercepting proxy is working
Category:Software
Category:Proxy Server
Category:Security
Setting up ZFS with native encryption

This is a guide for creating and auto-mounting an encrypted ZFS drive or partition on an existing encrypted alpine linux system, using ZFS's own encryption capabilities. If you want to make a fresh install with the root partition on ZFS, see Root on ZFS with native encryption.
The system will be encrypted when powered off but will not require you to type an extra password at boot, since it uses a key stored on the encrypted root partition. Alternative options are also given, such as prompting for a password at boot rather than storing the key on the root drive. The example in this guide is modeled around creating a ZFS filesystem to be used as a user's home directory, but it can be trivially modified to create a filesystem for other purposes.
= Preparation =
Every command in this guide should be run as root.
 apk update
 apk add zfs zfs-lts # install the utilities
 modprobe zfs # load the kernel modules
 mdev -s # make sure the device nodes are present
== Create an encryption key ==
This section can be skipped if you intend to unlock the drive by typing a password rather than unlocking automatically. You should use a password instead if your root partition is not encrypted. The location "/etc/home.key" can be anything.
 dd if=/dev/random of=/etc/home.key bs=32 count=1
 chmod 600 /etc/home.key
IMPORTANT: Make sure you don't lose this key by overwriting your root filesystem or anything like that. You might want to store a copy of it on an encrypted USB drive, for instance.
= ZFS setup =
== Create the zpool ==
Replace `/dev/sd...` with the name of the disk or partition where you would like to make the zfs filesystem, such as `/dev/nvme0n1` or `/dev/sda1`. If you would like to be prompted for a password at boot rather than using the key as generated above, then replace `-O keylocation=file:///etc/home.key -O keyformat=raw` with `-O keylocation=prompt -O keyformat=passphrase`. The name "homepool" can be anything.
 zpool create -o ashift=12 -O acltype=posixacl -O compression=lz4 \
 -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa \
 -O encryption=aes-256-gcm -O keylocation=file:///etc/home.key -O keyformat=raw \
 -O mountpoint=none homepool /dev/sd...
After completing this, confirm that the pool has been created:
 zpool status
Should return something like:
 pool: homepool
 state: ONLINE
 config:
 
 NAME STATE READ WRITE CKSUM
 homepool ONLINE 0 0 0
 sd... ONLINE 0 0 0
 
 errors: No known data errors
== Create and mount the filesystem ==
 zfs create -o mountpoint=/home/username homepool/username
 chown username:username /home/username # likely unnecessary if not creating a homedir
== Set up the services to auto-mount the new filesystem ==
 rc-update add zfs-import # import existing zpools
 rc-update add zfs-load-key # load the encryption keys
 rc-update add zfs-mount # mount the filesystems
Finally,
 reboot
Category:Filesystems
Setting up Zaptel/Asterisk on Alpine

Asterisk is an open-source voip server. It can be used both with sip-clients as with phones and/or phonesystems.
Note:
 We used Alpine version 1.1.3-beta8
== Installation ==
Booted from CD
Log in as root, no password needed
 $ setup-alpine
Set hostname, network settngs and root-password
 $ apk_add openssh asterisk
Make ssh run at bootup:
 $ rc-update add sshd
Configure asterisk, we copied settings from our previous install, on
Debian Sarge. The only change we had to make to our previous asterisk
config was:
 $ vi modules.conf
under [modules], make sure
 load => “res_musiconhold.so” 
is loaded before other modules
Make asterisk run at bootup:
 $ rc-update add asterisk
== Zaptel ==
We use an isdn card to connect to our phone-center. It uses the zaptel
driver. To load all the needed modules we had to make the following
changes:
 $ vi /etc/modules
Add the following modules:
 zaphfc
 zaptel
 af_packet
 $vi /etc/modules.conf
Add:
 options torisa base=0xd0000
 alias char-major-196 torisa
 alias wctdm wcfxs
 alias wct2xxp wct4xxp
== Wrapping up ==
Commit to floppy
 $ lbu co floppy
Reboot to make sure you made no mistakes, done.
I prefer to reboot staright after installation. If I made a mistake, I rather find out now then in a couple of monts, when I will for sure have forgotton how I set it all up.
== Permissions ==
To run asterisk as user asterisk, we had to add asterisk to the dialout group:
 $ grep asterisk /etc/group
dialout:x:20:root,asterisk
To be able to support sip dial-in clients, we run asterisk as root:
 $ vi /etc/conf.d/asterisk
And set:
 ASTERISK_USER="root:root"
See also issues
== Issues ==
For sip clients to call in we had have to run Asterisk as root, this needs to be fixed. Asterisk on alpine runs as root out of the box.
== Memory-usage ==
 $ free
total used free shared buffers
Mem: 185824 51772 34052 0 184
Swap: 0 0 0
Total: 185824 51772 134052
==Call logging==
To log phonecalls to a csv-file, edit : /etc/asterisk/modules.conf
 $ vi /etc/asterisk/modules.conf
And add load => cdr_csv.so:
;
; Asterisk configuration file
;
; Module Loader configuration file
;
[modules]
autoload=no
load => cdr_csv.so
etc
Now your logs will be in /var/log/asterisk/cdr-csv/Master.csv
For other forms of logging, see [here]
This box is running the following services:
Ssh, asterisk, tinc and openvpn All this would fit in 64mb.
= Resources =
A very nice series of articles called "VoIPowering Your Office with Asterisk: SOHO VoIP" can be found below:
* Intro, How to connect an Asterisk server to legacy phones and phone service, [Part 1]
* Set up a connection to the outside world and set up internal extensions, [Part 2]
* Configure outbound calling, [Part 3]
* Voicemail, [Part 4]
= See also =
* FaxServer using Asterisk
Category:Telephony
Setting up a LLDAP server

= General =
LLDAP is a small LDAP server designed for directory services without the overhead of a full blown OpenLDAP server. LLDAP server is designed for easy management using a simple web gui. It lacks some of the features found in other directory servers, because its specificly designed for easy use.
= Install =
Installing LLDAP is fairly simple and can be done in less then 5 minutes. start by logging in as root:
Then we make sure the system is up to date and install wget:
Then we make the directory for LLDAP to live in and install the software:
= Configure =
To configure LLDAP we have to create a config file, and an rc file to start it automaticly upon boot. First we generate 2 random strings to use in the configuration as jwt_secret and key_seed:
Then we paste the following configuration into and replace the jwt_secret and key_seed with the random generated value's:
Replace domain.tld with your chose domain name.
Next we need to create an openrc file so we can automatically start lldap:
This is not an extensive file, but it gets you running and ensures lldap starts and works correctly.
Now we need to add it to the default runlevel and start the service
= Use =
To use LLDAP we can browse to http://<ip>:17170 and login with the credentials we specified in the config file.
This is a basic configuration. You can now connect other services that support ldap logins to LLDAP.
= Troubleshooting =
* Some troubleshooting information
= Resources =
* https://github.com/lldap/lldap
Category:Server
Setting up a SSH server

= Overview =
This article provides a short overview of SSH on Alpine Linux.
Also see Secure Shell (Wikipedia).
= OpenSSH =
OpenSSH is a popular SSH implementation for remote encrypted login to a machine. OpenSSH defines sshd as the daemon, and ssh as the client program.
The package provides OpenSSH on Alpine Linux.
== Installation ==
Install the package:
Also see Alpine Linux package management.
== Service commands ==
Enable the sshd service so that it starts at boot:
List services to verify sshd is enabled:
Start the sshd service immediately and create configuration files:
Also see Alpine Linux Init System.
== Fine tuning ==
You may wish to change the default configuration. This section describes some of the configuration options as examples, however it is by no means an exhaustive list. See the manual for full details.
The fine-tuning is done by editing . Any line starting with "#" is ignored by sshd.
 UseDNS no # By setting this to no, connection speed can increase.
 PasswordAuthentication no # Do not allow password authentication.
Other configuration options are shown in . The file includes comments that explain many of the options.
== Firewalling and Port Changes ==
By default, sshd will communicate on TCP port 22.<BR>
Sometimes 22/tcp is blocked by a firewall over which you have no control. Changing the Port option to an unused port number in may be useful in this situation.<BR>
 Port 443 # Use whichever port number fits your needs
Restart sshd after making modifications to the configuration file:
= Dropbear =
Dropbear is a lightweight SSH client/server alternative to OpenSSH.
=== server ===
 can be install through the Alpine setup scripts, or manually with:
Start it:
Add it to the default runlevel:
Use the following command to check all available server options:
The config file is located at 
=== client ===
 contains the SSH client and can be installed manually with:
In its simplest form it can be used like this:
 (where x.x.x.x is the IP address of the remote machine).
Use dbclient -h to see all available options.
= See also =
* Two Factor Authentication With OpenSSH
= Further Reading =
OpenSSH (openssh.com)<BR>
OpenSSH (wikipedia.org)
Category:Server
Category:Networking
Category:Security
Setting up a Samba server

= Installation =
Install packages:
= Create a share directory =
This will be the directory that's shared to clients. You can create as many of these as you wish.
= Create smb.conf =
Alpine provides an example configuration file located at /etc/samba/smb.conf. The following is a simple example to get you up and running.
= Create a system user and Samba user =
Create a user on the system. Create a Samba user. Give both users the same password.
= Configure the Samba service =
Run these two commands to start the service on boot and to start the service right now.
Category:Server
Category:Printers
Category:Authentication
Setting up a compile vserver for third party packages

Goal: Create a buildserver that will compile third party packages (ones not in the main aports tree) that can be used for unofficial repositories. One example of use could be used to build packages that provide a set of custom default configurations for a group of packages (making quick roll-out of similar servers easier). This box will not build regular aports, just custom packages.
= Prepare buildserver =
First, follow Setting up a compile vserver.
= Customize buildserver =
First, we're going to use this server as both a buildbox and a mirror, so we need lighttpd installed.
Next, set the buildozer package directory to be the lighttpd root, by editing the following lines in /etc/lighttpd/lighttpd.conf:
var.basedir = "/home/buildozer"
server.document-root = var.basedir + "/packages"
Create a softlink to also share the distfiles directory.
Uploading to rsync.alpinelinux.org isn't going to work from this buildbox, so comment out line 133 in /usr/local/bin/update-repos.
Move the old aports directory, create a new aports directory, initialize it as a git directory, setup it's "upstream" source.
Make a new test package in the main repo and test build.
Edit /home/buildozer/aports/main/testing/APKBUILD, put in some bogus info so that the package will build, then test using the sircbot control that you made in the base document.
Category:Virtualization
Category:Development