Merge branch 'feature/guideContinuation' into develop

master^2
Nathan Steel 3 years ago
commit 8bf509d823

@ -4,7 +4,6 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="To avoid using an IP, this guide will help you point your domain name at your server.">
<meta name="keywords" content="Blog, articles, news, DNS, domain, server">
<meta name="author" content="Nathan (Aney) Steel">
<meta name="theme-color" content="white">
<meta name="theme-color" content="black">
@ -33,28 +32,26 @@
<main id="main">
<section>
<p class="intro">To avoid needing to remember an IP, this guide will help to link your domain name to your server.</p>
<p class="intro">To avoid needing to remember an IP, this guide will help to link your domain name to your server. It assumes you have already <a href="/guides/get-a-domain-name">attained a domain name</a>.</p>
<h2>Login to your domain name registrar</h2>
<p>Login to the registrar, and select the domain name you want to point at your server.</p>
<h2>Find the section for DNS</h2>
<p>The domain name should have a section named, "DNS", "Custom DNS records", or something similar to this. Find, and open it, there should be a bunch of boxes and an option to add a new record</p>
<p>The domain name should have a section named, "DNS", "Custom DNS records", or something similar to this. Find, and open it, there should be a bunch of boxes and an option to add a new record.</p>
<h2>Add the A record</h2>
<p>There will likely be many option for adding records, but all we need is to add a singular A record</p>
<p>Find the box that allows you to "Add a new record" and input the below, changing <IP> and <DOMAIN> with your IP address, and domain name</p>
<pre><code></code></pre>
<p>Find the box that allows you to "Add a new record" and input the below, changing <IP> and <DOMAIN> with your IP address, and domain name.</p>
<p>If there are not multiple boxes, but instead a single box to input your record into, this will be what you add instead</p>
<pre><code></code></pre>
<pre><code>&lt;DOMAIN&gt; A 86400 &lt;IP&gt;</code></pre>
<h2>Wait for propagation</h2>
<p>Now there's a bit of a waiting game, as you need to wait for the new DNS record to propagate (get updated) for all nameservers. This can be anywhere from instantly to 72 hours, but typically takes an hour or two.</p>
<h3>Check your domain has propagated</h3>
<p>Pinging the domain name will let you know when the IP has propagated, as when the ping command shows your IP, you're all set</p>
<p>Pinging the domain name will let you know when the IP has propagated, as when the ping command shows your IP, you're all set.</p>
<pre><code>ping -c 3 domainname.com</code></pre>
</section>
</main>

@ -36,42 +36,38 @@
<p class="intro">PHP is one of the highest used programming languages for websites, and it allows you to add practically any functionality you'd ever want to your sites.</p>
<h2>Install</h2>
<pre><code>sudo apt install php-fpm php-mysql</code></pre>
<h2>Um, I forgor</h2>
<pre><code>sudo nano /etc/php/<VERSION>/fpm/php.ini</code></pre>
<p>Comment the cgi.fix_pathinfo line, to look like below</p>
<pre><code>#set cgi.fix_pathinfo = 0</code></pre>
<pre><code>sudo apt install php-fpm</code></pre>
<p>If you want to work with mysql, then you also need to install <strong>php-mysql</strong>.
<h2>Add to Website's NGINX conf</h2>
<p>For each website you want to use php, you'll need to edit the confige file</p>
<p>For each website you want to use php, you'll need to edit the config file.</p>
<pre><code>sudo vim /etc/nginx/sites-available/<WEBSITE></code></pre>
<p>The following code needs adding within the XXX block</p>
<p>The following code needs adding within the <strong>server</strong> block.</p>
<pre><code>location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php<VERSION>-fpm.sock;
fastcgi_pass unix:/run/php/php&lt;VERSION&gt;-fpm.sock;
}</pre></code>
<p>This will use nginx's fastcgi-php.conf snippet which is more secure by deafult than many other php/nginx configs because it 404s if the files doesn't exist. Read Neal Poole's<a href="https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/" target="_blank" rel="noopener">Don't trust the tutorials</a> for more info.</p>
<p>This will use nginx's fastcgi-php.conf snippet which is more secure by default than many other php/nginx configs because it 404s if the requested file doesn't exist. Read Neal Poole's <q><a href="https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/" target="_blank" rel="noopener">Don't trust the tutorials</a></q> for more info.</p>
<h2>Reload NGINX</h2>
<pre><code>sudo systemctl reload nginx</code></pre>
<h2>Test it works</h2>
<p>Create a PHP file e.g. <strong>filename.php</strong> in the website's directory, and add the snippet below into it</p>
<pre><code><?php phpinfo(); ?></code></pre>
<p>Create a PHP file e.g. <strong>filename.php</strong> in the website's directory, and add the snippet below into it.</p>
<pre><code>&lt;?php phpinfo(); ?&gt;</code></pre>
<p>Go to that webpage in your browser e.g. <strong>domain.co.uk/filename.php</strong>, and if php is working you should see a dump of your PHP's version, headers, etc.</p>
<h2>Make nginx use index.php as homepage/root</h2>
<p>Now we'll set nginx to load up index.php as the root of the website, if it exists. Open the site's config with an editor</p>
<p>Now we'll set nginx to load up index.php as the root of the website, if it exists. Open the site's config with an editor.</p>
<pre><code>vim /etc/nginx/sites-available/<WEBSITE></code></pre>
<p>Change the index line to read as below. This will then tell the server to load index.php, and if it doesn't exists, load index.html in it's stead</p>
<p>Change the index line to read as below. This will then tell the server to load index.php, and if it doesn't exists, load index.html in its stead.</p>
<pre><code>index index.php index.html</code></pre>
</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>
<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>

