Posts mit dem Label LINUX werden angezeigt. Alle Posts anzeigen
Posts mit dem Label LINUX werden angezeigt. Alle Posts anzeigen

Dienstag, 26. Februar 2013

nmap

nmap -sV -PN -sC -sS –O

-sV: Probe open ports to determine service/version info
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
-sC: equivalent to --script=default
-O: Enable OS detection

ICMP Tunnel




Angenommen wir haben einen "RootServer" im Internet
mit der WAN IP: 1.2.3.4
Dort lassen wir das Programm: ptunnel und Squid laufen.

# apt-get install ptunnel

startscript

/etc/init.d/ptunnel

#! /bin/sh
### BEGIN INIT INFO
# Provides:          ptunnel
# Required-Start:    $remote_fs $network $syslog
# Required-Stop:     $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: initscript for ptunnel
# Description:       initscript for ptunnel
### END INIT INFO

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="IP over ICMP tunneling server"
NAME=ptunnel
DAEMON=/usr/sbin/$NAME
DEFAULT=ptunnel
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Get config
get_config() {
        [ -r /etc/default/$DEFAULT ] && . /etc/default/$DEFAULT
        if [ "$run_daemon" != "true" ] ; then
                [ "$VERBOSE" != no ] && log_progress_msg "- automatic start disabled" && log_end_msg 0
                exit 0
        fi
}


#
# Function that starts the daemon/service
#
do_start()
{
        # populate $DAEMON_ARGS
        get_config
        #
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --background --exec $DAEMON -- -x "" -m 200\
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --exec $DAEMON
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
       # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --quiet --oknodo --retry=0/5/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return "$RETVAL"
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  restart|force-reload)
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac



# update-rc.d ptunnel defaults


# /etc/init.d/ptunnel start


Auf dem Client ptunnel installieren oder kompilieren


# ./ptunnel -m 30 -p 1.2.3.4 -lp 8000 -da localhost -dp 3128 -c eth0 -x



Dann auf dem Client im Browser folgenden Proxy eintragen


Host: localhost Port:8000


So kann man aus einem Netzwerk das einen Ping ins internet zulässt aber
keinen Zugriff per HTTP / HTTPs / FTP über einen ICMP Tunnel über
den Proxy auf dem "RootServer" doch surfen.



Batch copy mit SFTP

es muss der public der der QuellMaschine auf der Zielmaschine
unter /root/.ssh/authorized_keys abgelegt werden

sftp -b ~/commands.sftp user@domain.tld

commands.sftp:

cd /dir1
mput *.123
mput *.456
quit


Mittwoch, 3. Oktober 2012

HMC Commandline

IBM HMC (Hardware Managment Console)
Wer lieber Commandline statt die WebGUI nutzen will
hier nur ein paar wenige Kommandos

 
ssh hscroot@

> vtmenu          =          für öffnen von Consolenfenstern auf LPAR
                                   hier kann man auch nach den SERVER-SYSTEM-NAMEN schauen

> chsysstate -r lpar -m -o on -f -b sms -n

starten einer LPAR ins SMS MENU


> chsysstate -r lpar -m -o on -f -n

starten einer LPAR

> chsysstate -r lpar -m -o shutdown --immed -n

ausschalten einer LPAR



> lssyscfg -m -r lpar

infos über die LPARs auf dem SERVER-SYSTEM abfragen


> lspartition -ix -dlpar

dlpar Infos abfragen von alle SERVER-SYSTEMEN

> lshwres -r virtualio --rsubtype eth --level lpar -m

MAC Adressen
Status Abfrage LPAR ein oder ausgeschaltet






Montag, 21. November 2011

tcp_timestamps abschalten

Abschalten von Info der (nic)uptime


z.B: in der /etc/rc.local
echo 0 > /proc/sys/net/ipv4/tcp_timestamps



Testen mit:



für SSL

hping3 -S --tcp-timestamp -p 443 -c 2


für HTTP

hping3 -S --tcp-timestamp -p 80 -c


für ssh

hping3 -S --tcp-timestamp -p 22 -c

Sonntag, 19. Juni 2011

Icinga auf Ubuntu Server 10.04

