vps header 1200x200

3.4 Two Ways to Create a VPS with a Bridge Connection

We have now added a second wired connection device and shortened its name to enx0 using udev. We have also turned off our Wireless network connection. In this article, we will first use the Network Manager Network Connections graphical interface to create a Bridge0 connection. We will then create a new virtual server with VVM - NAT and then replace NAT with Bridge0. Finally, we will create a third virtual server using the Bridge1 connection in the Installation process so that we determine if one bridge creation process is better than the other.

Hardware Needed for Second Ethernet Connection
A bridge connection will capture your normal Ethernet connection on your laptop unless you create a second Ethernet connection on your laptop. The easiest way to create the second Ethernet connection is to convert one of the existing USB3 ports on your laptop into an Ethernet port. This is done by buying a USB3 to Ethernet adapter and plugging the USB3 end of the adapter into your computer Ethernet port. Here is a link to a J5Create USB3 to Ethernet port sold at Best Buy for $20

https://www.bestbuy.com/site/j5create-usb-3-0-to-gigabit-ethernet-adapter-gray/2001047.p?skuId=2001047

01

You will then need an Ethernet Network Switch to connect a separate Ethernet cable to. This switch should be a Plug and Play switch. Here is a link to a TP-Link 5 port switch on Amazon for $14

https://www.amazon.com/gp/product/B00A128S24/ref=ask_ql_qh_dp_hza

TP-Link TL-SG105 5 Port Gigabit Unmanaged Plug and Play Ethernet Network Switch $14 Model TL-SG105

02

Unmanaged switches are plug and play - connect one of the ports to your existing router via Ethernet to receive additional physical Ethernet port connectivity via the switch. Plug and Play means easy setup with no software installation or configuration needed. Some switches require Windows software and passwords. We do not want this. We want a plug and play unmanaged switch.

You also need at least three 10 foot Ethernet Cables ($7 each or 5 pack for $18). A long cable is needed to connect the switch to your router (which may be in a different room). The switch should be in the same room as your laptop. You will then need a second Ethernet cable to connect the switch to your normal Ethernet port on your laptop. Finally, you will need a third Ethernet cable to connect the switch to your USB3 to Ethernet adapter (using a USB3 port on the left side of your laptop).

TIP: use Cat 6e, 7e or 8e Ethernet cables as Cat5e is being phased out and is no longer the standard. A 5 pack of 6e 10 foot cables is $18

Note: Having a 5 port Ethernet switch is also useful if you have several devices in the same room, such as computers, TV monitors or cameras, that each need their own high speed secure Ethernet Internet connection.

Create a Bridge0 Connection with Network Manager Network Connections
We will be using our USB3 to Ethernet device to create our bridge0 connection. At the end of the previous chapter, we shortened the name of this device to enx0. Before we create our new bridge0 connection, we need to make sure that any Wired connections which uses the USB3 to Ethernet device enx0 are not active. Open a terminal on your home computer and type ip addr:

03

The above image shows that we have six devices. The first called lo is a local device. The third wlp3s0 is our laptops wireless device which we have turned off and will not be using. The second device, called eno1, is our laptop's normal Ethernet device. This is automatically set to be used by our Wired connection 1. The fourth device is enx0 which we will use to create our bridge0 connection. The fifth and sixth devices (virbr0) were created when we created our first VPS with VMM. Close the terminal.

Note: If you do not see the virbr0 devices, this means they are turned off. To turn them on, open VMM and click on Edit, Connection Details, Virtual Networks tab and turn on the default network (arrow in lower left) and set it to autostart on boot and click Apply:

04

Then close Connection Details and close VMM.

Turn the USB to Ethernet Device Off

Click on the Network icon in the lower right corner of your Taskbar.

05

Click on the Wired Gigabit Ethernet Device to turn it off. The box should turn from blue to gray. Then click on Network Connections.

06

If you have a Wired connection 3, it was likely created when we shortened the name of our enx0 device. We do not need or want it. To delete it, click on it to select it. Then click on the minus sign at the bottom of the screen. Then click Delete. To see the Wired connection 1 default settings, select it and click on the settings wheel at the bottom of the screen.

07

Wired connection 1 uses the eno1 Ethernet device. Click on the IPv4 tab and you will see that it is set for Automatic (DHCP). Close the Wired connection 1 Edit screen and click on Wired connection 2 to open its Edit screen.