@ -50,10 +50,10 @@
chmod 755 /var/www/html/adminer.php</code></pre>
<h2>Access it</h2>
<p>Head to your <WEBSITE/IP>/adminer.php, and you should load into the adminer login. Using your mysql/mariaDB credentials, you can then login, and use the GUI to manage your database(s)</p>
<p>Head to your <strong>&lt;WEBSITE/IP&gt;/adminer.php</strong>, and you should load into the adminer login. Using your mysql/mariaDB credentials, you can then login, and use the GUI to manage your database(s)</p>
<h2>Make it a directory, not a file</h2>
<p>Instead of accessing /adminer.php?<ARGUMENTS>, we can make it look like /adminer/<ARGUMENTS></p>
<p>Instead of accessing <strong>/adminer.php?&lt;ARGUMENTS&gt;</strong>, we can make it look like <strong>/adminer/&lt;ARGUMENTS&gt;</strong></p>
<pre><code>location /adminer/ {
root /var/www/html ;
try_files $uri $uri/ /adminer/index.php/$is_args$args ;
@ -62,16 +62,16 @@ chmod 755 /var/www/html/adminer.php</code></pre>
<h2>Password Protect</h2>
<p>An additional level of security, just in case. Using Htaccess, any file, or directory can be password protected</p>
<pre><code>sudo apt install apache2-utils
htpasswd -c /home/<USER>/.htpasswd admin</code></pre>
htpasswd -c /home/&lt;USER&gt;/.htpasswd admin</code></pre>
<h3>Add to location</h3>
<p>Add the location of the auth file to the adminer location block</p>
<pre><code>auth_basic "Adminer" ;
auth_basic_user_file /home/<USER>/.htpasswd ;</code></pre>
auth_basic_user_file /home/&lt;USER/&gt;.htpasswd ;</code></pre>
<p>They block should look like below</p>
<pre><code>location /adminer/ {
auth_basic "Adminer" ;
auth_basic_user_file /home/<USER>/.htpasswd ;
auth_basic_user_file /home/&lt;USER&gt;/.htpasswd ;
root /var/www/html ;
try_files $uri $uri/ /adminer/index.php/$is_args$args ;
}</code></pre>

@ -59,8 +59,7 @@
<pre><code>rsync -auv $USER@$HOST:$BACKUP $RESTORE</code></pre>
<h2>Notes/Advanced</h2>
<pre><code>
-r recursive. All files/directories in the path will be backed up
<pre><code>-r recursive. All files/directories in the path will be backed up
-a archive mode. Recursive, but with file permissions, symlinks, etc retained.
-z compress
-b backups

@ -4,7 +4,6 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A basic guide on how to purchase a domain name">
<meta name="keywords" content="Blog, articles, news, domain name, website">
<meta name="author" content="Nathan (Aney) Steel">
<meta name="theme-color" content="white">
<meta name="theme-color" content="black">
@ -33,19 +32,19 @@
<main id="main">
<section>
<p>A domain name, as many will know is what people typing into their browser, e.g. google.com, facebook.com, etc.</p>
<p>The primary use for these is to have a memorable thing for users, instead of needing to type the IP address of the server</p>
<p>A domain name, as many will know is what you type into a browser to access a website. Without a domain name, everyone accessing your server/website would need to be entering the IP address.</p>
<h2>Choose a registrar</h2>
<p>First thing is to choose a registrar (who you are leasing the domain from). You can search for "domain name registrars" and find who is cheapest. So long as they handle DNS (which all I've used do) you're good.</p>
<p>First thing is to choose a registrar (who you are leasing the domain from). You can search for "domain name registrars" and find who is cheapest. So long as they handle DNS (which most do) you're good.</p>
<p>I'm currently using <a href="https://tsohost.com" target="_blank" rel="noopener" >tsohost.com</a>, as they're pretty cheap, and besides a few little issues, it works for me.</p>
<h2>Choose a domain name</h2>
<p>On the registrar's website there will be a section to purchase a domain. Upon clicking this you'll likely be greeted with a searchbar, search for whatever domain you'd like here, and they'll let you know if it's available, and what similar domains there are</p>
<p>On the registrar's website there will be a section to purchase a domain. Upon clicking this you'll likely be greeted with a searchbar, search for whatever domain you'd like here, and they'll let you know if it's available, and what similar domains there are.</p>
<p>Select the domain(s) you wish, and add it/them to your cart.</p>
<h2>Purchase your domain name</h2>
<p>Simply checkout, and make your way through the process</p>
<p>Simply checkout, and make your way through the process. Tada, you now have a domain name!</p>
<p>Next up you'll need to <a href="/guides/add-domain-to-server">link your server and domain name</a> with DNS.</p>
</section>
</main>

@ -34,28 +34,36 @@
<main id="main">
<section>
<p class="intro">If you want to start getting into server hosting, system administration, or just want to get a basic minecraft/web server up for you and your friends, then welcome. We all start somewhere, and I would love if I could get your foot in the door.</p>
<h2>Notice</h2>
<p>This is heavily a WIP, so I'll be adding to this guide whenever I get time, and will update it's readibility, and correct/add anything missing once it's 'complete'. If I didn't put it up in an unfinished state, it would never go live, so bear with.</p>
<h2>Basic Server setup</h2>
<ul>
<li>Get a server and <a href="/guides/server-install-debian.html">Install Debian</a></li>
<li><a href="/guides/initial-server-setup.html">Basic Debian Server setup (with some security)</a></li>
<li>TODO:<a href="/guides/get-a-domain-name.html">Get a domain name</a></li>
<li><a href="/guides/get-a-domain-name.html">Get a domain name</a></li>
<li><a href="/guides/add-domain-to-server.html">Connect your server and domain name</a></li>
<li>TODO:Port Forwarding (home server)</li>
</ul>
<p>Now you officially own, and have setup a server. Currently all you can do is SSH into it though, so let's get some services on there</p>
<h2>Virtualisation</h2>
<p>Virtual machines allow you to use your server as multiple servers at once, with different operating systems, services, files, etc. If you're self-hosting this is a great way to separate concerns, having one system for each distinct task.</p>
<ul>
<li><a href="/guides/setup-qemu-kvm.html">Setup Qemu/KVM</a></li>
<li><a href="/guides/setup-kvm-bridge.html">Setup a bridged adapter</a></li>
<li>TODO:<a href="/guides/install-kvm-virtual-machine.html">Install a virtual machine</a></li>
<li>TODO:<a href="/guides/kvm-optimisation.html">Optimisate KVM Virtual Machines</a></li>
<li>TODO:<a href="/guides/virsh-cheatsheet.html">Virsh cheatsheet</a></li>
<li><a href="/guides/vm-seperation-of-concerns">Example of Separation of Concerns (SoC)</a></li>
</ul>
<h2>Nginx Webserver</h2>
<p>A great first service for any server is a website, even if it's just a little page to let people know you own the server/domain name</p>
<ul>
<li><a href="/guides/nginx-install.html">Install nginx</a></li>
<li><a href="/guides/setup-nginx-website.html">Setup an nginx website</a></li>
<li><a href="/guides/certbot-ssl.html">Add an SSL certificate w/Certbot</a></li>
<li><a href="/guides/nginx-web-optimisation.html">TODO: Nginx web optimisation</a></li>
<li>TODO:<a href="/guides/add-php-to-nginx.html">(Optional) Add PHP to your webserver</a></li>
<li>TODO:Guide to front-end web development</li>
<li>TODO:<a href="/guides/nginx-web-optimisation.html">Nginx web optimisation</a></li>
<li><a href="/guides/add-php-to-nginx.html">(Optional) Add PHP to your webserver</a></li>
</ul>
<h2>MariaDB Database</h2>
@ -63,63 +71,33 @@
<ul>
<li><a href="/guides/install-mysql-mariadb.html">Install mariaDB</a></li>
<li>TODO:<a href="/guides/sql-cheatsheet.html">SQL cheatsheet</a></li>
<li>TODO:<a href="/guides/adminer-setup.html">(Optional) Adminer setup</a></li>
<li><a href="/guides/adminer-setup.html">(Optional) Adminer setup</a></li>
<li>TODO:<a href="/guides/backup-mysql-mariadb.html">(Optional) Backup databases</a></li>
</ul>
<h2>Backup your server!</h2>
<p>Backups are super useful. If something breaks, or gets accidentally deleted you can always use a backup to get it back</p>
<ul>
<li>TODO:<a href="/guides/backup-with-rsync.html">Backup with rsync</a></li>
<li><a href="/guides/backup-with-rsync.html">Backup with rsync</a></li>
<li>TODO:<a href="/guides/backup-with-rdiff.html">Backup with rdiff-backup</a></li>
<li>TODO:<a href="/guides/backup-with-cron.html">Setup backup cronjob(s)</a></li>
</ul>
<h2>Run virtual machines</h2>
<p>Virtual machines allow you to use your server as multiple servers at once, with different operating systems, services, files, etc. If you're self-hosting this is a great way to separate concerns, having one system for each distinct task.</p>
<ul>
<li>TODO:<a href="/guides/setup-qemu-kvm.html">Setup Qemu/KVM</a></li>
<li>TODO:<a href="/guides/setup-kvm-bridge.html">Setup a bridged adapter</a></li>
<li>TODO:<a href="/guides/install-kvm-virtual-machine.html">Install a virtual machine</a></li>
<li>TODO:<a href="/guides/virsh-cheatsheet.html">Virsh cheatsheet</a></li>
<li>TODO:<a href="/guides/vm-seperation-of-concerns">Example of Separation of Concerns (SoC)</a></li>
<li><a href="/guides/backup-with-cron.html">Setup backup cronjob(s)</a></li>
</ul>
<h2>Additional services/potential guides</h2>
<p>Unless there is an anchor, these are all "TODO", and may just be omitted from this list</p>
<h3>Useful tidbits</h3>
<ul>
<li><a href="/guides/nginx-proxy.html">Proxy services with NGINX proxy pass</a></li>
<li><a href="/guides/password-protect-webpage.html">Password protect webpages</a></li>
<li>TODO:<a href="/guides/nginx-proxy.html">Proxy services with NGINX proxy pass</a></li>
<li>TODO:<a href="/guides/password-protect-webpage.html">Password protect webpages</a></li>
</ul>
<h3>Additional Services</h3>
<ul>
<li><a href="/guides/setup-git-server.html">git</a></li>
<li>samba</li>
<li>Open Media Vault</li>
<li>umami</li>
<li>uptime kuma</li>
<li>Uptime Kuma</li>
<li>torrentbox</li>
<li>jellyfin</li>
<li>Jellyfin</li>
<li>VPN</li>
<li>mailserver</li>
<li>Host client websites</li>
</ul>
<h3>Game Servers</h3>
<ul>
<li>minecraft</li>
<li>terraria</li>
<li>factorio</li>
</ul>
<h3>Additional guides</h3>
<p>These are some guides for specific use-cases, that will aid with setting up
<ul>
<li>Basic Homeserver for a web developer/designer</li>
</ul>
</section>

@ -40,6 +40,20 @@
<h2>Install with virt (CLI)</h2>
<h2>Install with virt-manager (GUI)</h2>
By default virsh lists vms belonging to user
virsh --connect qemu:///system list --all
The above run as root shows all vms
For virtmanager, etc to controll vms from an remote host
It needs ssh-key shared
If a different port, then use virt-manager -c 'qemu+ssh://myuser@192.168.1.139:2222/system?keyfile=id_rsa'
e.g.
virt-manager -c 'qemu+ssh://nathan@aney.co.uk:2020/system?keyfile=id_rsa'
</section>
</main>

@ -40,15 +40,20 @@
<h2>Secure Install/Setup</h2>
<pre><code>sudo mysql_secure_installation</code></pre>
<p>Run the above command, and follow the instructions, if you don't want to then follow mine.</p>
<p>Press enter for the current password, and again when asked if you want to set a root password. Enter the password, then press enter for everything else.
<h2>Create Admin user</h2>
<pre><code>sudo mysql</code></pre>
<pre><code>GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;</code></pre>
<pre><code>GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY '&lt;DESIRED_PASSWORD&gt;' WITH GRANT OPTION;</code></pre>
<pre><code>FLUSH PRIVILEGES;</code></pre>
<pre><code>exit;</code></pre>
<h2>Test it works</h2>
<p>Simply try logging in as the admin account.</p>
<pre><code>mysql -u admin -p</code></pre>
<p>It should ask for a password, so enter your <strong>DESIRED_PASSWORD</strong>, and if you get mysql access, it's successful.</p>
<h2>(Optional) Make it easier to access on command line</h2>
<p>If you're working with a terminal, when calling <code>mysql</code> you'll need to enter a password each time. You can store the passwordwith a special .cnf file, making it faster to get into writing SQL.</p>
@ -56,9 +61,9 @@
<pre><code>vim ~/.my.cnf</code></pre>
<p>Add the following, with your credentials</p>
<pre><code>[mysql]
user=<USERNAME>
password=<PASSWORD></code></pre>
<p>The above can be used for mysqldump, mysqladmin, and others too, by replacing the <code>[mysql]</code> block</p>
user=&lt;USERNAME&gt;
password=&lt;PASSWORD&gt;</code></pre>
<p>The above can be used for mysqldump, mysqladmin, and others too, by replacing the <code>[mysql]</code> block, with the related. e.g. <code>[mysqldump]</code>.</p>
</section>
</main>

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<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>KVM Optimisation</title>
</head>
<body>
<header>
<a href="#main" class="vh">Jump directly to main content</a>
<h1>KVM Optimisation</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 id="main">
<section>
<h2>KVM Optimisations</h2>
transmit queue
virsh domiflist <vm>
# this is then the txqueuelen change below ???
# changing to 4096
ifconfig <interface_name> txqueuelen <length>
txqueuelen (iwbcman comment)
defaults to 1000, apparently 200 is good
ip link set eth0 txqueuelen 200
vim /etc/network/interfaces
add
post-up /sbin/ip link set eth0 txqueuelen 200
to the end
If virtual hdd is slow can try
Cache mode: none (not default!)
I/O mode: native<Paste>
https://unix.stackexchange.com/a/48584
non caching on dirves?
https://blog.jdpfu.com/2012/07/30/improving-kvm-performance
://documentation.suse.com/smart/linux/html/concept-virtual-disk-cache-modes/concept-virtual-disk-cache-modes.html#:~:text=A%20disk%20cache%20is%20a,example%2C%20by%20setting%20its%20type.
On VM turning cache off essentially acts like accessing the drive itself. No exactly a passthrough, but decent enough
http://www.linux-kvm.org/page/Tuning_KVM
</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>

@ -57,7 +57,7 @@
<h2>Use the git server</h2>
<p>With all the setup out the way, the git server is now usable as a remote for any of your git repos.</p>
<p>So on another PC...</p>
<p>So on another PC, you can use git as normal. For example.</p>
<h3>Add remote to existing repo</h3>
<pre><code>git remote add origin git@&lt;your-server&gt;:/&lt;repo.git&gt;</code></pre>
<h3>Clone the repo</h3>
@ -69,7 +69,7 @@
<p>Giving you something like this</p>
<pre><code>git clone git@&lt;your-server&gt;:&lt;port&gt;/&lt;repo.git&gt;</code></pre>
<br/>
<h2>Completed</h2>
<p>From here you can use git as you would via any other provider, but with the knowledge that your remote is yours.</p>
</section>

@ -33,69 +33,68 @@
<main id="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>
<p class="intro">A bridge network is a means to connect/bridge different networks together to act as a single network. In this case, it allows any virtual connections to the bridge network to get their own internal IPs, as if plugged into the network directly.</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>Find the network device to bridge</h2>
<p>First we need to find the network device we want to bridge to the VMs.</p>
<pre><code>ip link</code></pre>
<p>You'll likely have a device called something similar to <strong>enp1s0</strong>, or <strong>eth0</strong>.</p>
<h2>Bridge it</h2>
<h2>Create the bridge network</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>
<h3>Remove interface from interfaces file</h3>
<p>First step is to remove any references to your network device from <strong>/etc/network/interfaces</strong>, if this file is untouched there will likely be two lines at the bottom.</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>
<h3>Create a new bridge interface</h3>
<p>Now create a file in the <strong>/etc/network/interfaces.d/</strong> directory, with the name of your bridge (I like <strong>br0</strong>).</p>
<h4>Static IP</h4>
<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
iface br0 inet static # Name the same as your file (br0)
address 192.168.0.100
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>
netmask 255.255.255.0
gateway 192.168.0.1 # Normally your router's IP
dns-nameservers 192.168.0.1 8.8.8.8 8.8.4.4 # Don't set if resolveconf is installed, comment if internet borked
bridge_ports enp1s0 # Your device name
bridge_stp off # Disable Spanning Tree Protocol
bridge_waitport 0 # No delay before a port becomes available
bridge_fd 0 # No forwarding delay (Connects to network immediately)</code></pre>
<h4>Dynamic IP</h4>
<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>
<h2>(Optional) Create Virtual Network</h2>
<p>To make it easier to manage with VMs, this new bridge can also be made into a Virtual Network (Basically so you can select it from a dropdown).</p>
<h3>Create XML file</h3>
<p>Open up a text-editor, and create a file called <strong>br0.xml</strong>, named after the bridge itself.</p>
<pre><code>vim br0.xml</code></pre>
<p>Enter the following, then save</p>
<pre><code>&lt;network&gt;
&lt;name&gt;bridged-network&lt;/name&gt;
&lt;name&gt;br0&lt;/name&gt;
&lt;forward mode="bridge"/&gt;
&lt;bridge name="br0"/&gt;
&lt;/network&gt;</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>
<h3>Create the virtual network</h3>
<pre><code>sudo virsh net-define br0.xml</code></pre>
<p>Activate, and auto-start (on boot) the new network.</p>
<pre><code>sudo virsh net-start br0</code></pre>
<pre><code>sudo virsh net-autostart br0</code></pre>
<p>You can now remove the br0.xml file.</p>
<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>
<p>This may claim to have failed, but if checking with <strong>ip link</strong> shows the bridge, reboot. Essentially the bridge has been brought up, and it's trying to bring it up again (and can't), then throws an error.</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>
<p>Run some checks and you should now see br0, with an IP4 address.</p>
<pre><code>ip a</code></pre>
<pre><code>ping google.co.uk</code></pre>
</section>

@ -10,13 +10,13 @@
<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 KVM/QEMU virtualisation</title>
<title>Setup QEMU/KVM virtualisation</title>
</head>
<body>
<header>
<a href="#main" class="vh">Jump directly to main content</a>
<h1>Setup KVM/QEMU virtualisation</h1>
<h1>Setup QEMU/KVM virtualisation</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/>
@ -33,8 +33,54 @@
<main id="main">
<section>
<p class="intro">This is an intro, you gotta believe me</p>
<h2>Heading</h2>
<p class="intro">Virtualisation is the act of creating a virtualised computer (guest), inside another computer (the host) by sharing the hardware. This allows a single host the ability to run all your services, whilst keeping a level of <a href="/guides/vm-seperation-of-concerns">SoC</a>.</p>
<h2>Enable in the BIOS</h2>
<p>To run virtual machines, certain flags in the bios need to be set. If you don't want to bring down an existing server to check, then check the next section first.</p>
<ul>
<li>Reboot your PC</li>
<li>At the BIOS splashscreen, press your motherboard's prefered key (typically <kbd>ESC</kbd>, <kbd>F3</kbd>, or <kbd>F12</kbd>).</li>
<li>Find and enable the virtualisation setting(s).
<ul>
<li>One of VT-x, AMD-V, SVM, or Vanderpool.</li>
<li>One of Intel VT-d, or AMD IOMMU (if available)</li>
</ul>
</li>
</ul>
<h2>Check Virtualisation is enabled</h2>
<p>Double check to make sure your server can be used for virtualisation, if you've enabled it in the BIOS it should be good. Just run one of the following command</p>
<pre><code>lscpu | grep 'Virtualization'</code></pre>
<pre><code>grep -E --color '(vmx|svm)' /proc/cpuinfo</code></pre>
<h2>Install the packages</h2>
<p>The easiest part, just copy and paste the below to install the required packages.</p>
<pre><code>sudo apt install qemu-kvm libvirt-clients libvirt-daemon libvirt-daemon-system virtinst</code></pre>
<h2>Sessions</h2>
<p>There are two different session types for VMs, user, and system sessions. If you are using a desktop, and intend to virtualise other desktop OSs I recommend user sessions. If you're setting up a server hypervisor, then use System sessions.</p>
<h3>User Session</h3>
<p>A user session VM is what I recommend for personal PCs, laptops, etc. as it's the best option for desktop virtualisation (e.g. a Kali install for l33t hackers).</p>
<h4>Add user to group</h4>
<pre><code>sudo adduser $USER libvirt</code></pre>
<h4>Enable default network</h4>
<p>Check the name of your default network (typically just 'default').</p>
<pre><code>sudo virsh net-list --all</code></pre>
<p>Enable the network.</p>
<pre><code>sudo virsh net-start default</code></pre>
<p>(Optionally) Set it to turn on with system boot.</p>
<pre><code>sudo virsh net-autostart default</code></pre>
<h3>System Session</h3>
<p>For now all that's needed to know is that you run sudo before any virsh commands, and that the VMs will launch with root permissions.</p>
<h2>Extra</h2>
<p><a href="/guides/setup-kvm-bridge.html">Setup bridge adapter for KVM</a></p>
<p><a href="/guides/kvm-optimisation.html">Optimisations for KVM Virtual Machines</a></p>
</section>
</main>

@ -77,6 +77,11 @@
<pre><code>virsh snapshot-delete --domain $vm --snapshotname $snapshot_name</code></pre>
<h2>(TODO)Drive management</h2>
<h3>Resize virtual drives</h3>
<p>Find the name of your drive.</p>
<pre><code>virsh domblklist $vm</code></pre>
<p>Resize with qemu</p>
<pre><code>sudo qemu-img resize /location/drive.qcow2 +10G</code></pre>
<h2>Change Memory</h2>
<p>In variantions of 512M, 1G, etc</p>

@ -79,7 +79,6 @@
<h2>Why not use a dedicated server for each concern?</h2>
<p>You can! No-one's going to stop you, but unless each concern <em>requires</em> (i.e. needs the dedicated hardware/isolation) its own dedicated server, it's hugely redundant. Again NAS as an example, would be good for a dedicated machine, as it'll be safer if there's no additional chance it goes down due to failure of an unrelated service.</p>
<p>Virtual Machines are wonderful, as they allow you to make use of more powerful/high spec machines while minimising the wasted usage...</p>
</section>
</main>

Loading…
Cancel
Save