Icinga auf Ubuntu Server 10.04 (64bit)
--------------------------------------

0. Installation Ubuntu Server


1. apt-get install -y libdbi0-dev libdbd-mysql build-essential libgd2-xpm-dev libjpeg62-dev libpng12-dev mysql-server mysql-client apache2 openssl libssl-dev libmysqlclient16-dev

2. useradd -m icinga
passwd icinga
groupadd icinga-cmd
usermod -a -G icinga-cmd icinga
usermod -a -G icinga-cmd www-data


3. cd /var/tmp
wget http://sourceforge.net/projects/icinga/files/icinga/1.0.2/icinga-1.0.2.tar.gz/download

tar xvfz icinga-1.0.2.tar.gz

cd /var/tmp/icinga-1.0.2
./configure --with-command-group=icinga-cmd --enable-idoutils
make all
sudo make fullinstall

4. cd /var/tmp
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download
tar xvfz nagios-plugins-1.4.15.tar.gz

cd /usr/src/nagios-plugins-1.4.15
./configure --prefix=/usr/local/icinga --with-nagios-user=icinga
make
sudo make install


5.

sudo htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
sudo /etc/init.d/apache2 restart
sudo mysql -u root -p
create database icinga;
GRANT USAGE ON *.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
GRANT SELECT , INSERT , UPDATE , DELETE ON icinga.* TO 'icinga'@'localhost';
flush privileges;
quit

cd /var/tmp/icinga-1.0.2/module/idoutils/db/mysql
sudo mysql -u root -p icinga < mysql.sql

sudo mv /usr/local/icinga/etc/ido2db.cfg-sample /usr/local/icinga/etc/ido2db.cfg
sudo mv /usr/local/icinga/etc/idomod.cfg-sample /usr/local/icinga/etc/idomod.cfg

sudo vi /usr/local/icinga/etc/ido2db.cfg

db_user und db_password anpassen wenn nicht "icinga" als password verwendet wurde.

sudo vi /usr/local/icinga/etc/icinga.cfg

broker_module=/usr/local/icinga/bin/idomod.o config_file=/usr/local/icinga/etc/idomod.cfg

sudo /etc/init.d/ido2db start
sudo /etc/init.d/icinga start
sudo update-rc.d ido2db defaults 50
sudo update-rc.d icinga defaults 51



püfen der config

cd /usr/local/icinga/bin
sudo ./icinga -v /usr/local/icinga/etc/icinga.cfg




sudo apt-get install sendmail mailutils

vi /etc/mail/sendmail.mc

add: FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl

vi /etc/mail/mailertable

example:

.domain.tld esmtp:[mailserver]


sendmailconfig



mail user@domain.tld

check mail recivied

ntop 4 installation unter Ubuntu 10.04 Server

nTop 4 unter Ubuntu 10.04(64bit)
--------------------------------

Internetanbindung notwendig!
Möglichst 2 Netzwerkkarten (eine zum Mitlauschen, eine zum Netzwerkzugriff)
Festplatte sollte min 4 GB haben (für kleinen Test) lieber grösser.


1. Installation von Ubuntu Server 10.04 (64bit)
Download: http://www.ubuntu.com/server/get-ubuntu/download
OpenSSH Server

2. Online Update
sudo apt-get update
sudo apt-get updrade

u.U. muss man den akt. Kernel noch instl.
sudo apt-get install linux-headers-server linux-image-server linux-server

diese sagt einem aber sudo apt-get upgrade wenn man es nochmals aufruft

Danach ein reboot: sudo reboot
dann sudo apt-get autoremove um alte nichtmehr benötigte
Packte zu deinstallieren

sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get install autoconf
sudo apt-get install automake
sudo apt-get install m4
sudo apt-get install libpcap0.8
sudo apt-get install libpcap0.8-dev
sudo apt-get install zlib1g
sudo apt-get install zlib1g-dev
sudo apt-get install rrdtool
sudo apt-get install librrd4
sudo apt-get install librrd-dev
sudo apt-get install graphviz


sudo apt-get install openssl
sudo apt-get install libssl-dev

sudo apt-get install libgeoip-dev


