So far, all we have done is to create a Hyper-V virtual switch and assign an IP address to the corresponding virtual Ethernet adapter. The figure below shows what this command looks like when run. The interface index is the IfIndex that I looked up a moment ago. New-NetIPAddress -IPAddress 10.0.0.1 -PrefixLength 24 -InterfaceIndex 37Īs you can see, this command is relatively straightforward, but you will notice that I had to supply an interface index. Here is an example of how to use this command: The command used to set up the gateway IP address is New-NetIPAddress. Twenty-four is also the most commonly used prefix value for other non-routable addresses such as 192.168.0.x and 172.16.0.x. Using a prefix value of 24 is the same as using a subnet mask of 255.255.255.0. The most commonly used prefix length for the IP address range that I am going to be using is 24. In addition to the IP address, we are also going to need to specify a prefix length. You should use whatever IP address range suits your own needs. Therefore, I am going to use 10.0.0.1 as the gateway IP address. Instead, creating a NAT gateway simply refers to the act of assigning a gateway IP address to the virtual Ethernet adapter that is being used by the newly created NAT virtual switch.īecause we are basing the NAT network around an internal virtual switch, I want to use a non-routable IP address range. In this case, the NAT gateway does not refer to a gateway VM or anything like that. In the world of IT, the term “gateway” can mean a lot of different things. The third step in the process is to create a NAT gateway. If you look at the figure below, you can see my three adapters, and you can see that my NAT adapter’s IfIndex value is 37 (your adapter will probably have a different value). You can find the IfIndex value for the switch that you just created by entering the Get-NetAdapter cmdlet. Hyper-V differentiates between these adapters by using an IfIndex value. There is an adapter for the previously existing virtual switch, another adapter for the physical NIC, and a third adapter that corresponds to the NAT switch that I just created. Hence, my Hyper-V server has three virtual Ethernet adapters. If you go back and look at the figure above, you can see, however, that my host server already had a virtual switch before I created the NAT switch. When you create a Hyper-V virtual switch, Hyper-V will automatically create a virtual Ethernet adapter that corresponds to the virtual switch. Identifying the corresponding virtual Ethernet adapter I then created the new virtual switch, and then ran the Get-VMSwitch cmdlet again, to show that the newly created virtual switch has been added to the list of virtual switches. Here I have used the Get-VMSwitch cmdlet to display a list of the previously existing virtual switches. You can see how this command works in the figure below. New-VMSwitch -SwitchName “NAT” -SwitchType Internal So with that said, here is the command used to create the virtual switch: In this case, I am going to create an internal virtual switch, although I could have just as easily made the virtual switch external. The other piece of information that you will have to provide is the switch type. For the sake of demonstration, I am going to call the virtual switch NAT. First, you are going to have to assign a name to the virtual switch. When you use this cmdlet, there are only two pieces of information that you will need to provide. The cmdlet used for virtual switch creation is New-VMSwitch. Although you can create a virtual switch using the Hyper-V Manager, let’s go ahead and use PowerShell instead. Not surprisingly, the first step in creating a NAT network is to create a Hyper-V virtual switch. In the case of Hyper-V, this connection point is going to be a Hyper-V virtual switch and the underlying virtual Ethernet adapter. It allows a series of non-routable IP addresses to be bound to a single connection point. NAT is the same technology that is used in consumer WiFi routers. Sometimes if you need to create a number of Hyper-V virtual machines (or even containers), it can be helpful to create a Network Address Translation, or NAT network.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |