Tuesday, October 30, 2018

Creating a Fedora 28 Server Linux Router - Part 1

Linux has some very powerful routing capabilities. It is also very performant and it uses very few resources. These, and countless other benefits make it an excellent choice for a router operating system. Choosing a distribution can be a challenge, however.

I have built routers using pfSense, DD-WRT, Ubuntu, Debian, and CentOS. Each of these has pros and cons. pfSense and DD-WRT have web applications that can be used to configure the router. Ubuntu and Debian are easy to get up and running quickly. CentOS has wide support. Fedora has much newer packages available, and also has wide support.

As a side note, Ubuntu is built on top of Debian. CentOS is built on top of Fedora. Debian and Fedora have been around for a very long time, and they have very large numbers of users.

After having created so many different routers, my current favorite is Fedora. It has been very predictable and stable - both are good qualities to have in a router operating system. This article will take you step-by-step through the process of building a router using Fedora.

Prerequisites


Here are my recommended prerequisites. I am just making these up based on past experiences:
  • 16 GB Hard Disk
  • 2 GB RAM
  • 2 CPU Cores
  • 2 Network Cards

Installation


Download and install Fedora Server from https://getfedora.org/en/server/. If you plan on booting from a USB drive, download the Fedora Media Writer from https://getfedora.org/en/workstation/download/. Note that although the page says Download Fedora 28 Workstation, the download link currently points to the Media Writer.


Post Installation Steps


Configure Static IP Address


Fedora 28 stores its network configuration scripts under /etc/sysconfig/network-scripts. For each network card that is detected, a script will be created with the prefix
ifcfg-. For example, my computer has two network cards: eth0 and eth1. eth0 is connected to the public Internet and eth1 is connected to my private network. Two files exist called ifcfg-eth0 and ifcfg-eth1.

To configure an IP address for a given interface, open the appropriate file in a text editor. By default, it is set to use DHCP to obtain an IP address. Add the following entries:

IPADDR=192.168.1.1
PREFIX=24


Install Updates


To install all available updates, type dnf upgrade at the console.






Sunday, October 14, 2018

Ubuntu 18.04 Won't Resolve DNS

DNS Resolution Failure and Fix

I noticed after doing both fresh installations and upgrades of Ubuntu Server 18.04, DNS was either really slow, or it would not resolve at all. The symptoms were random. I searched high and low on the Internet. It took me a long time to find a solution.

By default, when installing Ubuntu, it will create a symbolic link from /etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf. If DNS resolutions are failing, one solution is to remap this link. Point it to to /run/systemd/resolve/resolv.conf instead.  The following commands will move the link:

sudo rm /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

If you are experiencing long delays while performing DNS lookups, the previous commands should resolve the issue. To see what file your symbolic link is pointing to, run the following command.

ls -al /etc/resolv.conf

If it points to /run/systemd/resolve/resolve.conf then it should work just fine.

Thursday, October 19, 2017

Migrating Existing Virtual Machines to NVMe in VMWare Workstation 14

Today, I downloaded a trial version of VMWare Workstation 14. The release notes mention a new "NVMe" hard disk controller. Having had hard disk performance issues in the past, I was excited to try it out. I decided to port one of my development virtual machines to the new controller. I was able to do so successfully. To do this, follow the instructions below:

To begin, "upgrade" the virtual machine hardware version from the Settings tab:



In the wizard, select Workstation 14.x:


Once the virtual machine has been upgraded, ensure the new drivers are loaded into Windows. To do this, add a second hard disk, that uses the NVMe controller. You can delete the hard disk when the upgrade is complete. But, add it for now. Start by clicking, Edit virtual machine settings:

From there, click the Add button:


Choose Hard Disk:


Choose NVMe:


Choose Create a new virtual disk:


If you want the disk to be a single file, be sure to select Store virtual disk as a single file:


Finally, give the disk a name and click the Finish button:



Click the OK button in the Virtual Machine Settings page to save your changes. Turn on the virtual machine. Once it has turned on, log into Windows. In VMWare Workstation, select VM->Upgrade VMWare Tools. A virtual CD will be inserted into the CD-ROM drive. Run the setup.exe program to install the new drivers. Allow the virtual machine to reboot.

Once the virtual machine has rebooted, the new NVMe drivers will have been loaded. At this point, shut down Windows. Then, close the virtual machine in VMWare Workstation. The next step is to hand edit the .vmx file for the virtual machine. Make a backup of the file. Then, open it in a text editor, such as Notepad++.

In the text editor, search for scsi0. Remove all lines for the scsi0 controller. Take note of the name of the hard disk file, you will need it later. It will end with the .vmdk extension. In the screenshot below, mine is BRN-CLIENT02.vmdk:


 Now, scroll to the bottom of the file. You will find the new NVMe hard disk:


Change any occurrences of nvme0:0 to nvme0:1 to make that drive the second hard disk on the NVMe controller. Then, insert your original hard disk on nvme0:0:


Save the file. Open the virtual machine in VMWare Workstation. Boot it up. You are now using the NVMe controller for your hard disk!

NOTE: If you are using shared virtual machines, the VMWare Workstation Server service caches the .vmx file once you load it. Be sure to also stop that service prior to editing the .vmx file. Stopping the service will not shut down any running virtual machines. Start it back up once the file has been modified.




Wednesday, September 7, 2016

Migrating from VMWare Workstation to Hyper-V

My Reason For Migrating From VMWare Workstation to Hyper-V

I am a long-time user of VMWare Workstation. I have been using it since version 6.0. It has been used to run my personal domain controller, my various development computers, and some test environments. Needless to say, I depend heavily on virtualization. I was very disappointed at some news I recently heard about VMWare.

With the announcement of layoffs at VMWare that took place in January, I began forming a plan for the migration to Hyper-V. VMWare later announced they would continue to maintain their products. However, their plan is to completely outsource the development of those products.

Having worked with large companies that have outsourced some of their development, I have learned first-hand how the quality of a product decreases as the development force of that product is moved off site. My decision to move away from VMWare is to ensure that I continue to experience a hypervisor that is considered a first-class citizen by its owners, and will continue to receive the best attention from the most-skilled developers available. It is my experience that this is an objective that is simply not possible when the development of a product is completely outsourced.

This month, I finally completed my migration of over 20 virtual machines. It was a lot of work. Here are some of the challenges I ran into:

Converting the Virtual Machine

  1. The first challenge is to convert the hard disk. I found the easiest method is to do this is to use StarWind V2V Converter. Run it from the command-line, or it will require that there is enough free space for expanded virtual disks - even if they are dynamic.

Note that it was not necessary for me to uninstall VMWare Tools prior to the conversion. I just shut down the guests and ensured there were no snapshots.

Setting Up Networking

The networking set up is not quite so simple if you are using Network Address Translation (NAT). Using Windows 10, it is necessary to set this up using PowerShell:
  1. New-VMSwitch -SwitchName "SwitchName" -SwitchType Internal
  2. New-NetIPAddress -IPAddress <NAT Gateway IP> -PrefixLength <NAT Subnet Prefix Length> -InterfaceIndex <ifIndex>
  3. New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex 24
  4. New-NetNat -Name <NATOutsideName> -InternalIPInterfaceAddressPrefix <NAT subnet prefix>
     

Working With DPI

Windows prevents users from changing DPI settings in a Remote Desktop session. Annoyingly, this also happens to extend to Hyper-V sessions. In order to change DPI, it is necessary to either hack the registry, or to gain access to the console session. I personally prefer the second option.

To gain access to the console session, install TightVNC. After installing the server and setting it up, install the client on another machine. With the client, log into the server. It will then be possible to change DPI settings.

Wednesday, August 10, 2016

Fixing 'Cannot find wrapper assembly for type library "MSHTML"' After Windows 10 Upgrade

I received the Anniversary update to Windows 10 last week. After doing so, a solution I work on in Visual Studio 2013 would no longer compile.

Visual Studio showed multiple errors along the lines of "Metadata file xxxx.dll could not be found."

Thinking there was more to this than meets the eye, I navigated to Tools->Options. From there, I selected "Projects and Solutions->Build and Run." I increased the MSBuild logging to Normal:



Then, I ran the build and copied the "Output" tab to Notepad++. I searched for "Build Failed" and ran into this line:

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(2234,5): warning MSB3283: Cannot find wrapper assembly for type library "MSHTML". Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform must not be 64-bit.

Thinking that was a bit odd, I opened the references to the project and noticed there was a yellow exclamation mark next to MSHTML. So, I opened the project on my Windows 8.1 virtual machine, and noticed the reference was pointing to an ActiveX control that was registered from a file sitting in the Global Assembly Cache:



Curioius, I wanted to check if this file was in the GAC on my Windows 10 machine. I opened an instance of "Developer Command Prompt for VS2013" (Right-click, Run as Administrator), and entered the following command:
gacutil /l | find "Microsoft.mshtml"
I received a positive hit:


So, I then navigated to C:\Windows\assembly\GAC\Microsoft.mshtml and typed dir to see what folders were there:



I then went into the "7.0.3300.0__b03f5f7f11d50a3a" folder. From there, I registered the assembly using the regasm command:

regasm Microsoft.mshtml.dll



And now my solution compiles once again! Problem solved.