sudo aptitude install python-dev
sudo apt-get install pyhton-dev
sudo apt-get install pyhton-mako

sudo apt-get install libgdbm-dev


3. Download von nTop Source
http://sourceforge.net/projects/ntop/

oder

wget http://sourceforge.net/projects/ntop/files/ntop/ntop-4.0.1/ntop-4.0.1.tar.gz/download

z.B: tar xvfz ntop-4.0.1.tar.gz


cd ntop-4.0.1

./autogen.sh

./configure

make

sudo make install

sudo adduser --system --group --home /usr/local/lib/ntop ntop


sudo cp packages/debian/etc/ld.so.conf.d/ntop.conf /etc/ld.so.conf.d




vi /etc/init.d/ntop

#! /bin/sh
#
# ntop script
#
# NOTE: Copy this script in /etc/init.d/ntop
#
# Author:
# Paul Mansfield
# Worldpay - 20020218
#
# Fixed by L.Deri - May 2007
# mod. D.Schneck - August 2010

set -e

NAME=ntop
DAEMON=/usr/local/bin/ntop
CONFIG=/etc/ntop/ntop.conf
PROTOCOLFILE=/etc/ntop/protocol.list
test -x $DAEMON || exit 0

start_ntop() {
echo -n "Starting ntop "
$DAEMON @$CONFIG -p $PROTOCOLFILE > /var/log/ntop.out &
echo " ...done"
}

stop_ntop() {
echo -n "Stopping ntop "
if test -f /var/run/ntop.pid ; then
kill `cat /var/run/ntop.pid`
echo -n " killed pid `cat /var/run/ntop.pid`"
rm /var/run/ntop.pid
fi
echo " ...done"
}

case "$1" in
start)
start_ntop
;;

stop)
stop_ntop
;;

restart)
stop_ntop
start_ntop
;;

defaults)
$DAEMON -u ntop --set-admin-password=admin
;;

*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|install}"
exit 1
;;
esac

exit 0



sudo chmod 755 /etc/init.d/ntop






sudo ldconfig

sudo chown -R ntop.ntop /usr/local/var/ntop

cd /etc/init.d

sudo mkdir /etc/ntop

cd /var/tmp/ntop-4.0.1

sudo cp packages/Redhat/ntop.conf.sample /etc/ntop/ntop.conf

In dieser Datei werden z.B: Portnummer, Netzwerkkarte usw. eingestellt.

--db-file-path /usr/local/var/ntop muss angepasst werden

sudo cp packages/debian.official/protocol.list /etc/ntop

sudo ntop --user ntop -P /usr/local/var/ntop

sudo chown -R ntop.ntop /usr/local/var/ntop

sudo service ntop start

Soll ntop beim starten des Systemns automatisch gestartet werden, geben Sie folgendes ein:

sudo update-rc.d ntop defaults

Ändern von gruppen

ändern von gruppen(rechten)

find admin audit bin esa etc home lpp opt oracle pconsole sapmnt sbin tivoli unix usr var -group 203 -exec chgrp 200 {} \;

Samstag, 29. Januar 2011

Daten auf myDrive.ch verschlüsselt speichern

Getestet mit Ubuntu 10.10 (64bit)


0. Nötige Pakete installieren

1. MyDrive.ch account anlegen

2. Verschlüsselten Container erzeugen

3. Upload des Containers auf MyDrive

4. Mounten des Containters

5. Spass haben




0. sudo apt-get install cryptsetup davfs2

sudo mkdir /media/mydrive

sudo mkdir /media/cryptfs

1. per Browser auf http://www.mydrive.ch gehen
und einen Kostenloses Account anlegen

2. dd if=/dev/zero of=meins bs=1M count=256
(hier wird eine 256 MB grosse Datei erstellt mit dem Namen: meins)

sudo losetup /dev/loop0 meins

dd if=/dev/urandom of=/dev/loop0 bs=1M count=2

cryptsetup luksFormat -c aes-cbc-essiv:sha256 -s 256 -y /dev/loop

(hier Informieren was das beste Format für die Verschlüsselung ist)

cryptsetup luksOpen /dev/loop0

z.B.

sudo cryptsetup luksOpen /dev/loop0 myDrive

