Nov 152017

Sometime you just wanna check how many packets and bytes are transferred via network interface. For my Linode NTP server I solved that need using the following script:



LINE_COUNT=`tput lines`

while true
    if (( LINE % (LINE_COUNT-1) == 0 ))
        echo "INTERFACE   RX bytes packets     TX bytes packets"
    LINE=$(( LINE+1 ))

    sleep 1
    RX2_BYTES=`cat /sys/class/net/$INTERFACE/statistics/rx_bytes`
    TX2_BYTES=`cat /sys/class/net/$INTERFACE/statistics/tx_bytes`
    RX2_PACKETS=`cat /sys/class/net/$INTERFACE/statistics/rx_packets`
    TX2_PACKETS=`cat /sys/class/net/$INTERFACE/statistics/tx_packets`

    if [[ "$RX1_BYTES" != "" ]]
        RX_BYTES=$(( RX2_BYTES - RX1_BYTES ))
        TX_BYTES=$(( TX2_BYTES - TX1_BYTES ))

        printf "%-7s  %'11d %'7d  %'11d %'7d\n" $INTERFACE $RX_BYTES $RX_PACKETS $TX_BYTES $TX_PACKETS
Nov 102017

On my web server I wanted to use a separate directory for my logs. All I needed was to configure ErrorLog and CustomLog directives and that’s it. Well, I did that only to have following error: Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

And no, there weren’t any details worth mentioning in systemctl status httpd.service nor journalctl -xe.

To cut long story short, after a bit of investigation I narrowed the problem to SELinux that is enabled by default on CentOS. Armed with that knowledge, I simply transferred security from default log directory to my desired location:

# chcon -R --reference=/etc/httpd/logs/ /var/www/logs/

With that simple adjustment, my httpd daemon started and my logs lived happily ever after.

Nov 062017

This version is all about enabling you to quickly see which passwords suck. For this purpose a centralized weak password search has been implemented. Yes, you could see which password is weak even before but it required opening every single account – and that can take a while. This way you get the same information but after a single click.

Additionally, there is an option to check all accounts for breaches at Have I been pwned? site. While password for these accounts might not be compromised themselves, risk is quite increased and changing them is not necessarily the worst idea – let’s not even think about the sites using trivial hashes (like MD5) or no hashing at all. Search is smart enough to verify when exactly you changed your password last time to avoid false positives.

Moreover, if you go into Options, you can enable more thorough search. If selected, you can verify all your passwords (hashed and sent over TLS 1.2) against all exposed passwords. This is not enabled by default (even hidden a bit) because it requires quite a big leap of faith toward Troy and his website. I personally do trust him, but your mileage might vary.

As always, new version is available from Bimil’s page or you can update it through application.

Nov 052017

One of the features I added to Bimil was NTP client support for time-based two-factor authentication. For this I needed NTP server so I turned to pool and requested vendor zone. Once zone got approved I suddenly had infinite* amount of NTP servers at my disposal.

So, when I decided to give linode’s $5 virtual server a try, I didn’t want just to create dummy machine. I also wanted to do something for community. As NTP pool service is one of invisible pillars of Internet-connected devices and I was really happy such service was provided for free to myself, it was easy to decide. I am going to build NTP server.

Creating account on linode was a breeze as it was creating the machine. It was literally, click-next, click-next process. Once I finally logged on to it, the first action was to update system to the latest packages. Surprisingly, on Linode there was literally nothing to do – all was already up to date. Awesome!

# yum update -y

No packages marked for update

By default, Linode’s CentOS installation has firewall disabled. As this server will be open to public, enabling firewall is not the worst idea ever:

# systemctl start firewalld

# systemctl enable firewalld

# firewall-cmd --state

And, while dealing with firewall, you might as well allow NTP through and check if configuration is correct:

# firewall-cmd --permanent --add-service ntp

# firewall-cmd --reload

# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  services: ssh dhcpv6-client ntp
  masquerade: no
  rich rules:

With firewall configuration completed, you can finally install NTP:

# yum install -y ntp

And this brings you to the most involved part of the process. You need to go over available stratum 1 time servers and select between four and seven of them for your devious synchronization purposes. Which servers should you select? As long as they are reasonably close (in the terms of network distance) you will be fine.

Using your favorite editor, you need to adjust /etc/ntp.conf file. Following recommendations always worked for me but with a slight adjustment in the form of a separate log file and forcing IPv4 resolving for servers. Quite a few IPv6 capable servers only serve clients over IPv6 and don’t like other servers via the same. I personally use the following configuration (don’t forget to adjust servers names):

driftfile /var/lib/ntp/drift

restrict -4 default kod limited nomodify notrap nopeer noquery
restrict -6 default kod limited nomodify notrap nopeer noquery

restrict -4
restrict -6 ::1

server -4 iburst
server -4 iburst
server -4 iburst
server -4 iburst
server -4 iburst
server -4 iburst
server -4 iburst

logfile /var/log/ntp.log

With configuration ready, it is the moment of truth – start the NTP daemon and configure its automatic startup upon boot. Don’t forget to disable chrony too:

# systemctl start ntpd
# systemctl enable ntpd
# systemctl disable chronyd

With all up, wait for couple minutes while checking state with ntpstat or ntpq. Forgetting it for hour or two will save you lot of angst :) I consider sync good enough whenever pooling interval goes to 1024s.

# watch "ntpq -np ; echo ; ntpstat"

     remote           refid      st t when poll reach   delay   offset  jitter                                                            ==============================================================================
*    .CDMA.           1 u   41  512  377    2.022    6.680   6.798
+ .CDMA.           1 u   77 1024  377    2.127    5.663   6.180
+    .GPS.            1 u  257  512  377    4.908    2.753   5.031
+     .GPS.            1 u   40  512  377    5.232    5.278   6.052
+   .GPS.            1 u  532  512  377    9.978   -0.637   3.795
+   .NIST.           1 u  362 1024  377   35.226    5.489   7.610
+   .NIST.           1 u  430  512  377   35.148    5.353   7.607

synchronised to NTP server ( at stratum 2
   time correct to within 19 ms
   polling server every 1024 s

It will take some time for other servers to “discipline” yours so do be patient. If servers are showing INIT refid for a while, this might indicate a permanent issue (e.g. server might be down) or just something temporary (e.g. server might be overloaded). If server is not reachable for a while, toss it out and select another one from stratum 1 list (followed by systemctl restart ntpd).

I personally gave server an hour or two to get into the shape before proceeding with the final step – adding it to pool. This can be done at management pages and it is as easy as simply adding server using either host name or IP address.

After monitoring server for some time and assuming its time is stable, your score will raise and you get to be the part of the collective NTP pool.

* some restrictions apply