Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X
Post

How to clone a Linux Physical server or workstation to Hyper-V

So at one particular company, they use Hyper-V (on 2012 R1) to drive their virtualization platform. I used to have problems with Hyper-V since it had poor Linux and BSD support, but that is coming along now.  Major Linux distros are embraced by Microsoft and the Linux Kernel has support, but the tools to convert are lagging.  A little Googling will find that there are some guides using outdated tools that aren’t made by Microsoft. So here is an easier way to do that and save your day:

1. Download Clonezilla and copy the Physical Linux  computer to an img file on an external drive of some sort.  No special options are required if you do disk to image.

2. Create a DYNAMIC partition on Hyper-V that is big enough to absorb the source partition.  If the machine was a 500GB machine, make a 550GB partition and thin provision it.

3. Restore the image file by booting up Clonezilla from the guest host you build in Hyper-V.

4. When done, download GParted and shrink the partition down to whatever size you want.  If you were only using 200GB from my example above, you can shrink down to 300GB if you would like.

5. With the guest machine off, make sure your drive in Hyper-V is a vhdx format, not vhd.  If it is vhd, convert it to vhdx and then, only then, can you shrink the virtual disk down to your Gparted size.

6. As of this posting, Linux and Hyper-V can’t get along with dynamic MAC addresses for nic adapters, set a static MAC to your NICs in your guest linux machine, be ready to setup your nics again on the distro of your choice.  Also, do not use Time-Sync from the hyper-v vitualization tools, as of this posting, it isn’t the most stable and I use ntpupdate rather than tweaking config files, time.nist.gov is a great NTP server to use.

That’s really it, I’m running Kali Linux and CentOS on a Hyper-V advanced cluster

Post

PFSense with transparent bridging (and VMWare)

So I had a hard time setting up PFSense, which is a good, open source firewall, if you put the time into it.  In fact, I’ve used it in critical environments when the ability to get a high end Watchguard or “other” firewall wasn’t an option and have enjoyed its performance, but that’s one guy’s opinion.  Regardless, here’s my project, I hope it helps you out!

- Use PFSense

- Create a public DMZ where I could continue to use my /29 network for servers.  I wanted to host mail, web, and more while running an IPS (Snort) with it.

- All of this is done through virtual switching in VMWare, though would work on a physical switch, too.

 

So, the basic pfsense setup won’t be covered, but here’s what I did after that.  On the VMWare box that was hosting the PFSense, I had a WAN switch, LAN switch, and a DMZ switch, I created one adapter for each switch and bound it to my pfsense box.  The LAN will not be discussed going forward in this article, but nothing special is needed beside rules to allow DMZ –> LAN and LAN –> DMZ.   Also, when creating the DMZ adapter, make sure you choose “None” for the IPv4 configuration.  You need to remember that this is quietly in the middle of the process and that can be confusing for some newer network engineers.  You don’t need an IP address to be a firewall, you just need to be able to stop the packet from continuing. Here’s a really important part for the VMWare users who are using virtual switches, put the VMWare switch in to promiscuous mode on the WAN and DMZ adapters, otherwise the pfsense box will never see all of the traffic it needs or allow traffic in, but not out or vise versa depending on what is promiscuous and what isn’t.

 

 

From there, put your DMZ and WAN into a bridge… This seems a little confusing at first in pfsense, but you need to think about it this way.  Your public devices will be in the DMZ and will be in theory connected to the WAN port, but the pfsense box is sitting in between the DMZ and WAN as a chokepoint between the traffic, think of an hourglass passing sand between the two chambers.

From there, if you create WAN rules pointing from Any –> Public IP, it will control the traffic from passing through due to that hourglass effect.  You do not need to NAT anything because, after all, this is a public IP and you bridged the adapters together.  Just open all the ports you need, but don’t forget to create an outbound rule from the DMZ allowing your traffic out, too.  May I suggest that you just create an allow all from the public ip in the dmz to any for basic t-shooting before you lock everything down for good egress filtering.Once you have it working, you can enable Snort or traffic shaping to get the most out of your bandwidth. Good times!