sudo mkfs.ext4 /dev/mapper/myDrive

sudo cryptsetup luksClose /dev/mapper/myDrive

sudo losetup -d /dev/loop0


3. Anmelden auf MyDrive.ch
die Datei: meins hochladen



4. Zuerst muss man myDrive.ch mounten

sudo mount.davfs https://webdav.mydrive.ch /media/mydrive

sudo losetup /dev/loop0 /media/mydrive/meins

sudo cryptsetup luksOpen /dev/loop0 myDrive

sudo mount /dev/mapper/myDrive /media/cryptfs



Abhängen des Filesystems:

sync

sudo umount /dev/mapper/myDrive

sudo cryptsetup luksClose /dev/mapper/myDrive

sudo losetup -d /dev/loop0


umount /media/mydrive

(Auch das unmounten kann lange dauern, je nach Internetverbindung)

Donnerstag, 14. Oktober 2010

sendmail mailq leeren

Sendmail - mail queue abarbeiten

sendmail -q -v

Netzwerkarten nach Clone nicht mehr eth0 - was tun ?

Wenn man einen Clone z.B. mit CloneZilla von einer Linux-Maschine macht.
Kommt es vor, dass die Netzwerkarte(n) nicht mehr eth0 (/ eth1) sind sondern eth2 (/ eth3)

Dies lässt sich beheben in dem man in folgender Datei:

/etc/udev/rules.d/??-persistent-net.rules

Die Einträge anpasst, dann hat man wieder z.B. eine eth0 in dem geclonten System.

Automatisches Backup auf eine Netzwerkfreigabe mit CloneZilla

0. Laden des Tools von http://www.pendrivelinux.com/boot-multiple-iso-from-usb-multiboot-usb/

1. Herunterladen der CloneZilla ISO unter: http://clonezilla.org/ (Alternative Version)

2. Herunterladen der Memtest ISO von http://www.memtest.org/

3. USB-Stick einstecken, Tool (MultiBootISOs-X.X.X.X.exe) unter Windows starten
Formatieren des Sticks auswählen und die Memtest Datei.
Und das Programm laufen lassen.

