Building a SQL Server Virtual Lab in Windows: Virtual Network for the Virtual Lab
JP Chen | | June 11, 2020
In the previous and first blog of this blog series “Building a SQL Server Virtual Lab in Windows,” we had covered Virtualization Concepts. In this blog, we will explore the virtual network for the virtual lab.
Let’s get started!
Like a physical network where the servers need to connect and communicate within the network, the VMs in the virtual lab too need to communicate among themselves via their unique IP addresses along with their subnet mask and default gateway.
IP Address, Subnet Mask, and Default Gateway
Every device connected to a network needs an IP address to communicate. Just like every house in a zip code area has an address to receive mail. Whereas your house address will have numbers and street name, an IP address has four segments called octets that are separated by a dot (.). The numbers with each octet range between 0 and 255. For example:
No other servers or devices on your network can have the same IP address. Just like no other house in your zip code area can have the same address as you do.
The subnet mask subdivides a network into smaller segments and limits the broadcast traffic within a network. For a sending server to send data to a receiving server, the sender needs to know the destination IP address. The destination IP can either be on the same subnetwork as the sender or on other subnetworks. Networks use subnet mask to designate the network boundaries. In the following example, 255.255.255.0 is the subnet mask.
The first three octets in the subnet mask are all 255 indicates that the corresponding numbers in the IP address are static and can’t change. The first three octets of the IP address (192.168.0) designate the network portion of the IP address. The fourth octet of the subnet mask is 0 means that the IP address for a subnet can range from 1 to 254. In other words, any IP address starting with 192.168.0. can have the last octet ranging from 1 to 254 and will belong to the same subnet.
The default gateway in a network will forward the data packets to other networks when no other devices in the same network matches the destination IP address of the data packet. If two devices in different subnet trying to communicate, the default gateway is used as the destination of all traffic. For example, if a server with the IP address of 192.168.0.8 sends a data packet to another server with the IP address of 192.168.2.5, because they are in different subnets all traffic will send to the default gateway. The default gateway through a router will send the data packets correctly to the destination device in a different subnet. It’s like you sending a mail to a different zip code area. The mail truck will need to get on a highway and drive to a different neighbor corresponding to the zip code area of your destination address for the mail. The default gateway always has the last octet as .1. For example, 192.168.0.1 is the default gateway for the 192.168.0 network.
Preferred DNS Server and Alternate DNS Server
A DNS server resolves or translates hostnames to IP addresses as requested. Just like in the old days, where people can look up in a phonebook the contacts they wish to reach out and then find their phone numbers. The Preferred DNS server as the first choice or preferred choice when making DNS requests. If the Preferred DNS server does not respond then the backup, Alternate DNS server, is used.
Note: This is a high-level overview of IP address, subnet mask, default gateway, and DNS server. More in-depth review is beyond the scope of this blog series. However, understanding the basics will become handy in planning and troubleshooting sessions for the SQL DBAs.
Network Connectivity in the Virtual Lab
A network adapter is used for communicating over a network with another computer. The hypervisor software, Oracle VM VirtualBox, allows you to select the network types for a network adapter through networking modes. Each VM can have one or more network adapters. The following are the seven networking modes available:
- Not attached
- Network Address Translation (NAT)
- NAT Network
- Bridged networking
- Internal networking
- Host-only networking
- Generic networking
The three most common options for virtual labs are NAT Network, Bridged networking, and Host-only networking.
NAT Network creates a segregated network comprises of the host computer and guest VMs. All guest VMs can communicate with the host computer and access the Internet through the NIC card of the host computer.
Bridged networking sets up the guest VMs as if they are physical machines just like the host computer on the network.
Host-only networking create a network where the guest VMs are only accessible within the network between the host computer and guest VMs. You can’t access them outside of the host computer.
The virtual lab uses the NAT Network option as shown in Figure 2-3 NAT Network. The DC (DV-DV) and all the three servers running SQL Server 2019 (DV-SQL01, DV-SQL02, and DV-SQL03) are setup and configured within the host computer – your laptop or desktop.
Figure 2-3 NAT Network
IP Properties of the Virtual Lab
In the virtual lab, we will have one Domain Controller (DC) and three servers running SQL Server 2019. You can visualize the physical form of the lab as shown back in Figure 2-3 NAT Network. DV-DC is the DC and DV-SQL01, DV-SQL02, and DV-SQL03 are the three servers connecting to and authenticating through DV-DC. The switch in the virtual lab is an abstract object and Oracle VM VirtualBox handles the network switching. We will go over the concept of a Domain Controller (DC) in a subsequent blog section of this blog series – 2.6 Create the Domain Controller (DC) VM.
Classless inter-domain routing (CIDR) is a method for allocating IP addresses and IP routing. In the virtual lab, we will create a 192.168.0.0/24 network. The IP addresses for each of the VMs are listed back in Figure 2-3 NAT Network. The default gateway is 192.168.0.1. The Preferred DNS Server is 192.168.0.20 (the IP address for the DC where the DNS server role is installed) for all servers except DV-DC. For DV-DC, we will set the Preferred DNS Server to a loopback IP address which is 127.0.0.1. For the Alternate DNS Server for all servers in the virtual lab, we will use Google’s DNS server which is 184.108.40.206.
We will assign static IP addresses for the DC in a subsequent blog section of this blog series – 2.6.7 Assigning Static IP Address for the DC VM and the three SQL Server VMs in 2.8.1 Assigning Static IP Address to the VMs.
In the next blog, I’ll cover software and hardware requirements. Stay tuned!
And please reach out if you’re looking for expert support with your SQL Servers.
Subscribe to Our Blog
Never miss a post! Stay up to date with the latest database, application and analytics tips and news. Delivered in a handy bi-weekly update straight to your inbox. You can unsubscribe at any time.
Most people will encounter this error when their application tries to connect to an Oracle database service, but it can also be raised by one database instance trying to connect to another database service via a database link.
Imagine over 100 logins on the source server, you need to migrate them to the destination server. Wouldn’t it be awesome if we could automate the process?