dnsmasq and logrotate on ubuntu 20.04

I had same issues with dnsmasq and logrotate on ubuntu 20.04. Here is my solution:

In /etc/dnsmasq.conf the following entry is required:

log-facility=/var/log/dnsmasq/dnsmasq.log

Create /etc/logrotate.d/dnsmasq with the following content:

/var/log/dnsmasq/dnsmasq.log {
   size 100M
   weekly
   rotate 7
   compress
   missingok
   notifempty
   postrotate
      service dnsmasq restart
   endscript
}

The important thing was the restart of dnsmasq!

, ,

Leave a comment

How to check the expiration date of a ssl certificate?

To check a certificate of an host:

openssl s_client -servername your.domain -connect your.domain:443 2>&- | openssl x509 -enddate -noout | sed 's/^notAfter=//g'

To check a certificate file:

openssl x509 -noout -enddate -in your.crt | sed 's/^notAfter=//g'

 

,

Leave a comment

Apache failed on system boot, when binding to an additional IP

Starting point:

My system (Ubuntu 18.04.1) is a VPS running on KVM. The network with some additional IPs is configured with Netplan.

 

Problem:

The Apache server is running on an additional IP. If the VPS reboots, the apache didn’t start because, it couldn’t be bind on an aditional IP. A log entry like the following can be found:
apachectl[631]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address [xxxxxxxx]:80

But if you restart Apache after the reboot, it runs as expected!
Strange, isn’t it?

 

Solution:

Ok, I couldn’t find the exact reason of this reason. But I think, there is a strange timing issue on reboot. The network isn’t completely up before Apache is starting.

To solve the problem, just edited the section ‘Unit’ in the file /lib/systemd/system/apache2.service and replace

After=network.target remote-fs.target nss-lookup.target

with

Requires=network-online.target
After=network-online.target remote-fs.target nss-lookup.target

That’s it!

More information about the network-target can be found her: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

, ,

Leave a comment

JII (Java Image Info) Version 1.1.0

Version 1.1.0 of JII has been released.

It provides a clean interface to a collection of Java libraries and source code to read basic properties of images.

Changes:

  • issue #5 Include Apache-Commons-Imaging
  • issue #8 Update platform to Java 8
  • updated slf4j to 1.7.25
  • changed to maven 3.5

, ,

Leave a comment

How to initialize a static final object

Sometimes I need to intitialize a complex static final object, but I don’t like static blocks for initialization. IMHO it isn’t nice to read!
An alternative way is using an static method:

private static final YourObject defaultYourObject = initYourObject();

private static YourObject initYourObject() {
	try {
		return new YourObject(param1, param2);
	} catch (Exception e) {
		// should never happened
		throw new Error("Could not initialize YourObject", e);
	}
}

And of course, the error-handling is an own special topic in this case!

,

Leave a comment