4. ggf. die CloneZilla ISO Datei entpacken mit z.B: 7zip (http://www.7-zip.org/)
in das Verzeichnis clonezilla auf dem USB-Stick

5. anpassen der Datei: menu.lst auf folgenden Inhalt


default 0

timeout 5

color NORMAL HIGHLIGHT HELPTEXT HEADING

splashimage=/splash.xpm.gz

foreground=FFFFFF

background=000000





title Boot Clonezilla (AUTOBACKUP /dev/sda)

find --set-root /clonezilla/live/initrd1.img

kernel /clonezilla/live/vmlinuz1 boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run="/live/image/clonezilla/custom-ocs" ocs_live_extra_param="" ocs_live_keymap="/usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 nolocales live-media-path=/clonezilla/live

initrd /clonezilla/live/initrd1.img





title Boot Clonezilla (AUTOBACKUP /dev/hda)

find --set-root /clonezilla/live/initrd1.img

kernel /clonezilla/live/vmlinuz1 boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run="/live/image/clonezilla/custom-ocs-hda" ocs_live_extra_param="" ocs_live_keymap="/usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 nolocales live-media-path=/clonezilla/live

initrd /clonezilla/live/initrd1.img





title Boot Clonezilla

find --set-root /clonezilla/live/initrd1.img

kernel /clonezilla/live/vmlinuz1 boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run='ocs-live-general' ocs_live_extra_param='' ocs_live_keymap='de' ocs_live_batch='no' ocs_lang='en' vga=788 ip=frommedia nosplash live-media-path=/clonezilla/live toram=filesystem.squashfs

initrd /clonezilla/live/initrd1.img





# Suggested by Erhan Sohail

title Boot First Hard Drive (HDD)

map (hd0) (hd1)

map (hd1) (hd0)

map --hook

chainloader (hd0)+1

rootnoverify (hd0)



title Restart

reboot



title Shutdown

halt



6. erstellen der 2 Dateien: custom-ocs und custom-ocs-hda im Verzeichnis clonezilla auf dem USB-Stick

mit folgendem Inhalt:

#!/bin/bash

# Author: Steven Shiau

# License: GPL

# When this script is ready, you can run

# /opt/drbl/sbin/ocs-iso -g en -k NONE -s -m ./custom-ocs

# to create the iso file for CD/DVD. or

# /opt/drbl/sbin/ocs-live-dev -g en -k NONE -s -c -m ./custom-ocs

# to create the zip file for USB flash drive.

# Begin of the scripts:

# Load DRBL setting and functions

if [ ! -f "/opt/drbl/sbin/drbl-conf-functions" ]; then

echo "Unable to find /opt/drbl/sbin/drbl-conf-functions! Program terminated!"

exit 1

fi

. /opt/drbl/sbin/drbl-conf-functions

. /opt/drbl/sbin/ocs-functions

# load the setting for clonezilla live.

[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf

# Load language files. For English, use "en_US.UTF-8". For Traditional Chinese, use "zh_TW.UTF-8"

ask_and_load_lang_set en_US.UTF-8

# The above is almost necessary, it is recommended to include them in your own custom-ocs.

# From here, you can write your own scripts.

echo "#########################################################################################"

echo "# 1. Configure network"

dhclient

echo "#########################################################################################"

echo "# 2. Mount the clonezilla image home"

mkdir /home/partimag

mount -t cifs -o username=USERNAME,password=PASSWORD //SERVERNAME/SHARE /home/partimag

echo "#######################################after mounting, now showing mounts###########"

mount

echo "#########################################################################################"

echo "# 3. backing up sda"

/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLIENTNAME_`date +%H%M%S_%d%m%Y`" "sda"

echo "#########################################################################################"



bzw. die Zeile

/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLIENTNAME_`date +%H%M%S_%d%m%Y`" "hda"

in der Datei: custom-ocs-hda anpassen


ACHTUNG: es müssen folgende Zeilen angepasst werden:

mount -t cifs -o username=USERNAME,password=PASSWORD //SERVERNAME/SHARE /home/partimag

ersetzen in z.B.

mount -t cifs -o username=backup,password=backup4client //10.1.1.250/backup /home/partimag


/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLIENTNAME_`date +%H%M%S_%d%m%Y`" "sda"

ersetzen in z.B.

/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "CLI01_`date +%H%M%S_%d%m%Y`" "sda"


Das wars....

Freitag, 20. August 2010

Icinga unter Ubuntu 10.04 kompilieren

Icinga auf Ubuntu Server 10.04 (64bit)
--------------------------------------

0. Installation Ubuntu Server


1. apt-get install -y libdbi0-dev libdbd-mysql build-essential libgd2-xpm-dev libjpeg62-dev libpng12-dev mysql-server mysql-client apache2 openssl libssl-dev

2. useradd -m icinga
passwd icinga
groupadd icinga-cmd
usermod -a -G icinga-cmd icinga
usermod -a -G icinga-cmd www-data


3. cd /var/tmp
wget http://sourceforge.net/projects/icinga/files/icinga/1.0.2/icinga-1.0.2.tar.gz/download

tar xvfz icinga-1.0.2.tar.gz

cd /var/tmp/icinga-1.0.2
./configure --with-command-group=icinga-cmd --enable-idoutils
make all
sudo make fullinstall

4. cd /var/tmp
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download
tar xvfz nagios-plugins-1.4.15.tar.gz

cd /usr/src/nagios-plugins-1.4.15
./configure --prefix=/usr/local/icinga --with-nagios-user=icinga
make
sudo make install


5.

sudo htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
sudo /etc/init.d/apache2 restart
sudo mysql -u root -p
create database icinga;
GRANT USAGE ON *.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
GRANT SELECT , INSERT , UPDATE , DELETE ON icinga.* TO 'icinga'@'localhost';
flush privileges;
quit

cd /var/tmp/icinga-1.0.2/module/idoutils/db/mysql
sudo mysql -u root -p icinga < mysql.sql

sudo mv /usr/local/icinga/etc/ido2db.cfg-sample /usr/local/icinga/etc/ido2db.cfg
sudo mv /usr/local/icinga/etc/idomod.cfg-sample /usr/local/icinga/etc/idomod.cfg

sudo vi /usr/local/icinga/etc/ido2db.cfg

db_user und db_password anpassen wenn nicht "icinga" als password verwendet wurde.

sudo vi /usr/local/icinga/etc/icinga.cfg

broker_module=/usr/local/icinga/bin/idomod.o config_file=/usr/local/icinga/etc/idomod.cfg

sudo /etc/init.d/ido2db start
sudo /etc/init.d/icinga start
sudo update-rc.d ido2db defaults 50
sudo update-rc.d icinga defaults 51



püfen der config

cd /usr/local/icinga/bin
sudo ./icinga -v /usr/local/icinga/etc/icinga.cfg

nTop unter Ubuntu 10.04 kompilieren

nTop 4 unter Ubuntu 10.04(64bit)
--------------------------------

Internetanbindung notwendig!
Möglichst 2 Netzwerkkarten (eine zum Mitlauschen, eine zum Netzwerkzugriff)
Festplatte sollte min 4 GB haben (für kleinen Test) lieber grösser.


1. Installation von Ubuntu Server 10.04 (64bit)
Download: http://www.ubuntu.com/server/get-ubuntu/download
OpenSSH Server

2. Online Update
sudo apt-get update
sudo apt-get updrade

u.U. muss man den akt. Kernel noch instl.
sudo apt-get install linux-headers-server linux-image-server linux-server

diese sagt einem aber sudo apt-get upgrade wenn man es nochmals aufruft

Danach ein reboot: sudo reboot
dann sudo apt-get autoremove um alte nichtmehr benötigte
Packte zu deinstallieren

sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get install autoconf
sudo apt-get install automake
sudo apt-get install m4
sudo apt-get install libpcap0.8
sudo apt-get install libpcap0.8-dev
sudo apt-get install zlib1g
sudo apt-get install zlib1g-dev
sudo apt-get install rrdtool
sudo apt-get install librrd4
sudo apt-get install librrd-dev
sudo apt-get install graphviz


sudo apt-get install openssl
sudo apt-get install libssl-dev

sudo apt-get install libgeoip-dev

sudo apt-get install pyhton-dev
sudo apt-get install pyhton-mako

sudo apt-get install libgdbm-dev


3. Download von nTop Source
http://sourceforge.net/projects/ntop/

oder

wget http://sourceforge.net/projects/ntop/files/ntop/ntop-4.0.1/ntop-4.0.1.tar.gz/download

z.B: tar xvfz ntop-4.0.1.tar.gz


cd ntop-4.0.1

./autogen.sh

./configure

make

sudo make install

sudo adduser --system --group --home /usr/local/lib/ntop ntop


sudo cp packages/debian/etc/ld.so.conf.d/ntop.conf /etc/ld.so.conf.d




vi /etc/init.d/ntop

#! /bin/sh
#
# ntop script
#
# NOTE: Copy this script in /etc/init.d/ntop
#
# Author:
# Paul Mansfield
# Worldpay - 20020218
#
# Fixed by L.Deri - May 2007
# mod. D.Schneck - August 2010

set -e

NAME=ntop
DAEMON=/usr/local/bin/ntop
CONFIG=/etc/ntop/ntop.conf
PROTOCOLFILE=/etc/ntop/protocol.list
test -x $DAEMON || exit 0

start_ntop() {
echo -n "Starting ntop "
$DAEMON @$CONFIG -p $PROTOCOLFILE > /var/log/ntop.out &
echo " ...done"
}

stop_ntop() {
echo -n "Stopping ntop "
if test -f /var/run/ntop.pid ; then
kill `cat /var/run/ntop.pid`
echo -n " killed pid `cat /var/run/ntop.pid`"
rm /var/run/ntop.pid
fi
echo " ...done"
}

case "$1" in
start)
start_ntop
;;

stop)
stop_ntop
;;