08

Wired connection 2 should use the enx0 device. Use the drop down arrow to change it to this device if needed.

Click on the IPv4 tab and you will see that it is set for Automatic (DHCP). Close the Wired connection 2 Edit screen and click on virbr0 to open its Edit screen.

09

Virbr0 Edit screen opens in a tab called Bridge rather than a tab called Ethernet. It does not have a Device. Instead, it has an interface name which is also called virbr0. Even though it is a Bridge connection, it does not have an Added bridge connection. This is because it was set up by VMM to be a NAT device - which means it uses the normal Ethernet device on your laptop called eno1. Click on the Ipv4 tab.

10

VMM set up virbr0 to have a manual IP assignment. VMM also added a static IP address called 192.168.122.1. VMM left the Gateway box blank because 192.168.122.1 is actually a Gateway address for the network 192.168.122.xxxx. Each NAT VPS created by VMM will be assigned an IP which begins with 192.168.122.___. Close virbr0.

Create a new bridge0 connection

Now that the enx0 device has been turned off and we have a better understanding of our existing connections, let's create a new bridge0 connection. From the Network Connections screen, click on the Plus sign in the lower left corner to create a new connection. Then choose bridge.

11

Click Create.

12

Change the Connection name from Bridge connection 1 to bridge0 so that the connection name and the Interface name are the same. Then click Add.

13

Leave the Type at Ethernet and click Create.

14

For Device, use the drop down arrow to choose enx0. Then click Save.

15

Leave the IPv4 tab set for Automatic (HDCP). Click Save. This returns us to the Network Connections screen:

16

Because bridge0 is now using the enx0 device and because the enx0 device can only be used by one connection, we should now delete Wired connection 2 so that it does not try to steal the enx0 device from bridge0. Select Wired connection 2 and delete it by clicking on the minus sign at the bottom of the screen.

Then click on the bridge0 slave1 connection to open it.

17

Note that it uses enx0. But it does not have an IP address. Close bridge0 slave1 and close the Network Connections screen. Then click on the Network icon to turn the Gigabit Ethernet Device (aka anx0) back on.

18

Restart your laptop. Then open a terminal on your home computer and type ip addr.

19

There are now seven connections. We are only interested in number 4 (enx0) and number 5 (bridge0. Both connections are in the state UP. enx0 has a master called bridge0 and does not have an IP address. bridge0 has the IP 192.168.1.48 which means that it is part of our normal LAN network and VMM should assign normal IP addresses when we use the bridge0 connection instead of NAT.

Create an XML file for our bridge0 connection

For VMM to be able to use our bridge0 connection, we need to create an XML file for it. Open your File Manager and click File System. Then click on the etc folder to open it. Then click on libvirt folder to open it. Then click on the qemu folder to open it. Then click on the networks folder to open it.

20

There is a file called default.xml and a folder called autostart. Right click on the screen and click Open as Root. Then right click again and click Create New Document, Empty document. Call the file bridge0.xml. Then right click on the new file and open this new file with Bluefish. The copy paste the following into the file:

<network>

<name>bridge0</name>

<forward mode="bridge"/>

<bridge name="bridge0" />

</network>

Then click Save and Close and close the file manager. Then open your terminal and copy paste this command:

sudo virsh net-define /etc/libvirt/qemu/networks/bridge0.xml

The terminal should reply;

Network bridge0 defined from /etc/libvirt/qemu/networks/bridge0.xml

Then start the network with this command:

sudo virsh net-start bridge0

It should reply that Network bridge0 started. Then set the network to autostart with each reboot with this command:

sudo virsh net-autostart bridge0

It should reply that Network bridge0 marked as autostarted.

Then to confirm the network status, copy paste this command.

sudo virsh net-list –all

21

Close the terminal and open VMM. Then click on Edit Connection Details, Virtual Networks.

22

Bridge0 has been added to the list of Virtual Networks and set to Active and Autostart on Boot. Close the Connection Details screen. But leave the VMM screen open.

Now that we have an active bridge0 network, we are ready to add it to a VMM VPS. We will review two different ways to add the bridge0 connection to a VPS created by VMM.

Method 1: Create a normal VPS using the default NAT Connection. Then replace the NAT connection with the bridge0 connection.

We will leave our first VPS alone so we can refer back to it if needed.

23

To create a second VPS, click on the gold star. Then Local install and click Forward. Then browse to the Debian 10 iso to select it. Click Forward. Memory OK. Click Forward. Disc Space OK. Click Forward. Change the name to ns02. Then click Finish. This will bring up the Debian installation wizard. Leave it at Graphical Install and press Enter. Then increase the height of the screen so you can see the Continue button at the bottom. Then click Continue. Continue. Continue. Then components will load.

For Configure the network, change the hostname from debian to ns02. Then click Continue. For domain name, type example.com. Then click Continue. Leave the root password blank and click Continue.

Type your name and click Continue. Then type your username and click Continue. Then enter a short and easy to remember password. Type it twice and click Continue. Choose your Time Zone and click Continue. Use Guided entire disk and click Continue. Continue. Continue. Continue. Change Write changes from No to Yes and click Continue. The base system will then be installed.

Leave scan at No. Click Continue. Leave package manager at US. Click continue. Then continue. Then continue. Leave the survey at No and click Continue. Uncheck Desktop and Print and check SSH server. Then click Continue. Leave boot loader set for Yes and then continue. Change device to vda and continue. Then continue to complete the installation. Then log in. Type ip addr. Note that the NAT IP is 192.168.122.xxx (In my case 157).

Type sudo poweroff. Then click on the info circle. Then click on NIC in the side menu.

24

The default network is NAT. Close the VM details screen and close VMM.

Use the File Manager to change the connection from NAT to bridge0.

Open your file manager and click on File System, etc, libvirt, qemu.

You will see two XML files, one for each VPS:

25

Right click on the screen and click Open as Root. Then open ns02.xml with Bluefish. Scroll down to the interface section.

<interface type='network'>

<mac address='52:54:00:79:2f:91'/>

<source network='default'/>

<model type='virtio'/>

<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>

</interface>

We want to change the source network from default to bridge0. But this might also means changing the MAC address. So close this file (but leave the file manager open ) and let's see if we can use VMM to make this change.

Open VMM and click on ns02 to select it. You do not need to start it. Then click on Edit, Virtual Machine Details, info. Then click on Nic in the side menu. Use the drop down menu to change from NAT to bridge0:

26

Then click Apply. The IP address will change to unknown. But the MAC address stayed the same. Now with your file manager, open the ns02.xml file and scroll down to the interface section, line 104. Note that the source network has changed to bridge0. Close the file and the file manager. Then use VMM to start ns02. Click View Console.

Then log in. Type IP address. The IP address for enp1s0 has changed from a NAT address to the local area network address of 192.168.1.xxx (in my case 57). Type sudo poweroff to close ns02.

Method 2:Use the VMM installer to install bridge0.

In the VMM initial screen, click on the gold star to create a new VPS. Then Local install and click Forward. Then browse to the Debian 10 iso to select it. Click Forward. Memory OK. Click Forward. Disc Space OK. Click Forward. Change the name to ns03. Then click Network Selection. Use the drop down to change the network from NAT to bridge0.

27

Then click Finish. This will bring up the Debian installation wizard. Leave it at Graphical Install and press Enter. Then increase the height of the screen so you can see the Continue button at the bottom. Then click Continue. Continue. Continue. Then components will load.

For Configure the network, change the hostname from debian to ns03. Then click Continue. For domain name, type example.com. Then click Continue. Leave the root password blank and click Continue.

Type your name and click Continue. Then type your username and click Continue. Then enter a short and easy to remember password. Type it twice and click Continue. Choose your Time Zone and click Continue. Use Guided entire disk and click Continue. Continue. Continue. Continue. Change Write changes from No to Yes and click Continue. The base system will then be installed.

Leave scan at No. Click Continue. Leave package manager at US. Click continue. Then continue. Then continue. Leave the survey at No and click Continue. Uncheck Desktop and Print and check SSH server. Then click Continue. Leave boot loader set for Yes and then continue. Change device to vda and continue. Then continue to complete the installation. Then log in. Type ip addr.

Sadly, enp1s0 was not assigned an IP address. Type sudo poweroff. Then click on the info circle. Then click on NIC in the side menu.

28

We may be able to fix this problem in the next chapter. For now, close VMM.

What's Next?
We now have three virtual servers. In the next chapter, we will learn how to configure their DNS settings.