VMWare ESXi change MAC Address of physical network adapter

This article explains how to change the MAC address of a physical network adapter on an VmWare ESXi 5.1 host.

1) Connect you with SSH to your ESXi Server

2) Open the file /etc/vmware/esx.conf
vi /etc/vmware/esx.conf

3) Search for your old MAC address and replace it with the new one. You can search in the VI editor by typing “/” without brackets.

4) Save your changes by typing :wq

5) Reboot

Windows Server 2008 – Changing RDP Port

Open the Registry Editor

Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

Open PortNumber, switch to dezimal and change the port.

Click ok and close the registry editor.
By the way: U have to add a Firewall Rule for the new port to Windows Firewall…

I believe, following pictures are self explained…

now you have to restart the server or restart the “Remotedesktopservices” under the Windows Services but befor u test it: You should have physic access to the server, if something went wrong!
If you don’t have this option, install TeamViewer or something like that.. so u could return the changes in the registry.

If it works, deactivate the old RDP Firewall Rule in the Windows Firewall.

Realtime CLI Netzwerkmonitoring auf Linux

jnettop:
apt-get install jnettop


Usage: jnettop [-hv] [-i interface] [-d filename]
-h, --help display this help message
-v, --version display version information

-c, --content-filter disable content filtering
-d, --debug filename write debug information into file (or syslog)
--display type type of display (curses, text, uia)
-f, --config-file name reads configuration from file. defaults to ~/.jnettop
--format format list of fields to list in text output
-i, --interface name capture packets on specified interface
--local-aggr arg set local aggregation to none/host/port/host+port
-n, --no-resolver disable resolving of addresses
-p, --promiscuous enable promisc mode on the devices
--remote-aggr arg set remote aggregation to none/host/port/host+port
-s, --select-rule rule selects one of the rules defined in config file
by it's name
-t, --timeout sec timeout in seconds after which jnettop ends (text display)
-x, --filter rule allows for specification of custom filtering rule
this follows tcpdump(1) syntax. don't forget to
enclose the filter in quotes when running from shell

Format variable can be CSV (comma separated values), TSV (tab separated values)
or completelly custom format string, where the following identifiers are subst-
ituted when surrounded by '$':
src, srcname, srcport, srcbytes, srcpackets, srcbps, srcpps,
dst, dstname, dstport, dstbytes, dstpackets, dstbps, dstpps,
proto, totalbytes, totalpackets, totalbps, totalpps, filterdata

example:
jnettop --display text -t 5 --format CSV
jnettop --display text -t 5 --format '$srcname$,$srcport$,$dstname$,$dstport$,$totalbps$'

iptraf
apt-get install iptraf

iptraf [ -f ] [ -u ] [ { -i iface | -g | -d iface | -s iface | -z iface |
-l iface } [ -t timeout ] [ -B ] [ -L logfile ] [-I interval] ]

Issue the iptraf command with no parameters for menu-driven operation.
These options can also be supplied to the command:

-i iface - start the IP traffic monitor (use "-i all" for all interfaces)
-g - start the general interface statistics
-d iface - start the detailed statistics facility on an interface
-s iface - start the TCP and UDP monitor on an interface
-z iface - shows the packet size counts on an interface
-l iface - start the LAN station monitor ("-l all" for all LAN interfaces)
-B - run in background (use only with one of the above parameters)
-t timeout - when used with one of the above parameters, tells
the facility to run only for the specified number of
minutes (timeout)
-L logfile - specifies an alternate log file for any direct invocation
of a facility from the command line. The log is placed in
/var/log/iptraf if path is not specified.
-I interval - specifies the log interval for all facilities except the IP
traffic monitor. Value is in minutes.
-f - clear all locks and counters. Use with great caution.
Normally used to recover from an abnormal termination.

-u - allow use of unsupported interfaces as ethernet devices.

RouterVM auf ESXi

Wenn man auf ESXi verschiedene Netzwerke betreiben will, braucht es bekanntlich eine Virtuelle Machine, die Routing beherrscht.
Geeignet wäre da beispielsweise M0n0wall oder für Leute, die es gerne anspruchsvoller haben, Vyatta Core.

Im Grunde ist es ganz einfach. Man plant sich kurz die verschiedenen Interfaces/Netzwerke…

External (WAN):
Netz: 10.10.10.0
Subnet: 255.255.255.0

Optional (DMZ/OPT1):
Netz: 10.20.20.0
Subnet: 255.255.255.0

Trusted (LAN):
Netz: 10.40.40.0
Subnet: 255.255.255.0

Auf VmWare braucht es dafür 3 Virtuelle Switchen, die man direkt per vSphere Client unter Konfiguration -> Netzwerk erstellen kann oder via SSH auf der Konsole:
esxcfg-vswitch -a NAME
Dem external vSwitch weist man dann die physische Netzwerkkarte zu. Es ist zu empfehlen, die Portgruppen nach dem jeweiligen Netzwerk (external, trusted, optional/dmz etc.) zu benennen, damit man nicht in Verwirrung gerät und die Zuordnung der VMs einfacher verläuft.

Zur vereinfachung lege ich noch ein Screenshot bei:
HN1-PXY01 gilt hier als Router – dieser VM werden alle vSwitchen bzw. Portgruppen angebunden, ansonsten gäbs nichts zu routen:
VmWare ESXi
Zur Vergrösserung: Bild Vergrössern

Falls etwas unklar ist, schreibt mir.

IPs mittels Iptables blockieren

Heute hab ich bemerkt, dass wiedermal ein Bot an einem meiner Server klebt und beim Ftp Service standart Users durch probiert. Dies generiert, auch wenn nur eine sehr geringe Menge, unnötigen Traffic und unnötig endlose Logfiles … Obwohl ich fail2ban am laufen hab, was sehr zu empfehlen ist, hab ich Ihn dann doch noch manuell per iptables ausgesperrt.

Oft schon standart mässig installiert:
apt-get install iptables

Anzeigen von bestehenden Chains:
iptables -L
iptables -L CHAIN

Blockieren einer bestimmten source IP auf allen Ports:
iptables -A INPUT -s 11.22.33.88 -j DROP

Herausnehmen der blockierten IP aus Chain:
iptables -D INPUT -s 11.22.33.88 -j DROP

Anlegen einer eigenen Chain:
iptables -N CHAINNAME

Der Nachteil an diesen manuell gesetzen Einträgen ist, dass sie nach einem Neustart verloren gehen. Daher empfiehlt sich, für eine fixe Lösung die iptables Einträge zum Beispiel in der /etc/iptables.conf abzulegen.
echo "iptables -A INPUT -s 11.22.33.88 -j DROP" >> /etc/iptables.conf

Danach in der /etc/network/interfaces zum loopback Interface eine pre-up Zeile hinzufügen:

auto lo
iface lo inet loopback
pre-up /sbin/iptables-restore < /etc/iptables.conf

Diese Lösunge reicht für unseren gebrauch föllig aus, birgt aber trotzdem einige Nachteile. Zudem kann man die Rules nicht einfach aus/einschalten, dafür müsste man sich ein eigenes Init-Script schreiben oder ein bestehendes umschreiben, was mir aber für diese Situation zu aufwenidig wäre.

Wer ausführlich mehr über iptables wissen will Iptables Tutorial 1.2.2@frozentux.net