So, some Q&A that is bound to come up:

 

Q. I read on a ton of sites that a Virtual IP is needed, why not here?

A. Virtual IPs make sense when you are NATing the traffic into the firewall rather than setting up a true DMZ. I think what is lost from training on newer network guys is the difference between NATing and Port Forwarding vs. a public DMZ.  NATing makes sense for a home network where you want to keep that “server” or device on the same network as your LAN, but for the bad guys, putting your public facing servers on your LAN with port forwarding and NATing makes it easier to own the network.  If they can breach the server in the LAN that is part of the port forwarding and NATing setup you would have, then they can attack the LAN.  With the public DMZ, they are stuck there and have to go another hop to get to the LAN.  Back to the original question, if PFSense needs to answer on behalf of the device hiding back in the LAN, the Virtual IP will tell pfsense to field requests to that IP, which isn’t what you want to do, you want your public server to do that.

Q. Is the WAN IP of the pfsense box the gateway for my public device that is in the DMZ or is the upstream router?

A. It’s the upstream router, because remember, the bridge is the chokepoint for traffic and the management will happen there.  If you forward to the WAN IP of the pfsense box, then you are introducing an extra hop because the pfsense box is just going to push it up to the upstream router.  Then when packets come back to your public device, the upstream router will just go the public IP anyway.  The filtering of your traffic will be done quietly and without IPs, so it doesn’t matter where the gateway is because the pfsense is between your public IP host and the default gateway.

Post

Internet Explorer 8 and the iertutil.dll processor loop

So I was banging my head on a client’s machine the other day with a unique error.  IE8 was in a processor loop with iertutil.dll , which I observed using Process Monitor.  I tried the normal repairs of addons being disabled, reinstall IE8, Flash, Java, etc.  Finally, I found what the problem was.  See, the issue only occurred on a page or two and not most pages, that should have been a clue.  The user accidentally turned on “Compatibility Mode” for finance.yahoo.com and whatever code Yahoo through at it through Compatibility Mode caused the loop, just disable it and save yourself the 1hr plus I put into it :)

Post

Acronis issues with backups

So with a client, I was hit with an error in Acronis Backup & Recovery 11 that caused these errors:

ProtectCommand: Failed to execute the command.
Additional info:
——————–
Error code: 41
Module: 307
LineInfo: e6792a5ee190dd9e
Fields: $module : agent_protection_addon_glx_pic
Message: ProtectCommand: Failed to execute the command.
——————–
Error code: 53
Module: 309
LineInfo: 2e7e9e174f1fb746
Fields: $module : agent_protection_addon_glx_pic
Message: TOL cumulative completion result.

The issue with Acronis is that, well, it’s just a bad product now… I used to be a big Acronis fan, but when products break on their own, literally 7 times, on 3 clients without any changes to the server nor backup routine, it’s a bad product.  What happens is the XML files and lock files become corrupt, it won’t talk to that folder anymore because IT BROKE ITSELF!!!!  The best solution is to abandon the backup folder and create a new one, then it doesn’t have to work with the old XML and lock files, then it fires right up and works.

I have never been able to fix Acronis backup jobs that roll over and die, nor has the tech support from Acronis that has logged over 10 man hours in these client machines, they really have no answer why and they just rebuild the backup job from scratch and put it in a new folder, that’s the support for their software… It’s like the PC repair guys at the local town shop that believe in this formula

Customer + computer that has an error that isn’t related to a simple setting = reformat and charge for a system setup

I fully believe that Acronis has a similar banner hanging in the tech support office… /rant

Updating ports through SVN (subversion) instead of csup

So working on a customer’s FreeBSD server this month and being a good admin, I made sure I checked the /usr/ports/UPDATING message for anything of interest.  Lo and behold, the following message:

