The port forwarding from one ip to another ip in same network using iptables

Let’s say that we need to forward all connection to a port 143 IMAP to localhost to another server to a port 143 IMAP:

iptables -t nat -I PREROUTING -p tcp -d localhost --dport 143 -j DNAT --to-destination anotherserver:143
iptables -t nat -A POSTROUTING -p tcp --dport 143 -d anotherserver -j SNAT --to localhost

172.16.60.5 – localhost
172.16.10.77 – another server

# Forward port 143 IMAP to 172.16.10.77
iptables -t nat -I PREROUTING -p tcp -d 172.16.60.5 --dport 143 -j DNAT --to-destination 172.16.10.77:143
iptables -t nat -A POSTROUTING -p tcp --dport 143 -d 172.16.10.77 -j SNAT --to 172.16.60.5

# Log connection to port 143 to /var/log/firewall
iptables -t nat -I PREROUTING -p tcp --dport 143 -j LOG --log-prefix "IMAP PREROUTING: "
iptables -t nat -I POSTROUTING -p tcp --dport 143 -j LOG --log-prefix "IMAP POSTROUTING: "

Smokeping on Debian/Ubuntu.

To install smokeping:

root# apt-get install smokeping

Link in the smokeping apache config:

root# cd /etc/apache2/conf-available
root# ln -s ../../smokeping/apache2.conf smokeping.conf

Enable the config and mod_cgi:

root# a2enconf smokeping
root# a2enmod cgid

Reload Apache:

root# /etc/init.d/./apache2 reload

Configuration files can be found here: /etc/smokeping/config.d/

root# ls -la /etc/smokeping/config.d/
total 64
drwxr-xr-x 2 root root 4096 Nov 23 09:06 .
drwxr-xr-x 3 root root 4096 Nov 19 13:07 ..
-rw-r–r– 1 root root 165 Nov 19 12:41 Alerts
-rw-r–r– 1 root root 237 Jul 8 2014 Database
-rw-r–r– 1 root root 509 Nov 19 09:31 General
-rw-r–r– 1 root root 225 Jul 8 2014 pathnames
-rw-r–r– 1 root root 876 Jul 8 2014 Presentation
-rw-r–r– 1 root root 50 Jul 8 2014 Probes
-rw-r–r– 1 root root 147 Jul 8 2014 Slaves
-rw-r–r– 1 root root 9025 Nov 23 09:06 Targets
-rw-r–r– 1 root root 9039 Nov 23 09:00 Targets_okay
-rw-r–r– 1 root root 380 Jul 8 2014 Targets_orig
root#

Discarding unwanted messages in rsyslogd.

There are some messages that you do not want to see in the logs file. In this case I had the following:

Nov 16 14:15:51 nbefa1 nrpe[25429]: Error: Could not complete SSL handshake. 1
Nov 16 14:15:51 nbefa1 nrpe[25431]: Error: Could not complete SSL handshake. 1
Nov 16 14:15:51 nbefa1 nrpe[25435]: Error: Could not complete SSL handshake. 1
Nov 16 14:15:51 nbefa1 nrpe[25437]: Error: Could not complete SSL handshake. 1
Nov 16 14:15:55 nbefa1 nrpe[25446]: Error: Could not complete SSL handshake. 1
Nov 16 14:15:55 nbefa1 nrpe[25448]: Error: Could not complete SSL handshake. 1

To get rid of those unwanted messages add the following to the top of /etc/rsyslogd.conf file:

# Discarding unwanted messages
:msg, contains, "Error: Could not complete SSL handshake. 1" ~

And then restart rsyslogd.

More information: http://www.rsyslog.com/discarding-unwanted-messages/

Prevent users from accidentally dragging and dropping folders into other folders – OES11

Here is how to prevent that from happening.

1. Right click on the folder that you want to protect
2. Click on properties
3. Click on Netware Info tab
4. Put check mark on "Rename Inhibit" and "Delete inhibit"
5. Click on apply and OK

Also the command line can be used on OES11 server:

root# attrib /folder/protected_from_rename_delete_etc -s=ri,di

Mount an ISO image

An ISO image or .iso (International Organization for Standardization) file is an archive file that contains a disk image called ISO 9660 file system format. Every ISO file have .ISO extension has defined format name taken from the ISO 9660 file system and specially used with CD/DVD rom’s. In simple words an iso file is a disk image.
ISO images can be created from optical discs by disk imaging software, or from a collection of files by optical disc authoring software, or from a different disk image file by means of conversion. Software distributed on bootable discs is often available for download in ISO image format. And like any other ISO image, it may be written to an optical disc such as CD or DVD.

Mount an ISO image:
root# mount -t iso9660 -o loop /root/debian-8.2.0-amd64-xfce-CD-1.iso /mnt/iso/

Unmount an ISO image:
root# umount /mnt/iso

/ on LVM gets mounted by initrd with kernel device name /dev/dm-X instead of /dev/mapper/XXX name

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=791754

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=791754;msg=10;filename=resolve_device.diff;att=1

— /usr/share/initramfs-tools/scripts/functions.orig 2015-07-08 10:48:26.000000000 +0200
+++ /usr/share/initramfs-tools/scripts/functions 2015-07-08 10:39:15.000000000 +0200
@@ -324,6 +324,10 @@
UUID=*)
DEV=”/dev/disk/by-uuid/${DEV#UUID=}”
;;
+ /dev/mapper/*)
+ echo “$DEV”
+ return 0
+ ;;
esac
# Only canonicalise if a valid file, in case $DEV isn’t a filename
[ -e “$DEV” ] && DEV=$(readlink -f “$DEV”)

And then run the following command:

update-initramfs -u -k all

If this is not possible to implemented this patch/workaround always this command can be used:

dmsetup ls --tree