Port Proxy in iptables – Forwarding port to another host

Here is the commands, for example you want to forward port 8080 to another host 192.168.100.2:8080

preparation, enable ip forward
sysctl net.ipv4.ip_forward=1

first we need to masquerade the packet
iptables -t nat -I POSTROUTING -p tcp -j MASQUERADE

Second, change the destination to another host
iptables -t nat -I PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 192.168.100.2:8080

Or, listen on specific ip
iptables -t nat -I PREROUTING -p tcp -d 192.168.100.1 --dport 8080 -j DNAT --to-destination 192.168.100.2:8080

This last is optional, you may need it if your FORWARD chain default REJECT
iptables -I FORWARD -d 192.168.100.2 -p tcp --dport 8080 -j ACCEPT

Note:
* iptables rules is not persistent, you can make it persistent using iptables-persistent
* you can also use ufw rules, save in the file /etc/ufw/before.rules

Source: https://askubuntu.com/questions/320121/simple-port-forwarding

Using Linux screen in Ubuntu

Screen is useful when updating system, usually takes long time, whenever accidentally disconnected, you can reconnect again.

Install
apt-get install screen

Start screen
$screen

Reattach
$screen -r

Control command
ctrl-a

Next Screen
ctrl-a n

Prev Screen
ctrl-a p

Detach Screen
ctrl-a d

New Screen
ctrl-a c

Quit
ctrl-a \

Help keys
ctrl-a ?

Source: http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/

Setup new zoneminder ubuntu server 14.04

1. Download Ubuntu Server ISO (choose Bittorent LTS Server)
http://www.ubuntu.com/download/alternative-downloads

2. Install Ubuntu Server (need internet connection, install Basic Server, OpenSSH, LAMP, Samba)
http://www.zoneminder.com/wiki/index.php/Ubuntu_Server_14.04_64-bit_with_Zoneminder_1.28.0_the_easy_way

3. Install Webmin
http://www.webmin.com/deb.html

4. Configure dedicated HDD storage (optional)
a. List partitions
lsblk
b. List UUID
blkid
c. Configure fstab (using UUID or device path)
http://www.zoneminder.com/wiki/index.php/Using_a_dedicated_Hard_Drive

5. Configure samba (optional)
https://help.ubuntu.com/community/How%20to%20Create%20a%20Network%20Share%20Via%20Samba%20Via%20CLI%20%28Command-line%20interface/Linux%20Terminal%29%20-%20Uncomplicated,%20Simple%20and%20Brief%20Way!

6. Install/Configure ffmpeg (optional, if you want to export video)
https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media
http://www.zoneminder.com/wiki/index.php/How_to_export_an_event_as_video

7. Add cameras
http://www.zoneminder.com/wiki/index.php/D-Link#DCS-5010L_and_DCS-5020L
http://www.zoneminder.com/wiki/index.php/D-Link_DCS-5020L_Control_Script
http://www.zoneminder.com/wiki/index.php/SC-3171

8. Enjoy

ubuntu 14.04: no talloc stackframe … leaking memory

Error Ubuntu 14.04: no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory

Appears when login, to fix it:

1. remove libpam-smbpass
sudo apt-get remove libpam-smbpass

Based on:
https://bugs.launchpad.net/ubuntu/+s…a/+bug/1257186, and
https://bugs.launchpad.net/ubuntu/+s…o/+bug/1274680

the libpam-smbpass package will sync system users and passwords with the Samba user database.

2. You can also fix this issue while keeping libpam-smbpass installed by running “pam-auth-update” and remove “SMB password synchronization”. Got that solution from Thomas (reusch) on https://bugs.launchpad.net/ubuntu/+s…a/+bug/1257186