Category Archives: Linux

amavisd-new: disable e-mail filtering per destination domain

Testing SPAM filtering from shell

echo "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X" | mail -s Spam_test danman@example.com

Disable filtering for example.com

add following lines to /etc/amavis/conf.d/50-user (don’t forget the dot before domain, it has to be there):

@bypass_spam_checks_maps = (
[".example.com"],
);

@spam_lovers_maps = (
[".example.com"],
);

Using socat for multicast receiving and proxying

socat is a very handy networking tool. Here are some examples for multicast manipulation

Receive multicast data to stdout or file

If you save common mpeg-ts IPTV multicast this way, you can play it with any decent player, like vlc or mplayer.

SRC=239.1.2.3;SRCP=1234;IF=eth0

socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr -

socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr - > stream.ts

Create high-available multicast proxy

socat relays packets from 239.1.1.1:1234 to 239.2.1.1:1234 with multicast ttl=8.
If no packet arrives in 3 seconds (-T 3), socat exits and script runs another socat which joins another multicast 239.1.1.2:1234 and continues with relaying. You can add as many sources as you want, they will be used in a round-robin fashion. If you want to switch to next source, just kill currently running socat.

DST=239.2.1.1:1234
while true
do
 SRC=239.1.1.1;SRCP=1234;IF=eth0
 socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr UDP4-SENDTO:$DST,ip-multicast-ttl=8
 SRC=239.1.1.2;SRCP=1234;IF=eth0
 socat -T 3 UDP4-RECV:$SRCP,bind=$SRC,ip-add-membership=$SRC:$IF,reuseaddr UDP4-SENDTO:$DST,ip-multicast-ttl=8
 ...
done

Fixing distorted audio with Intel HDA on Ubuntu

edit /etc/pulse/default.pa
before:

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

after:

### Automatically load driver modules depending on the hardware available
#.ifexists module-udev-detect.so
#load-module module-udev-detect tsched=0
#.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
#.endif

Restart pulseaudio or the whole system.

usbip-utils 2.0 on Ubuntu

Ubuntu 15.10 contains usbip package too old to work with usbip v2.0 server (e.g. latest raspbian on RasPI) so you need to compile usbip tool from kernel sources.

UPDATE 19. 04. 2016:

You don’t need to go through compiling from source. You may just install package linux-tools-generic:

$ apt-get install linux-tools-generic

This will install precompiled usbip tools into /usr/lib/linux-tools/`uname -r`/:

$ /usr/lib/linux-tools/4.2.0-35-generic/usbip version
usbip (usbip-utils 2.0)

Non-working usbip installed from usbip package

$ sudo usbip -l 192.168.1.83
- 192.168.1.83
usbip err: usbip_network.c: 119 (usbip_recv_op_common) recv op_common, -1
usbip err: vhci_attach.c: 202 (query_exported_devices) recv op_common
usbip err: vhci_attach.c: 417 (show_exported_devices) query
$ usbip -v

** (process:30826): WARNING **: running non-root?
usbip 0.1.7 ($Id: vhci_attach.c 42 2007-09-07 12:07:51Z hirofuchi $)

Continue reading usbip-utils 2.0 on Ubuntu

DRBD quick cheat sheet

Creating volume

/etc/drbd.d/raid10.res
resource raid10 {

  protocol B;

  on hostname1 {
    device    /dev/drbd1;
    disk      /dev/raid10_vg/drbd;
    address   [localIP]:7789;
    meta-disk internal;
  }
  on hostname2 {
    device    /dev/drbd1;
    disk      /dev/raid10-vg/drbd;
    address   [localIP]:7789;
    meta-disk internal;
  }
}

Both nodes:

drbdadm create-md [resource]
drbdadm up [resource]

Primary node:

drbdadm primary --force [resource]

cat /proc/drbd
version: 8.4.3 (api:1/proto:86-101)
srcversion: 6551AD2C98F533733BE558C

 1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent B r-----
    ns:7552704 nr:0 dw:0 dr:7552936 al:0 bm:460 lo:47 pe:12 ua:47 ap:0 ep:1 wo:f oos:97303516
    [>...................] sync'ed:  7.3% (95020/102396)Mfinish: 0:15:29 speed: 104,672 (96,804) K/sec

Resize

Both nodes:

lvresize /dev/raid10-vg/drbd -L+100G
  Extending logical volume drbd to 200.00 GiB
  Logical volume drbd successfully resized

resize with resync:

drbdadm resize [resource]

resize without resync (added clean space):

drbdadm -- --assume-clean resize [resource]

Resize filesystem:

resize2fs /dev/drbd1

Fix splitbrain

slave:

drbdadm secondary all
drbdadm connect --discard-my-data all

master:

drbdadm connect all