Category Archives: Miscellaneous

Adding IPv6 to existing server (DigitalOcean)

While creating the server I didn’t add any IPv6 address. Later from the Control Panel I enabled IPv6 but the address didn’t get attached to ETH0.

Needed to do:

  • Edit the /etc/network/interfaces.d/50-cloud-init.cfg file
  • Add
# control-alias eth0
iface eth0 inet6 static
address 2400:xxxx:xxxx:xxxx:xxxx:xxxx:0000:6001/64
gateway 2400:xxxx:xxxx:xx::x
autoconf 0
dns-nameservers 2001:xxxx:xxxx::xxxx 2001:xxxx:xxxx::xxxx
  • The gateway and nameservers are important.
  • The NameServers are that of the server provider

Check DNS with DIG command

General Query

dig @ns2.dnsserver.com TXT domain.com +short   

With the +short it will show only the value of the queried field(s). Without +short  it will show the full result

 

Querying CNAME records 

dig @ns2.dnsserver.com CNAME 4xugchxxxxxxxxxxxxxxxxxx3eread3uc._domainkey.domain.com +short

This will return the value of that particular CNAME field.

 

Querying particular entry

dig @ns2.dnsserver.com TXT domain.com +short
dig @ns2.dnsserver.com NS domain.com +short

 

Bind server not responding to external queries

Recently I ran into a problem where one DNS server setup using Bind9 was not responding to external queries.

systemctl status bind9 –no-pager –full  shows “Denied

Common issues (listed below) that can cause the problem were not there.

  1. Bind9 was running properly
  2. The server was listening on both IPv4 and IPv6
  3. Port 53 was open
  4. The DNS server or port 53 could be connected using Telnet

 

The issue was with “recursive query” permissions. To allow external queries needed to add the following option

options {
   ...
   ...
     allow-recursion { any; };
   ...
   ...
}

The options are commonly stored in /etc/bind/named.conf.options for Bind9 servers.

Manually adding a DNS Zone to Bind9 server

  • Create a Zone file in /etc/bind/  Example – /etc/bind/pri.domain.com
  • Add the entries . Example below
    $TTL 3600
    @ IN SOA ns2.dnserver.net. manish.gmail.com. (
    2019051606 ; serial, todays date + todays serial #
    7200 ; refresh, seconds
    540 ; retry, seconds
    604800 ; expire, seconds
    3600 ) ; minimum, seconds
    ;
    
    domain.com. 3600 A xxx.xxx.xxx.xxx
    mail 3600 A xxx.xxx.xxx.xxx
    www 3600 A xxx.xxx.xxx.xxx
    domain.com. 3600 AAAA xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
    mail 3600 AAAA xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
    www 3600 AAAA xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
    domain.com. 3600 MX 10 mail.domain.net.
    domain.com. 3600 NS ns1.dnserver.net.
    domain.com. 3600 NS ns2.dnserver.net.
    domain.com. 3600 TXT "v=spf1 mx a ~all"
    default._domainkey.domain.com. 3600 TXT "v=DKIM1; t=s; p=......NBgkqhki................................................"
    _dmarc.domain.com. 3600 TXT "v=DMARC1; p=quarantine"
  • Add the zone to /etc/bind/named.conf.local . Example below

    zone "domain.com" {
        type master;
        allow-transfer {none;};
        file "/etc/bind/pri.domain.com";
    };
  • service bind9 restart for Ubuntu and likes. For CentOS and likes service named restart

Legends in Morris Chart

With help from this article https://github.com/morrisjs/morris.js/issues/346

This is about adding Legends to Morris charts. Though Morris chart shows legend on hovering on the graphs, but I wanted to show a legend permanently on one corner of the chart area.

Below are the codes. It is mostly plug and play code

The div in which the chart will be displayed

<div class="box-body chart-responsive">
    <div id="visitor_legend" class="bar-chart-legend"></div> <!-- the legend area -->
    <div class="chart" id="bar-chart" style="height: 300px;"></div> <!-- the chart area -->
</div>

The CSS

<style>
.bar-chart-legend {
	display: inline-block;
	right: 25px;
	position: absolute;
	top: 8px;
	font-size: 10px;
}

.bar-chart-legend .legend-item {
	display: block;
}

.bar-chart-legend .legend-color {
	width: 12px;
	height: 12px;
	margin: 3px 5px;
	display: inline-block;
}
</style>

The JS code

// Legend for Bar chart
bar.options.labels.forEach(function(label, i) {
	var legendItem = $('<span class="legend-item"></span>').text( label).prepend('<span class="legend-color">&nbsp;</span>');
	legendItem.find('span').css('backgroundColor', bar.options.barColors[i]);
	$('#visitor_legend').append(legendItem) // ID pf the legend div declared above
});

Morris charts documentation https://morrisjs.github.io/morris.js/lines.html

Amazon AWS SDK Passing Credentials

As per the the sample codes the AWS API access key and secret is to be stored in the a file called credentials under a folder named .aws 

The location of that .aws folder can be set in the code through this config statement

putenv('HOME=/path/that/you/want/to/set');

But I am more comfortable in passing the credentials through my code so that I can make things more flexible and need not worry about write permissions.

To pass the credentials through code the first thing needed is to remove or not to use the config statement

'profile' => 'default'

The credentials can then be passed like below

$xxxxxxClient = new xxxxxxClient([
   'version' => "<CLIENT VERSION>", /* can be set to 'latest' */
   'region' => "<REGION>",
   'credentials' => array(
     'key' => "<API USER>",
     'secret' => "<API PASS>"
    )
]);

 

RTMP and audio broadcasting — DRAFT

FFMPEG Commands

  1. https://gist.github.com/protrolium/e0dbd4bb0f1a396fcb55
  2. https://ffmpeg.org/ffmpeg-formats.html#toc-mov_002c-mp4_002c-ismv
  3. http://www.mediaentertainmentinfo.com/2015/06/5-technical-series-handy-ffmpeg-commands-to-get-your-video-processing-done.html/
  4. https://github.com/arut/nginx-rtmp-module/wiki/Examples
  5. https://github.com/arut/nginx-rtmp-module/wiki/Directives#exec_options

 

FFMPEG RTSP Commands

  1. https://trac.ffmpeg.org/wiki/StreamingGuide
  2. https://stackoverflow.com/questions/16658873/how-to-minimize-the-delay-in-a-live-streaming-with-ffmpeg

 

FFMPEG Latency

  1. https://www.wowza.com/blog/streaming-protocols-latency
  2. https://www.wowza.com/docs/how-to-set-up-low-latency-applications-in-wowza-streaming-engine-for-rtmp-streaming

 

Installing Amazon SDK on ISPConfig systems

  1. First install Composer and PHP for the jailed user. This article has the steps
  2. composer require aws/aws-sdk-php  — as the jailed user
  3. There might be an error –
    fopen(/usr/share/php/Composer/Autoload/../../../doc/composer/copyright): failed to open stream: No such file or directory
  4. You can copy the file using the root login
    1. mkdir -p /var/www/clients/client1/web1/usr/share/doc/composer
    2. cp /usr/share/doc/composer/copyright  /var/www/clients/client1/web1/usr/share/doc/composer/
    3. chown web1:client1 /var/www/clients/client1/web1/usr/share/doc/composer/copyright