With OVHcloud Additional IPs, connecting your virtual machines to the Internet can be a breeze. Follow this tutorial to connect your VM to the Internet in VMware ESXi.
Requirements
- How to Create a VM in VMware ESXi
- Dedicated Server running VMware ESXi
- Additional IP through OVHcloud
Topics
- Creating a Virtual MAC for an Additional IP in the OVHcloud Control Panel
- Adding a Virtual MAC to the Virtual Machine's NIC in ESXi
- Configuring Network Settings
Instructions
Creating a Virtual MAC for an Additional IP in the OVHcloud Control Panel
In this section, we will be creating a VMAC (virtual MAC address) to be used by the NIC (Network Interface Card) that ESXi assigns to a VM. To begin, log in to the OVHcloud Control Panel. On the left-hand sidebar click the Network option.
Next, click Public IP Addresses.
Choose the additional IP you wish to configure to your VM and click the ellipses (...) button next to it. Then, select the Add a virtual MAC option from the drop-down menu.
In the popup menu, change the "Type" to "vmware" and enter the name of your virtual machine.
Adding a Virtual MAC to the Virtual Machine's NIC in ESXi
In this step, we will be pairing the vMAC, which we generated in the& first section, to the interface that ESXi has assigned to the VM. To complete this step, your VM must be powered off.
In ESXi, right-click your VM and select the Edit settings option from the drop-down menu.
Then, select the drop-down next to "Network Adapter 1" and change the "MAC Address" field to Manual. Enter the vMAC created in the OVHcloud Control Panel into the "MAC Address" field.
Start your VM as you are now ready to configure the network interface. In the next step, we will be configuring network settings within the OS of our VM. These steps can be different depending on the OS you are using. Click the correct link below to take you to instructions for your OS of choice:
Configuring Network Settings
In this step, we will be configuring our interface settings. To do this, you must first open your interface configuration file. Do so in a text editor of your choice using the following command:
$ sudo vi /etc/network/interfaces
Edit the interfaces file to make it appear as follows:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto ens192 iface ens192 inet static address 192.0.2.1 netmask 255.255.255.255 gateway 203.0.113.254 dns-nameservers 208.67.222.222 208.67.220.220
In this file, replace the following pieces of information as instructed:
- 1. If you don't know the name of your interface, you can find it using the following command:
$ ip add
- 2. Next to "address", replace "192.0.2.1" with the additional IP to which you have added the vMAC in the OVHcloud Control Panel.
- 3. Next to "gateway", replace the "203.0.113" with the first three octets of your Dedicated Server's IP address with a final octet of "254". For instance, if your Dedicated Server IP was 1.2.3.4, you would use 1.2.3.254 as your gateway.
- 4. The DNS name servers listed are from OpenDNS. Feel free to use other name servers if you choose.
Now you will need to bring your NIC online. To do so, enter the following command:
$ sudo ip link set ens192 up
Finally, restart your networking service using the following command:
$ sudo systemctl restart networking
To test that the VM is fully connected to the Internet, ping example.com. If you get a response, you are good to go. If you do not, restart your VM and attempt the ping again.
Canonical, the developer of Ubuntu, implemented the use of Netplan for easy-to-use network configuration as of version 17.x.
To configure the network interface, open the 01-netcfg.yaml
file in a text editor of your choice using the following command:
$ sudo vi /etc/netplan/01-netcfg.yaml
Edit the file to make it appear as follows:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network: version: 2 renderer: networkd ethernets: ens160: dhcp4: no dhcp6: no addresses: [192.0.2.1/32] gateway4: 203.0.113.254 nameservers: addresses: [208.67.222.222,208.67.220.220] routes: - to: 203.0.113.254/32 via: 0.0.0.0 scope: link
In this file, replace the following pieces of information as instructed:
- 1. If you replace the VMXNET3 NIC with another one, your NIC may use a different naming convention. If it does, replace "ens160" in the file with the name of your interface. If you don't know the name of your interface, you can find it using the following command:
$ ip add
- 2. Next to "addresses", replace "192.0.2.1" with the additional IP to which you have added the vMAC in the OVHcloud Control Panel plus the subnet you wish to use in CIDR notation.
- 3. Next to "gateway4" and in the "routes" section, replace the "203.0.113" with the first three octets of your Dedicated Server's IP address with a final octet of "254". For instance, if your Dedicated Server IP was 1.2.3.4, you would use 1.2.3.254 as your gateway.
- 4. The DNS name server addresses listed are from OpenDNS. Feel free to use other name servers if you choose.
Now apply the Netplan settings with the following command:
$ sudo netplan apply
To test that the VM is fully connected to the Internet, ping example.com. If you get a response, you are good to go. If you do not, restart your VM and attempt the ping again.
In this step, we will be configuring our interface settings. To do this, you must first open your interface configuration file. Do so in a text editor of your choice using the following command:
$ sudo vi /etc/network/interfaces
Edit the interfaces file to make it appear as follows:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto ens160 iface ens160 inet static address 192.0.2.1 netmask 255.255.255.0 gateway 203.0.113.254 dns-nameservers 208.67.222.222 208.67.220.220
In this file, replace the following pieces of information as instructed:
- 1. If you don't know the name of your interface, you can find it using the following command:
$ ip add
- 2. Next to "address", replace "192.0.2.1" with the additional IP to which you have added the vMAC in the OVHcloud Control Panel.
- 3. Next to "gateway", replace the "203.0.113" with the first three octets of your Dedicated Server's IP address with a final octet of "254". For instance, if your Dedicated Server IP was 1.2.3.4, you would use 1.2.3.254 as your gateway.
- 4. The DNS name servers listed are from OpenDNS. Feel free to use other name servers if you choose.
Now you will need to bring your NIC online. To do so, enter the following command:
$ sudo ip link set ens160 up
Finally, restart your networking service using the following command:
$ sudo systemctl restart networking
To test that the VM is fully connected to the Internet, ping example.com. If you get a response, you are good to go. If you do not, restart your VM and attempt the ping again.
In this step, we will be configuring our interface settings. To do this, first navigate to the network-scripts
directory using the following command:
$ cd /etc/sysconfig/network-scripts
Use the ls
command to view the content of the directory.
$ ls -al
Locate your interface file (e.g. ifcfg-ensXXX) and then open it in a text editor of your choice using the following command:
ifcfg-ens192
.$ sudo vi ifcfg-ens192
Edit the interfaces file to make it appear as follows, changing only what is in red:
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens192 UUID=*DO NOT edit this field!* DEVICE=ens192 ONBOOT=yes IPADDR=192.0.2.1 NETMASK=255.255.255.0 GATEWAY=203.0.113.254 DNS1=208.67.222.222 DNS2=208.67.220.220
In this file, check/replace/add the following pieces of information as instructed:
- For "IPADDR", replace "192.0.2.1" with the additional IP that you added a vMAC to in the OVHcloud Control Panel.
- For "GATEWAY", replace the "203.0.113" with the first three octets of your Dedicated server's IP address with a final octet of "254". For instance, if your Dedicated server's IP was 1.2.3.4, you would use 1.2.3.254 as your gateway.
Next, enable the NIC by restarting the network service:
$ sudo systemctl restart network
To test that the VM is fully connected to the Internet, ping example.com. If you get a response, you are good to go. If you do not, restart your VM and attempt the ping again.
In this step, we will be configuring our interface settings. To do this, first navigate to the network-scripts
directory using the following command:
$ cd /etc/sysconfig/network-scripts
Use the ls
command to view the content of the directory.
$ ls -al
Locate your interface file (e.g. ifcfg-ethX) and then open it in a text editor of your choice using the following command:
ifcfg-eth0
.$ sudo vi ifcfg-eth0
Edit the interfaces file to make it appear as follows, changing only what is in red:
DEVICE=eth0
HWADDR=*Verify this matches the vMAC created and assigned to the VM!*
TYPE=Ethernet
UUID=*DO NOT edit this field!* ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none IPADDR=192.0.2.1 NETMASK=255.255.255.0 GATEWAY=203.0.113.254 DNS1=208.67.222.222 DNS2=208.67.220.220
In this file, check/replace/add the following pieces of information as instructed:
- For "IPADDR", replace "192.0.2.1" with the additional IP that you added a vMAC to in the OVHcloud Control Panel.
- For "GATEWAY", replace the "203.0.113" with the first three octets of your Dedicated server's IP address with a final octet of "254". For instance, if your Dedicated server's IP was 1.2.3.4, you would use 1.2.3.254 as your gateway.
Next, create a new file, route-eth0
, in the /etc/sysconfig/network-scripts/
directory and define the following default routes for the interface using the gateway we defined above:
$ sudo vi /etc/sysconfig/network-scripts/route-eth0
203.0.113.254 dev eth0 default via 203.0.113.254 dev eth0
Lastly, enable the NIC by restarting the network service:
$ sudo /etc/init.d/network restart
To test that the VM is fully connected to the Internet, ping example.com. If you get a response, you are good to go. If you do not, restart your VM and attempt the ping again.
In this step, we will be configuring our interface settings. To do this, navigate to the Server Manager. From the left-hand column, click the Local Server option.
By default, the "Ethernet0" option will read, IPv4 address assigned by DHCP, IPv6 enabled. This is exactly what we want to change, so click on this text.
Next, right-click on Ethernet0 and select the Properties option from the drop-down menu. From the ensuing menu, double-click the Internet Protocol Version 4 (TCP/IPv4) option.
This will allow you to configure your interface to use the IP address, gateway, and DNS name servers of your choice. Configure it as follows:
In this file, replace the following pieces of information from the picture as instructed:
- 1. Next to "IP address", replace "203.0.113.32" with the additional IP to which you have added the vMAC in the OVHcloud Control Panel.
- 2. Next to "Subnet mask", replace "255.255.255.248" with the correct netmask depending on the size of the block of IPs you have purchased. For instance, if you are using a /28 block, put "240" in the last octet.
- 3. Next to "Default gateway", replace the "147.135.0.254" with the first three octets of your Dedicated Server's IP address with a final octet of "254".
- 4. The DNS nameservers listed are from OpenDNS. Feel free to use other name servers here, if you choose.
Click OK after making these changes. To test that the VM is fully connected to the Internet, ping example.com. If you get a response, you are good to go. If you do not, restart your VM and attempt the ping again.
Conclusion
Connecting your VM to the Internet is an essential task before it can be used as a web server, a mail server, or whatever other use you have in mind. Having read this article, you should be familiar with the first steps that are required to connect a VM to the Internet using VMware ESXi.