<snippit start>

20120716:
AFFECTS: Nobody
AUTHOR: [email protected]

The FreeBSD ports tree switched from CVS to Subversion. A Subversion
to CVS exporter is in place to continue the support of CVSup.

</snippit>

Sure enough, I started researching the change and found that there wasn’t a great guide out there (yet), so I have this for all of you:

Changing over to SVN for updating your ports:

1. You’ll want to get SVN installed as root….

cd /usr/ports/devel/subversion && make install clean && rehash

(you can run with the defaults in the config screen)

2. Now I find that deleting the old ports tree that I built over time using csup cleans up any garbage that can be in there (old distfiles you forgot to clean, INDEX-*, and more).  Then I do the following….

rm -rf /usr/ports/ && mkdir /usr/ports && rehash

Keep in mind with root permissions already with you, that the ports directory will automatically be built with the correct permissions.  I through in a rehash because the system hated me twice, on two different servers, for killing the /usr/ports directory and recreating it… the rehash wakes up the system to the change.

3. From here, and this is where I found the instructions distracting… If you are reading this, you probably aren’t a developer, in fact, you just want a fresh copy of the ports tree so you can run portupgrade or whatever method you like to use.  The directions that I found out there require logins and more, but that’s because “you are a developer” from the perspective of the authors…. Our lives our easier than those instructions by using….

svn co svn://svn.freebsd.org/ports/head /usr/ports

The co is just “copy”  and from there, I would do a portupgrade -ar , which will rebuild that INDEX-* file in /usr/ports and correctly continue from where it should as if you did a csup.

4.  So how do you update for new ports????  Simple…

svn update

that’s it…

 

Now, what about updating the /usr/src… I normally don’t do that, I leave that to freebsd-update fetch and freebsd-update install , but if you HAD To rebuild it, it would be:

rm -rf /usr/src/ && mkdir /usr/ports

svn co svn://svn.freebsd.org/base/release/8.2.0 /usr/src   (or whatever release you wanted)

freebsd-update fetch

freebsd-update install

 

Though there isn’t a huge reason for us end users to change, IMO, it is way easier for the developers to make changes and slip in updates, plus, on our end we do enjoy a faster process than csup does for updates.

Post

Windows Server random reboots when Event Log is full due to GPO setting

So while working on a server at one of my clients, I noticed that the server was randomly shutting down with no good explanation.  Here’s a snippit of infomation that I found in the event viewer:

 

Log Name: Security

Source: Microsoft-Windows-Security-Auditing

Date: 12/2/2011 4:44:13 PM

Event ID: 4625

Task Category: Logon

Level: Information

Keywords: Audit Failure

User: N/A

Computer: servername.domain.local

Description:

An account failed to log on.

 

Subject:

Security ID: NULL SID

Account Name: -

Account Domain: -

Logon ID: 0×0

 

Logon Type: 3

 

Account For Which Logon Failed:

Security ID: NULL SID

Account Name: username

Account Domain: DOMAIN.LOCAL

 

Failure Information:

Failure Reason: Unknown user name or bad password.

Status: 0xc000006e

Sub Status: 0×0

 

Process Information:

Caller Process ID: 0×0

Caller Process Name: -

 

Network Information:

Workstation Name: -

Source Network Address: 192.168.1.73

Source Port: 61923

 

Detailed Authentication Information:

Logon Process: Kerberos

Authentication Package: Kerberos

Transited Services: -

Package Name (NTLM only): -

Key Length: 0

 

This event is generated when a logon request fails. It is generated on the computer where access was attempted.

 

The Subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.

 

The Logon Type field indicates the kind of logon that was requested. The most common types are 2 (interactive) and 3 (network).

 

The Process Information fields indicate which account and process on the system requested the logon.

 

The Network Information fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.

 

The authentication information fields provide detailed information about this specific logon request.

- Transited services indicate which intermediate services have participated in this logon request.

