Simultaneous audio in HDMI and analog with Pulseaudio

I have connected my computer to the TV via HDMI and wanted to play audio simultaneously in the PC speakers and in the home cinema. You can see this solution in the Arch wiki, I just have added the device description for easier identification.

At the beginning of /etc/pulse/default.pa, add:

load-module module-alsa-sink device="hw:0,0" sink_name=analog_output_stereo channels=2
update-sink-proplist analog_output_stereo device.description="PC Speakers - Stereo"

load-module module-alsa-sink device="hw:0,7" sink_name=hdmi_output_surround channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe
update-sink-proplist hdmi_output_surround device.description="Home theater - 5.1"

load-module module-combine-sink sink_name=analog_hdmi_surround slaves=analog_output_stereo,hdmi_output_surround channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe
update-sink-proplist analog_hdmi_surround device.description="Home theater and PC Speakers - 5.1"

You can get the device id with aplay. “hw:0,7” means the card 0, device 7.

[Read More]

PostgreSQL replication with Slony-I

In recent versions of PostgreSQL there are replication capabilities built-in, but for older versions I’ve been using Slony-I. I’m going to describe how I’ve replicated a database running on PostgreSQL 8.4 with Slony 1.2. For more info, you can read the official documentation.

  • Create a superuser role in both servers for replication:

CREATE ROLE slony WITH SUPERUSER LOGIN PASSWORD 'mipassword';

  • Example values:

CLUSTERNAME=db_cluster MASTERDBNAME=mydb SLAVEDBNAME=mydb MASTERHOST=psql01.example.com SLAVEHOST=psql02.example.com REPLICATIONUSER=slony DBUSER=user export CLUSTERNAME MASTERDBNAME SLAVEDBNAME MASTERHOST SLAVEHOST REPLICATIONUSER DBUSER

[Read More]

DNS timeout while logging in via SSH

In a computer which is in a isolated network, I have experienced a long delay while logging in via SSH. This is because a DNS timeout. It’s possible to disable the DNS lookups of sshd, modifying this setting in /etc/ssh/sshd_config:

UseDNS no
dns  ssh 

Fix failed to prime trust anchor -- DNSKEY rrset is not secure . DNSKEY IN

After installing Unbound in a OpenWrt router, I noticed that afer a reboot, the DNS was not working. I saw many of these errors in the log:

failed to prime trust anchor -- DNSKEY rrset is not secure . DNSKEY IN

I have discovered that the system date was wrong. As this device lacks a hardware clock, when the machine boots, it cannot synchronize the time by NTP because there is no resolver (Unbound doesn’t start because the date validation of the ICANN certificate fails). It’s a chicken or the egg problem.

[Read More]

Configure Unbound DNSSEC resolver in OpenWrt

After realizing that my ISP (ONO) was hijacking the NXDOMAIN DNS responses, I decided to improve the security of the DNS queries for my entire LAN using DNSSEC.

I choosed to replace dnsmasq for unbound in my OpenWrt router. These are the steps I followed.

First I installed the required packages:

# opkg update # opkg install unbound unbound-anchor unbound-control unbound-control-setup unbound-host

As dnsmasq is also the DHCP server, I’m not going to disable it, only change the DNS port to 5353. In /etc/config/dhcp

[Read More]

Montar un volumen VMFS que detecta como un snapshot

Me ha pasado que al añadir un nuevo host ESXi 5.1 no veía un datastore VMFS3 que estaba funcionando correctamente. Después de investigar un rato he visto que no lo monta porque lo detecta como si fuese un snapshot, por lo que hay que forzarle el montaje.

En este KB de VMware se explica el procedimiento que he realizado:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1011387

vmfs 

Habilitar el arranque automático de Hyper-V

En una máquina de pruebas de Windows 2012 me ha sucedido que no podía arrancar máquinas virtuales porque decía que el hypervisor no estaba corriendo. Después de comprobar que las extensiones de virtualización estaban habilitadas en la BIOS, he descubierto que hay que añadir un parámetro en el boot loader de Windows para que arranque automáticamente el hypervisor.

Para ello, usaremos el comando bcdedit.exe como administrador. Si lo ejecutamos sin parámetros, podemos ver la configuración actual, y para añadir la opción de autoarranque:

[Read More]

proxy.pac CGI script

In my OpenWrt box I have two internal networks,one for my LAN and other for the wifi guests. I have configured a proxy server, and to distribute the configuration to the clients, I did a little script to generate a proxy.pac file dependent on the client IP.

I have this in /www/cgi-bin/proxy.pac:

#!/bin/sh
mynetmask="255.255.255.0"
eval $(/bin/ipcalc.sh $REMOTE_ADDR $mynetmask)
if [ "$NETWORK" = "192.168.10.0" ]; then
  proxy=""PROXY 192.168.10.1:3128; DIRECT""
else
  proxy=""PROXY 192.168.11.1:3128; DIRECT""
fi

echo Content-Type: application/x-ns-proxy-autoconfig
echo ""

echo "function FindProxyForURL(url, host)
{
  return $proxy;
}"

Make it executable, you can test it in command line passing the client IP:

[Read More]

Script to grant dial-in access in Active Directory

I have found that is not a trivial task to change the dial-in permission in an Active Directory user or computer because you must update the userParameters attribute at the same time that the msNPAllowDialin.

In the KB252398, Microsoft says to download the Active Directory Service Interface, so you can register adsras.dll, and use the ADSI interface it provides, but the download is no longer available.

I have managed to create a script to allow dial-in: first, I have allowed manually a user to dial-in, and then I pick those permissions and apply them to the rest.

[Read More]