Category Archives: debian, linux, computing

Enable Port Forwarding in Windows 7

When working from home, I need to access the company network using a VPN software which works on Windows only.  However, all my tools are in Linux, thus working in Windows (dual-boot) or in a Windows virtual machine is very tedious and inefficient.

The solution is to create a Windows virtual machine.  Use it to run the VPN software.  Then, my linux OS will connect to the virtual machine and go into the office network via the VPN connection created by the virtual machine.  This is how to do it:

  1. Create a virtual machine with Windows 7 (I’m using Virtual-box).
  2. Create two network adapters for the virtual machine.  The first one uses NAT.  The second one uses Host-only Adapter.  To configure a Host-only Adapter, you will have to create a Host-only Network in the virtual-box (File > Preferences > Network > Host-only Network).
  3. Start up Windows 7 virtual machine.  Make sure VPN is working fine (can connect to the office network from within the Windows 7 virtual machine).
  4. Make sure the second adapter can be reached from the host Linux OS.  You can simply ping the IP address of the second adapter from the host Linux OS.  You will have to disabled the firewall in the Windows 7 virtual machine.

Now is the port forwarding.  Click the Windows start button and type cmd.  Right-click on the search result and choose Run as administrator.  In the command prompt, type the following command:

netsh interface portproxy add v4tov4 listenaddress=x.x.x.x listenport=xx connectaddress=x.x.x.x connectport=xx

My Windows 7 virtual machine has its 2nd network adapter configured with the IP address  I would like to connect to my office server with IP address  The office server is listening at port 22 (SSH).  My final command becomes:
netsh interface portproxy add v4tov4 listenaddress= listenport=22 connectaddress= connectport=22

The listenport=22 can be set to any other number as long as you specify it when connecting from your Linux OS to the Windows virtual machine like the following:

ssh -oPort=<listenport> user@

The effect is like running the following command

ssh -oPort=<connectport> user@

from the Windows 7 virtual machine.

To show all port forwarding configurations:

netsh interface portproxy show all

To clear all port forwarding settings:

netsh interface portproxy reset

If the forwarding does not work, you may want to clear all settings and re-add them.

More info here:


Setup A Wifi Router using a Laptop Running Windows 7

In work, I need to connect to LAN using Windows OS (running some CISCO NAC software).  However, all developers are using Linux laptops.  Running virtual machines in Linux with Windows 7 OS, failed to connect to the LAN with the CISCO NAC software.  So I tried to set up a Windows 7 laptop which can connect to the LAN (with this CISCO NAC software), and turn the laptop wifi into hosted mode, so that all Linux laptop can connect to it and use the LAN interface to access the network.  Initially, I set up the ad-hoc network, but no machines (linux and windows) can connect to it.  Android cannot even see it.  Then I read about the the windows miniport setup, which is able to turn the laptop wifi into an access point with hosted mode instead of just an ad-hoc network.  This is great for it should work with all laptops as well as android phones.  This is how to do it:

Step 1: Press start and type cmd and right click on it click on “Run as Administrator”
Step 2: Type netsh wlan stop hostednetwork and press enter.
Step 3: Type netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORD keyUsage=persistent and press enter.
Step 4: Type netsh wlan start hostednetwork and press enter.

That’s it!  You can now scan the network with laptop or android phones and connect to it.  To share the network, modify the properties of the LAN interface to allow internet sharing through the newly created miniport adapter.

Details explanation can be found here:

In one of the setup, the network is created, devices are able to connect to the network but IP addresses cannot be obtained (stuck at obtaining IP addresses…).  To fix it, modify the miniport adapter properties by removing all ticks except the TCP/IPv4.  Then, repeat step 1 to step 4.

More posts here: and here:

Sending Emails from Solaris to External Email Addresses

There are many cronjobs running on the servers I maintained.  Each cronjob creates output which needs to be sent to the external email addresses.  However, none of the cronjob mails were received by the external email accounts.  I guess the servers were not setup correctly.  I run the mail program from the terminal and got a bounced email with the following content:

The original message was received at Fri, 20 May 2016 12:02:03 +0800 (MYT)
from localhost []

   ----- The following addresses had permanent fatal errors -----

   ----- Transcript of session follows -----
550 5.1.2 <>... Host unknown (Name server: host not found)

The configured STMP server is but this host name is not valid.  I’m not sure how to modify the SMTP server configured, but I do know the IP address of the SMTP server.  So, I add the following line to the /etc/hosts file:

Then, all emails can now be sent to external email accounts successfully.

