Get IP address Space By AS(Autonomous System) Number

Sometimes you need to get all possible address blocks of a network but most of the time there is no easy way to figure it out, looking at you Facebook and Google, but fear not sysadmin we have one handy trick up in our sleeve, by using whois with the AS number of the company we can build this kind of list.
 
We’ll use Facebook(AS32934) as an example, but it should work for any Autonomous System.


whois -h whois.radb.net -- "-i origin AS32934" | grep ^route | tr -s " " | cut -d " " -f2-

Continue reading “Get IP address Space By AS(Autonomous System) Number”

Centos 7 with IPV6 at Server4You

As of 2019-10-01, the hosting company server4you.com doesn’t support IPv6, but if you want to test IPv6 or support your IPv6 capable clients there are still a few tricks you can try.
A good way is to use a broker to create a 6in4 tunnel with your IPv4 to the IPv6 enabled internet.

***** Disclaimer *****
 
This guide DOES NOT WORK if you are using their offerings of the vServer family because it’s powered by OpenVZ, but it will work perfectly with the VDS family powered by KVM or with their dedicated servers.
This is NOT a “true” IPv6 solution as you will use a tunnel broker to make a 6in4 tunnel, but it gets the job done for most workloads.
 
***** End Of Disclaimer *****
 
Continue reading “Centos 7 with IPV6 at Server4You”

Zombasite error while loading shared libraries: libpng12.so.0

If you are trying to run Zombasite GoG Version and the game is not starting properly what you can do to try and debug the issue is to run in in a terminal and see the output.


~/GOG\ Games/Zombasite/start.sh

 
If you get de following output:


Running Zombasite
./Zombasite: error while loading shared libraries: libpng12.so.0:
 cannot open shared object file: No such file or directory


 
This output means you are missing at least libpng12.
Continue reading “Zombasite error while loading shared libraries: libpng12.so.0”

Install proxmox 6.0 on top of Debian Buster

This is mostly a copy&paste of the article about installing Proxmox 5.X on top of Debian Stretch, but with the links and repositories updated to the new Debian Buster and Proxmox 6.X

The default proxmox installation ISO is notably minimalist, and one way to be able to do simple customization and have a little bit more flexibility to for example choose the partition layout or use an encrypted LVM is to first make a basic Debian installation and then upgrade it to a full blown Proxmox Installation.

This process is simple, fast and is described in detail at the official proxmox wiki here

But here is the tl;dr version with a few extras and useful modifications from the original article:

Start by making a minimal installation of Debian 10,ie. at the software selection screen check only “SSH server” and “standard system utilities”.
After installation boot to your new Debian machine and be sure that you can resolve the host-name of your machine, the command bellow must return an IP address that is not ‘127.0.0.1’.
This step is important because Proxmox expect to have a “real”( non localhost) IP or else the installation of the package ‘proxmox-ve’ will fail during post-install.
Continue reading “Install proxmox 6.0 on top of Debian Buster”

RIP Sound Card Audio in Linux

Sometimes you need a quick and dirty way of ripping the audio of your sound card, in Linux you can easily do it with the following script:


#!/bin/bash
set -x
WAV="$1"
if [ -z "$WAV" ]; then
    echo "Usage: $0 OUTPUT.WAV" >&2
    exit 1
fi
rm -f "$WAV"

# Get sink monitor:
MONITOR=$(pactl list | egrep -A2 '^(\*\*\* )?Source #' | \
    grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1)
echo "set-source-mute ${MONITOR} false" | pacmd >/dev/null

# Record it raw, and convert to a wav
echo "Recording to $WAV ..."
echo "Close this window to stop"
parec -d "$MONITOR" | sox -t raw -b 16 -e signed -c 2 -r 44100 - "$WAV"

 
Store it somewhere in your PATH, and when you need to record the audio just use it as:


./soundRipper.sh output.wav

 
If you don’t want to store wave files you can convert it as shown HERE

Sources:

https://outflux.net/blog/archives/2009/04/19/recording-from-pulseaudio/
https://www.pantz.org/software/alsa/recording_sound_from_your_web_browser_using_linux.html