- Package name indicates which sub-protocol was used among the NTLM protocols.

- Key length indicates the length of the generated session key. This will be 0 if no session key was requested.

Event Xml:

<Event xmlns=”http://schemas.microsoft.com/win/2004/08/events/event”>

<System>

<Provider Name=”Microsoft-Windows-Security-Auditing” Guid=”{54849625-5478-4994-A5BA-3E3B0328C30D}” />

<EventID>4625</EventID>

<Version>0</Version>

<Level>0</Level>

<Task>12544</Task>

<Opcode>0</Opcode>

<Keywords>0×8010000000000000</Keywords>

<TimeCreated SystemTime=”2011-12-02T22:44:13.352802000Z” />

<EventRecordID>35312462</EventRecordID>

<Correlation />

<Execution ProcessID=”556″ ThreadID=”660″ />

<Channel>Security</Channel>

<Computer>servername.DOMAIN.local</Computer>

<Security />

</System>

<EventData>

<Data Name=”SubjectUserSid”>S-1-0-0</Data>

<Data Name=”SubjectUserName”>-</Data>

<Data Name=”SubjectDomainName”>-</Data>

<Data Name=”SubjectLogonId”>0×0</Data>

<Data Name=”TargetUserSid”>S-1-0-0</Data>

<Data Name=”TargetUserName”>username</Data>

<Data Name=”TargetDomainName”>DOMAIN.LOCAL</Data>

<Data Name=”Status”>0xc000006e</Data>

<Data Name=”FailureReason”>%%2313</Data>

<Data Name=”SubStatus”>0×0</Data>

<Data Name=”LogonType”>3</Data>

<Data Name=”LogonProcessName”>Kerberos</Data>

<Data Name=”AuthenticationPackageName”>Kerberos</Data>

<Data Name=”WorkstationName”>-</Data>

<Data Name=”TransmittedServices”>-</Data>

<Data Name=”LmPackageName”>-</Data>

<Data Name=”KeyLength”>0</Data>

<Data Name=”ProcessId”>0×0</Data>

<Data Name=”ProcessName”>-</Data>

<Data Name=”IpAddress”>192.168.1.73</Data>

<Data Name=”IpPort”>61923</Data>

</EventData>

</Event>

 

Maybe you googled part of that event log and found this… Good news….  Sure enough, I found that the server was shutting down because the event log  was set to shutdown the server once full.  This was due to group policy being enforced and verifying that the event log for system, security, or application (can be a combination of any) was set “Do not overwrite events” in the properties of each log.  Get into your group policy and disable this policy, which is found in Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options

Post

Minecraft Backup

This script is a simple script that will backup by the date, that way, you can put a cron job together that will backup your Minecraft server on a nightly basis.  As my scripting skills are basic, it works, but I’m always open to hearing better methods

 

—-Start Script—-

#!/bin/sh

 

mkdir -p /usr/backups/minecraft/$(date +%d_%m_%Y)

cd /usr/backups/minecraft

cp -R /usr/local/www/minecraft_server /usr/backups/minecraft/$(date +%d_%m_%Y)

tar czf $(date +%d_%m_%Y).tar.gz $(date +%d_%m_%Y)

rm -R $(date +%d_%m_%Y)

 

—-End Script—–

 

Now that backup will run as root, but you can always demote the script from root (I have a  noshell user called minecraft24, then chown the folder in step 1) as there is no reason anything Minecraft should run as root.  That backup script will create subfolders that will be named by the date, backup, tar, and clean itself up so you have a nice backup.  Now, you’ll need a crontab…

 

—Start Crontab—-

SHELL=/bin/sh

PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin

HOME=/var/log

 

30 23 * * * /usr/backups/BackupMinecraft.sh

 

—-End Crontab—-

 

So my crontab runs everyday at 11:30pm Local time… There’s nothing special going on here, but for someone that is new to crontabs and making simple backups, this should be helpful.