Debian Jessie: Disable NVIDIA discrete graphic card in a NVIDIA Optimus laptop

Disabling NVIDIA discrete graphic card on a laptop running Debian Jessie is the same (in concept) compare to Debian Wheezy, however, the steps are a bit different.

1. First of all, install the bbswitch kernel module.

 # aptitude install bbswitch-dkms

2. Load the module.

 # modprobe bbswitch

3. Check the status of the NVIDIA graphic card (running or not).

 # cat /proc/acpi/bbswitch
0000:01:00.0 ON  <-- The card is running

4. Disable the card.

 # tee /proc/acpi/bbswitch <<<OFF

5. Check the status of the card again.

 # cat /proc/acpi/bbswitch
0000:01:00.0 OFF  <-- The card is no longer in use

6. To disable the graphic card at boot.

# echo "bbswitch" >> /etc/modules-load.d/bbswitch.conf
# echo "options bbswitch load_state=0" >> /etc/modprobe.d/bbswitch.conf
# update-initramfs -u

See the project website for more info regarding the module:

To see the battery consumption of your laptop (remember to remove the power cord).

awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT0/power_now

Debian Wheezy – Mate Desktop 1.8.1- Lowering The Volume Into Mute But Cannot Unmute By Increasing The Volume

Since the installation of Wheezy, I’ve been struggling to find a good and reliable desktop environment.  From Gnome 3 to XFCE to LXDE and back to XFCE.  Still, some of the things just didn’t work as I wanted it to be.  A few weeks ago I learnt that Debian’s Wheeze-backports have provided the Mate Desktop package.  It’s a fork from Gnome 2 which is the best Linux desktop environment I’ve ever used, so I decided to give it a try (I did try Mint Linux with Mate desktop for a short while quite some time ago).  It’s been a few weeks using the Mate desktop and I’m very happy with it except one thing: the sound will be muted when lowering the volume to 0% but it won’t be unmuted by increasing the volume.  I’ll have to fire up the “Sound Preferences” to unmute the audio device.  After some googling, the solution is easy:

aptitude install mate-media-pulse mate-settings-daemon-pulse

The two packages will replace the mate-media-gstreamer and mate-settings-daemon-gstreamer installed.

See here for a discussion of the issue:

Downgrade a debian package

Recently, I updated my iceweasel to version 24.4.0esr-1~deb7u2 which breaks the GWT browser plug-in. I need to downgrade it to a version which works with the plug-in.

First, I’ll need to install a tool which allows me to list out all available versions of a package:

# aptitude install apt-show-versions

Next, find out what versions of iceweasel are available:

# apt-show-versions --package=iceweasel --allversions

Finally, install the older version:

# apt-get install iceweasel=17.0.10esr-1~deb7u1


Creating a ISO file from CD/DVD

Find the block size:

$ isoinfo -d -i /dev/cdrom
CD-ROM is in ISO 9660 format
System id: 
Volume id: NEW
Volume set id: UNDEFINED
Publisher id: 
Data preparer id: 
Application id: NERO BURNING ROM
Copyright File id: 
Abstract File id: 
Bibliographic File id: 
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 2073648
NO Joliet present
NO Rock Ridge present

Create the ISO file:

$ dd if=/dev/cdrom bs=2048 of=video.iso

Setting up iceweasel in Wheezy (Debian)

To enable flash plugin:

aptitude install flashplugin-nonfree

To enable java plugin:

aptitude install icedtea-7-plugin

Open in Terminal -> Terminator

There is a very useful plug-in for nautilus called “nautilus-open-terminal”. One can open a terminal by right-click in any directory opened in nautilus. And immediately, your shell is in that particular directory. By default, the plug-in uses gnome-terminal. If you are using terminator and would like the plug-in to use terminator instead of the default gnome-terminal, just do the following:

#As root
update-alternatives --config x-terminal-emulator

Choose “terminator” when prompted and you are done. Probably a restart of the gdm is required.

#As normal unix user
gsettings set org.gnome.desktop.default-applications.terminal exec-arg '-x'

MySQL: Continue a failed replication slave

Sometimes, a replication error (e.g. duplicate data due to binlog error) will cause the replication slave to fail and stop. The easiest solution is to skip the problematic binlog data. We can do it by:

mysql> slave start;

By doing this, one line of replicated info is lost. So, do this only if the info to be skipped does not have real impact to the replicated database. My most recent use of this trick was when I encountered the following error:

[ERROR] Slave SQL: The incident LOST_EVENTS occured on the master. Message: mysqld startup, Error_code: 1590