restart)
stop_ntop
start_ntop
;;

defaults)
$DAEMON -u ntop --set-admin-password=admin
;;

*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|install}"
exit 1
;;
esac

exit 0



sudo chmod 755 /etc/init.d/ntop






sudo ldconfig

chown -R ntop.ntop /usr/local/var/ntop

cd /etc/init.d

sudo mkdir /etc/ntop

sudo cp packages/Redhat/ntop.conf.sample /etc/ntop/ntop.conf

In dieser Datei werden z.B: Portnummer, Netzwerkkarte usw. eingestellt.

--db-file-path /usr/local/var/ntop muss angepasst werden

sudo cp packages/debian.official/protocol.list /etc/ntop

sudo ntop --user ntop -P /usr/local/var/ntop

sudo chown -R ntop.ntop /usr/local/var/ntop

sudo service ntop start

Soll ntop beim starten des Systemns automatisch gestartet werden, geben Sie folgendes ein:

sudo update-rc.d ntop defaults

Sonntag, 21. Februar 2010

Verzeichnis nach einem STRING durchsuchen

Suchen im aktuellen Verzeichnis und den Unterverzeichnissen

find . -type f -exec grep -i 'STRING' {} \; -a -exec ls -l {} \;

Durchsuchen des ganzen Systems

