My *nix world

Connect to SQL Server KVM guest

So you have a KVM host that have one ore more KVM guests (such as Windows, Linux, Android, you name it) and one KVM guest is a Windows system that have a SQL Server (doesn't matter which edition). You want to be able to connect to SQL Server KVM guest from your LAN and even from the WAN.

There are three things you have to setup:

  • a Linux firewall rule (mandatory if you want to forward traffic)
  • a virtual network on your KVM host that is used by your KVM guests (so even by our Windows - SQL Server)
  • a Windows firewall rule (optional, if you have a running Windows firewall)

Linux firewall rule

First of all, you have to teach your firewall to accept incoming connection to a specific port that you will forward later to your KVM Windows guest:

So in my example your KVM host (the PC that host the KVM guests) have the IP and listen for incoming TCP connection on port 1433. By using the iptables rule listed above you will forward all that traffic that comes to your to another IP:PORT, in my example our Windows KVM guest at

Keep in mind that you might use another unused port for the HOST_PORT. You might use also another port for your KVM_PORT, too, in case that your SQL Server is installed on a different port or if you have a firewall inside Windows that allows you to define a port-forwarding rule so everything that comes in Windows on port-X will be forwarded by Windows through port-Y. This is a separate discussion that is not covered by this article.

KVM virtual network

If you have the Virtual Machine Manager (VMM) installed on your machine then setting a virtual network is straightforward:

  • open your VMM, connect to your KVM host
connect to sql server kvm

click to zoom

  • once connected, right-click your KVM connected host then choose Details menu
  • select "Virtual Networks" tab and add a new network with whatever name you want, with a address space like (or whatever you like), with/without DHCP enabled, that is FORWARDING its connections to a physical device in the ROUTED mode.
connect to sql server kvm

click to zoom

Windows firewall rule

Login to your Windows then go to Control Panel > Windows Firewall. If it's turned on then go to Exceptions tab and new exception rule by clicking "Add port" button:

connect to sql server kvm

click to zoom

That should be sufficient to make it work.

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.
Connect to SQL Server KVM guest

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Tagged on: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *


Get every new post on this blog delivered to your Inbox.

Join other followers: