You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
5.0 KiB
HTML
118 lines
5.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="description" content="This guide covers how to set a KVM bridge network for use with Virtual Machines">
|
|
<meta name="keywords" content="Blog, articles, template">
|
|
<meta name="author" content="Nathan (Aney) Steel">
|
|
<meta name="theme-color" content="white">
|
|
<meta name="theme-color" content="black">
|
|
<link rel="stylesheet" type="text/css" href="/main.css">
|
|
<link rel="icon" type="image/png" href="/images/favicon.svg">
|
|
<title>Setup a bridge network for KVM</title>
|
|
</head>
|
|
|
|
<body>
|
|
<header>
|
|
<h1>Setup a bridge network for KVM</h1>
|
|
<input id="burger-toggle" type="checkbox"/>
|
|
<label class="burger-container" for="burger-toggle"><div class="burger"></div><span class="sr">Burger menu</span></label>
|
|
<hr/>
|
|
<nav>
|
|
<a href="/">home</a>
|
|
<a href="/about.html">about</a>
|
|
<a href="/projects.html">projects</a>
|
|
<a href="/blog/">blog</a>
|
|
<a href="/sitemap.html">misc</a>
|
|
<a href="/support.html">support</a>
|
|
</nav>
|
|
<hr/>
|
|
</header>
|
|
|
|
<main>
|
|
<section>
|
|
<p class="intro">A bridge network is a means to connect/bridge different networks together to act like a single network. In this case, it allows any connections to the bridge network to get their own internal IPs, as if plugged into the network directly, and work as you'd expect a completely new physical PC to work. i.e. Accessble to other clients outside of the host.</p>
|
|
<h2>Install bridge-utils</h2>
|
|
<pre><code>sudo apt install bridge-utils</code></pre>
|
|
|
|
<h2>Find the network to bridge</h2>
|
|
<p>First we need to find the network we want to bridge to the VMs</p>
|
|
<pre><code>ip a</code></pre>
|
|
|
|
<h2>Bridge it</h2>
|
|
<p>This will be familiar to those who have <a href="/guides/set-static-ip.html">set a static ip</a> on linux, as it's essentially the same, with a few additional lines related to bridging</p>
|
|
<p>This can be done by editing <strong>/etc/network/interfaces</strong></p>
|
|
<pre><code>sudo vim /etc/network/interfaces</code></pre>
|
|
<p>And setting the following lines<p>
|
|
|
|
<h3>Change existing port to manual</h3>
|
|
<p>There will already exist some lines with your chosen network adapter, such as</p>
|
|
<pre><code>iface enp2s0 inet auto</code></pre>
|
|
<p>Change this to contain manual instead</p>
|
|
<pre><code>iface enp2s0 inet manual</code></pre>
|
|
|
|
<h3>Static Bridge</h3>
|
|
<p>If you want your server to have a static IP use this</p>
|
|
<pre><code>auto br0
|
|
iface br0 inet static
|
|
bridge_ports enp2s0 # which port(s) to bridge together
|
|
address 192.168.0.100 # Static IP
|
|
netmask 255.255.255.0
|
|
network 192.168.0.1
|
|
broadcast 192.168.0.255
|
|
gateway 192.168.0.1
|
|
bridge_stp off # New
|
|
bridge_fd 0 # New
|
|
bridge_maxwait 0 # New
|
|
dns-nameservers 8.8.8.8 8.8.1.1</code></pre>
|
|
<h3>Dynamic Bridge</h3>
|
|
<p>If instead you wish your server to have a dynamic IP (not recommended). A bridged network can be set, with a dynamic DHCP set IP</p>
|
|
<pre><code>iface br0 inet dhcp
|
|
bridge_ports enp2s0</code></pre>
|
|
|
|
<h2>Create Virtual Network</h2>
|
|
<p>To make it easier to manage with VMs, this new bridge can be made into a Virtual Network.</p>
|
|
<p>Open up a text-editor, and create a file called <strong>bridged-network.xml</strong></p>
|
|
<pre><code>vim bridged-network.xml</code></pre>
|
|
<p>Enter the following, then save</p>
|
|
<pre><code><network>
|
|
<name>bridged-network</name>
|
|
<forward mode="bridge"/>
|
|
<bridge name="br0"/>
|
|
</network></code></pre>
|
|
<p>Then pass the file to virsh net-define</p>
|
|
<pre><code>sudo virsh net-define bridged-network.xml</code></pre>
|
|
<p>Active, and auto-start the new network</p>
|
|
<pre><code>sudo virsh net-start bridged-network</code></pre>
|
|
<pre><code>sudo virsh net-autostart bridged-network</code></pre>
|
|
|
|
<h2>Reload the network</h2>
|
|
<pre><code>sudo systemctl restart networking</code></pre>
|
|
<p>If this creates the bridge, but claims to have failed, restart your PC</p>
|
|
<pre><code>sudo reboot</code></pre>
|
|
|
|
<h3>Check it's there</h3>
|
|
<p>Run another check for networks, and you should now see br0</p>
|
|
<pre><code>ip a</code><pre>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Useful Links</h2>
|
|
<ul>
|
|
<li><a href="https://ostechnix.com/how-to-find-available-network-interfaces-on-linux/">OSTechNix - Find available network interfaces</a></li>
|
|
<li><a href="https://www.cyberciti.biz/faq/how-to-configuring-bridging-in-debian-linux/">CyberCiti - Configure bridging in debian</a></li>
|
|
</ul>
|
|
|
|
</section>
|
|
</main>
|
|
|
|
<footer>
|
|
<hr/>
|
|
<p>Written by <a href="https://aney.co.uk" target="_blank" rel="noopener">@aney</a> with <a href="https://danluu.com/web-bloat/" target="_blank" rel="noopener">web bloat</a> in mind | <a href="https://github.com/Aney/website" target="_blank" rel="noopener">Source Code</a></p>
|
|
</footer>
|
|
</body>
|
|
</html>
|
|
|