find / -type f -exec grep -i 'STRING' {} \; -a -exec ls -l {} \;

Mittwoch, 6. Januar 2010

Ein NAS für VMWare ESXi Backup

Es stellte sich die Frage wie man Virtuelle Maschinen von einem VMWare ESXi Server sichert.
Der ESXi Server ist Kostenlos für privaten und Komerziellen einsatz.
Ein NAS - System als Datenspeicher wollte ich nutzen.
Meine erste Idee war freeNAS, die viel aber leider wegen Treiberproblemen mit den SATA Festplatten aus.
Also nahm ich Ubuntu Server 9.10, installierte mit openssh, NFS und Samba.
Als Harware kam ein PC mit einer SATA Festplatte für das Ubuntu Linux
und 2 SATA Festplatten als Software RAID1 für die Daten.

Das NFS-Protokoll benötigt man um den VMWare ESXi Server an
das NAS-System (Ubuntu Server 9.10) zu binden.
Samba das Windows PCs auf die Daten zugreiffen können.

Als Editor verwende ich VI, es kann auch jeder andere Editor verwendet werden.

Vorrausetzungen am ESXi-Server:
ssh muss eingeschaltet werden. Wenn man das macht bekommt man keinen Support von
VMWare.

STRG + F1 drücken
dann unsupported eingeben und Enter drücken

# vi /etc/inetd.conf


die Zeile mit ssh einkommentieren, sprich das # am Zeilenanfang löschen.
Dann am besten der Server booten.

Zum ssh Zugriff auf den VMWare ESXi Server kann man unter Windows z.B: putty verwenden.

Das Samba muss so Konfiguriert werden, dass ein Anonymer Zugriff möglich ist
da ich sonst Probleme mit BackupExec probleme hatte eine Sicherung in einen Ordner durchzuführen. Denn die Virtuellen Maschinen sichern mit der Backup-Software
BackupExec.


Anpassungen am Ubuntu Server

Angenommen der VMWare ESXi Server heist: vmsrv01

# apt-get update
# apt-get upgrade
# reboot

# apt-get install ntp
# apt-get install nfs-kernel-server nfs-common portmap
# apt-get install ethtool

RAID1 über 2 festplatten (z.B: /dev/sdb /dev/sdc) anlegen

# mdadm /dev/md0 --create --auto yes -l 1 -n 2 /dev/sdb /dev/sdc
# mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Filesystem (ext4) auf dem erzeuten RAID1 anlegen.

# mkfs.ext4 /dev/md0


# vi /etc/fstab

/dev/md0 /datastore ext4 errors=remount-ro 0 1

Alle Filesystem die nicht gemountet sind mounten.

# mount -a

Anzeigen aller gemounteten Filesysteme.

# df -h


Anpassen der NFS-Konfigurationsdatei

# vi /etc/exports

/datastore vmsrv01(rw,no_subtree_check)

WICHTIG: DNS bzw. Hosts das die Maschinen siche auflösen können
sprich wenn man vom ESXi Server # ping nas ausführt
bzw. vom NAS-System # ping vmsrv01
muss dann eine Antwort zurückkommen.
Ping ist ein kleines Programm das versucht einen anderen Rechner
im TCP/IP-Netz zu erreichen.

