Friday, December 23, 2016

Log TCP Connections to WAN in OpenWrt

I have a router running OpenWrt 15.05. I would like to log all the TCP connections. To achieve this, I just need to add a line in the firewall custom rule like:
iptables -A forwarding_lan_rule -p tcp -m state --state NEW -m limit --limit 30/sec -j LOG --log-prefix "NEW Conn "

Then, login the router as root, and restart the firewall with the following command:
/etc/init.d/firewall restart

The following shows how the System Log looks like after enable the custom rule:

Tuesday, December 20, 2016

Audio Volume Normalizer

When I switched from MS Windows to Linux as my primary desktop, I found that I needed to adjust the audio volume frequently. For example, different YouTube videos have different levels of audio volume, but I didn't notice this in MS Windows. With some searching on the web, I found that MS Windows did some tricks behind the scene, called "Loudness Equalization".

Do we have similar ticks in Linux? After some digging on the web, I found the solution. In the following, I will show you how I do that in my XUbuntu 16.04 LTS box:
  1. First of all, need to install "swh-plugins". Actually, we only need the Compressor Plugin.
    sudo apt-get install swh-plugins
    I am not an expert on Sound Engineering, but I found a page which explained the parameters well.
  2. Next, we need to config PulseAudio to load the plugin and set the "default sink". To do this, create a file at $HOME/.config/pulse/default.pa with below contents:
    #include system-wise config
    .include /etc/pulse/default.pa
    
    #compressor -- for normalize audio volume
    .ifexists module-ladspa-sink.so
    .nofail
    load-module module-ladspa-sink sink_name=ladspa_out plugin=sc1_1425.so label=sc1 control=3,401,-30,4,5,12
    set-default-sink ladspa_out
    .fail
    .endif
    
  3. Then, you just need to kill PulseAudio daemon to restart with the new config:
    pulseaudio -k
  4. If everything goes well, you can run any application with audio playback (e.g. Mpalyer). To confirm the setup, you can run "pavucontrol" command to bring up the "Volume Control" GUI. In the "Volume Control" GUI you should see "SC1" plugin is being used, like:
References:

Monday, December 19, 2016

Install Remix OS on VirtualBox

Remix OS is an Android OS which can run on PC. Because I want to run some Android Apps in my Ubuntu desktop, I tried to install Remix OS in VirtualBox VM. Here are the steps:
  1. Download the Remix OS (64-bit version) at http://www.jide.com/remixos-for-pc#downloadNow.
  2. Unzip release_Remix_OS_for_PC_Android_M_64bit_B2016112101.zip. We need the file Remix_OS_for_PC_Android_M_64bit_B2016112101.iso, which is a CD image of Remix OS.
  3. Create a new Virtual Machine in VirtualBox like below. Please ensure you select the "Remix_OS_for_PC_Android_M_64bit_B2016112101.iso" disk image for the CD driver of the VM. For Audio, please select "ASLA Audio Driver" and "ICH AC97".
  4. Start the VM, and you will see the GRUB menu. Press "Tab" immediately to edit the boot command.

  5. Append "INSTALL=1" in the boot command and then press "Enter"

  6. Follow the steps to create a new partition:





  7. Choose the newly created partition to install Remix OS
  8. Select "ext4" as the format of the new partition

  9. Choose "Yes" to install GRUB.
  10. Choose "Yes" to install "/system" dir as read-write.
  11. After a few minutes, you will see the installation completed screen. Now, you have to eject the CD of the VM (Device --> Optical Drives --> remove disk from virtual drive). Then, select "Reboot".
  12. If everything goes smooth, you should see the GRUB screen.
  13. After a few minutes you will see the welcome screen. Please note that you need to disable the mouse integration (Input --> Mouse Integration) of the VM, otherwise, you can't use mouse in Remix OS.
  14. Just follow the steps on the screen to initialize the Remix OS. Then, you should see "home" screen. To enable Google Play, you need to double click the "Play activator" and follow the steps on the screen.

Software versions:
XUbuntu 16.04.1 LTS
Linux Kernel 4.4.0-53-generic (64-bit)
Virtual Box 5.0.24_Ubuntu r108355

Reference:
https://gist.github.com/cs8425/7315d86a273e57a988245345df68a4f9