Reload HAProxy Without connection loss

Bellow is a quick and dirty script to reload haproxy without dropping connections, just fill the correct values at lines 2,3,4 and 5 and you a probably good2go
 
The script is really simple, after you plug the values for the variables the execution can be sumarized in this steps:
1) Create the PID directory in case it doesn’t exists
2) Checks to see if it found a valid configuration file
3a) if the configuration is valid look for another haproxy running and send it a signal to stop, while starting a new haproxy
3b) abort the restart and print the errors found on the config file
 

#!/bin/bash
CFG_FILE="/etc/haproxy/haproxy.cfg"
HAPROXYBIN=$(which haproxy)
PIDDIR="/var/run/haproxy/"
PIDFILE=${PIDDIR}"haproxy.pid"

[ ! -d ${PIDDIR} ] && mkdir -p ${PIDDIR}


# Check if the configuration is valid
${HAPROXYBIN} -c -f ${CFG_FILE} | tail -1 | grep "Configuration file is valid" -q
VALID=$?
if [[ ${VALID} == 0 ]];then
    echo "Found a Valid Configuration file, reloading HAProxy"
    ${HAPROXYBIN} -f ${CFG_FILE} -p ${PIDFILE} -sf $(cat ${PIDFILE})
else
    echo "Invalid Configuration file"
    ${HAPROXYBIN} -c -f ${CFG_FILE}
fi

Convert wav files to mp3

When you want to convert a wave file to MP3, one of the simplest ways you’ll find is by using ffmpeg.

If you use Debian, you can install it with:

apt install ffmpeg

 
If you use Centos you can install it following this steps:

sudo rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
wget http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum localinstall nux-dextop-release-0-5.el7.nux.noarch.rpm -y 
yum update
yum install ffmpeg -y

 
After that, you just need to specify the files input and output names

ffmpeg -i input.wav -acodec mp3 -ab 256k output.mp3

 

Sources:

https://lonewolfonline.net/convert-wav-mp3-linux/
https://linuxadmin.io/install-ffmpeg-on-centos-7/

Apache+php-fpm the right way

The simplest, and probably the correct, way to configure php-fpm with apache in Centos 6/7 is by using SetHandler and ProxySet directives.

The snippet bellow show a simple Virtual Host example, just change lines 2 3 and 6 and you are good to go.


<VirtualHost *:80>
    ServerAdmin [email protected]
    Servername example.com
    Options +Indexes
    DirectoryIndex index.php                                                                                                                    
    DocumentRoot /var/www/html
    # Register php-fpm as the handler for (.*).php files.
    <FilesMatch \.php$>
         SetHandler "proxy:fcgi://localhost:9000"
    </FilesMatch>
    # Configure the proxy
    <Proxy fcgi://localhost:9000>
        ProxySet connectiontimeout=5 timeout=240
    </Proxy>

    # If the php file doesn't exist, disable the proxy handler
    # so we can gracefully fail.
    RewriteCond %{REQUEST_FILENAME} \.php$
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteRule (.*) - [H=text/html]
</VirtualHost>

 
Continue reading “Apache+php-fpm the right way”

Install proxmox 5.0 on top of Debian Stretch

The default proxmox installation ISO is notably minimalist, and one way to be able to do simple customization and have a little bit more flexibility to for example choose the partition layout or use an encrypted LVM is to first make a basic Debian installation and then upgrade it to a full blown Proxmox Installation.

This process is simple, fast and is described in detail at the official proxmox wiki here

But here is the tl;dr version with a few extras and useful modifications from the original article:

Start by making a minimal installation of Debian 9,ie. at the software selection screen check only “SSH server” and “standard system utilities”.
After installation boot to your new Debian machine and be sure that you can resolve the host-name of your machine, the command bellow must return an IP address that is not ‘127.0.0.1’.
This step is important because Proxmox expect to have a “real”( non localhost) IP or else the installation of the package ‘proxmox-ve’ will fail during post-install.
Continue reading “Install proxmox 5.0 on top of Debian Stretch”