# vi /etc/init.d/netspeed

#!/bin/sh
ETHTOOL="/usr/sbin/ethtool"
DEV="eth0"
SPEED="100 duplex full"
#SPEED="1000 duplex full autoneg on"
case "$1" in
start)
echo -n "Setting eth0 speed 100 duplex full...";
$ETHTOOL -s $DEV speed $SPEED;
echo " done.";;
stop)
;;
esac
exit 0

# chmod +x /etc/init.d/netspeed
# update-rc.d netspeed defaults

So wird die Netzwerkkarte so eingestellt, dass Sie mit 100MBit Full Duplex
arbeitet.


Samba Konfiguration:

# vi /etc/samba/smb.conf

[global]
encrypt passwords = yes
netbios name = nas
workgroup = WORKGROUP
server string = NAS Server (Ubuntu Linux)
security = share
dns proxy = no
# Settings to enhance performance:
use sendfile = yes
strict locking = no
read raw = yes
write raw = yes
oplocks = yes
max xmit = 65535
deadtime = 15
getwd cache = yes
socket options = IPTOS_LOWDELAY TCP_NODELAY SO_SNDBUF=16384 SO_RCVBUF=16384
# End of performance section
unix charset = UTF-8
large readwrite = no
store dos attributes = yes
local master = yes
time server = yes
guest account = nobody
display charset = LOCALE
max log size = 10
syslog only = yes
syslog = 1
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
log level = 1
dos charset = CP437
smb passwd file = /etc/samba/smbpasswd
private dir = /etc/samba
passdb backend = smbpasswd
create mask = 0666
directory mask = 0777
force user = nobody
force group = nogroup

[backup]
comment = backup datastore
path = /datastore/
writeable = yes
printable = no
veto files = /.snap/
hide dot files = yes
guest ok = yes
inherit permissions = yes

# exportfs -a

# /etc/init.d/samba restart

Donnerstag, 4. Juni 2009

Bilder per Script verkleinern

Wenn man z.B: Bilder auf eine Webseite stellen will
aber die Bilder sind "viel" zu groß.
Dann kann einem das kleine Script hier helfen.
Auf dem System muss das Packet ImageMagick installiert sein.

#!/bin/bash
# imagemagick needed

for i in J*.jpg;
do
j=${i//\.jpg/};
convert -size 800x600 $i ${j}_klein.jpg;
done

Freitag, 29. Mai 2009

Volumegroup / VG verkleinern / verschieben

z.b. rootvg plattengrösse 147 gb /dev/sda

ziel rootvg plattengrösse 85 gb /dev/sdb

geht nur wenn die nutzdaten kleiner als 85 gb sind

zweite platten zum system dazu z.b. 85 gb

fdisk /dev/sdb

eine paration anlegen mit type 8e / lvm

pv create /dev/sdb

vgextend rootvg /dev/sdb

pvmove /dev/sda /dev/sdb

vgreduce rootvg /dev/sda

dann die neue 85 gb platte als master anhängen.
system von rescue cd booten und blootloader installieren.
/boot clonen nicht vergessen.
ggf. /etc/fstab anpassen

Dienstag, 17. März 2009

Donnerstag, 5. März 2009

Doppelte Dateien finden

Ein kleines Script mit dem man Doppelte Dateien finden kann.


#!/bin/bash
#
clear
USAGE="usage: doublefind ; ./doublefind /bin"
echo
if [ $# = 0 ]
then
echo $USAGE
echo
echo
exit
fi
echo $#


echo
echo
echo doublefind is running ...
echo
echo

# pruefsumme berechnen
#

find $1 -exec md5sum {} ; > /tmp/sum.unsorted

#
# pruefsummen sortieren

sort < /tmp/sum.unsorted > /tmp/sum.sorted


#
# alle doppelten summen finden und speichern

cut -f 1 -d " " /tmp/sum.sorted | uniq -d > /tmp/sum.dupe

#
# doppelte dateien finden und ausgeben

grep -F -f /tmp/sum.dupe /tmp/sum.sorted
#
#