- Joined
- Jan 14, 2011
Requirements:
- windows operating system that has hyper-v role enabled and running you can get the baremetal hypervisor free from microsoft, but that's alot more advanced.
- a router that is capable of forwarding dns traffic, for this writeup i will be using pfsense
- the more ram and cpu the better
- enough storage space to hold the files you will be caching im going to end up using 1tb worth of 500gb drives in raid10
- an iso of ubuntu 16.04 i used desktop which works fine
- must have a dedicated nic for the vm's dont want the host os to be sharing with the vm's it can make stuff messy.
[note: if installing on a physical machine scroll down to where the other note is under virtual machine part II]
ok first we are going to create a virtual switch to share between vm's and a virtual machine and for our caching server.
creating virtual switch
1. open hyper-v manager and click "virtual switch manager"
2. click "new virtual network switch" make sure external is selected then click "create virtual switch"
3. it should have went to settings for the new switch, give it a name, pick a network adapter that is dedicated just for the vm's.
- uncheck the box next to "allow management operating system to share this network adapter".
- make sure external network is still selected
- make sure "enable single-root i/o virtualization is not checked
4. click apply this will create the virtual switch. then click the "+" next to the new switch and click extensions, make sure no boxes are checked in there.
5. click apply if anything needed unchecked in "extensions"
now we will move on to creating the virtual machine.
1. open hyper-v manager in the right panel click new > virtual machine a dialogue box will appear, on "before you begin" read that then click next.
2. "specify name and location" any name will work i have mine named "cache" also you can use the default storage space or if you want it to use its own dedicated hard drive click next.
3. "specify generation" make sure generation 1 is selected and click next.
4. "assign memory" id prefer to have ATLEAST 4gb of memory so "4096"MB is a good starting point the more the better as the OS will use this to store the most recently shared files and will have faster access next time they are needed before they are flushed from memory. click next.
5. "configure networking" pick the virtual switch we created in the last section.
6. "connect virtual hard disk" ok this is crucial we need to have enough storage for what we need so put the virtual disk location somewhere that will have enough make the "size" eg if you want to be able to cache 500gb worth of games you need to have the virtual disk closer to 550gb.
7. "installation options" select the radio button next to "stall an operating system from a bootable cd/dvd-rom. then select "image file" then nagivate to your ubuntu iso we downloaded earlier. then click finish.
8. start the virtual machine from the hyper -v manager do the ubuntu install im not going to cover that its simple.
9. once its installed and you have rebooted, shut the machine down and right click on it in hyper- v manager we need to change some settings.
virtual machine part II.
im breaking this off as now we have the vm created and are changing settings to make this work best.
1. you should have the vm's settings open from the last instruction. select "processor" and give it as many cores as you can afford, i have an i3 and i gave it 4 cores (2c4t cpu).
2. click apply, then click ok. we are done with configuring the vm.
3. next we will start configuring the OS for the install, so put on your big girl panties its about to get fun.
OK so now we can power the vm back on and boot into Ubuntu. we want to install some hyper-v drivers, and needed software.
source: https://technet.microsoft.com/en-us/library/dn531029.aspx
1. open a terminal window (ctrl+alt+t) and run the following commands
that is the only thing i installed from the page if you want other things to work with hyper-v such as snapshots and stuff theres more info on the microsoft page i linked.
[note: anything after this point will work for setting it up on a dedicated physical machine with a fresh ubuntu 16.04 install as well]
2. next we are going to install nginx 1.10.1 https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
if there is any issue refer to the page i linked and use the secondary set of commands.
2.5 in terminal run
and make sure version 1.10.1 is installed (technically anything past 1.6 is fine)
3. now that nginx is installed we are going to open the file browser and go to computer>/etc/nginx/ and delete everything but "mime.types" you might have to chmod this directory to delete them. for more information on that https://help.ubuntu.com/community/FilePermissions i usually chmod 777 the folder plus /etc/nginx/* that will give permissions to all files in the folder. some people dont condone 777 being used though do some searching and see what's best for you.
4. next we will download the new nginx config there are alot of them but this one seems promising as its used for a huge lan party "q-con" and they actively update their stuff on there. https://github.com/Q-Con/ds-lancache/archive/master.zip open that zip folder then there should be a folder inside labeled "nginx" open that and copy everything from inside there into your /etc/nginx/ folder.
5. last thing in this section we need to create some folders this will be the directory where the caches are stored, open computer> /srv/ (chmod this directory first) create a folder called www, inside that folder one called cache, inside that folder we need to put 3 folders installs, other, and tmp. so the stucture of the folders should be
/srv/www/cache/installs/
/srv/www/cache/tmp/
/srv/www/cache/other/
now everything should be ready to rock and roll just a few more steps to go bear with me.
creating the virutal nic's
this is essential as this is where our dns forwarding is going to come in handy.
1. navigate in the file browser to /etc/networking/ (will likely have to chmod the directory and directory/*) and open the "interfaces" file.
2. now we need to create some virtual nic's inside this file we need to add some lines i will post my config in here you will have to change the all of the ip's to match your local network and router ect.
if you dont understand what to assign all these addresses then read here
we need all of these because that's what our dns forwards are going to point to later on.
3. reboot the machine. to ensure everything configured correctly open a terminal window and run ifconfig and make sure you have all 6 of the network adapters listed
ok now everything should be ready on the ubuntu side, now we are going to move onto the router configuration.
router dns forwarding config
ok this is the fun part every router is different im using pfsense i will give you the example of my config in dnsmasq you will see how the ip's match the above virtual nic's and that needs to happen so what everip's you assign to your virtual nics MUST MATCH all of your dns forwards.
im not going to go much more indepth on this part besides
NOTE: if when you go to run nginx with the new config and it says "host at lancache-steam cannot be found" that means you dont have the dns forwarded correctly.
if not using pfsense you might or might not need to use .localdomain after the names depending on your router.
open /etc/nginx/vhosts/lancache-single.conf and under all of the listen tags E.G. "lancache-steam" and "lancache-riot" add .yourdomain if you are using pfsense as you can see mine is "lancache-steam.localdomain"
basically all steam traffic will be directed to 192.168.1.218 where nginx will be listening and that's how it works or something.. i know it works. lol. riot traffic goes to .219 ect.
last thing there is to do is to start nginx.
1. open a terminal window and run the following"
-if this fails due to not finding a host look above and check your dns forwarding.
-if this fails because access to a folder or folder not existing then chmod or make the directory it needs go back and check what ones we made earlier.
-if this fails because of "user permissions" you didnt use sudo. lol i did this too many times to count.
2. only if the last step passes, run:
if it fails go back to step 1 as that tests and troubleshoots the nginx config.
3. if it successfully runs then we will need to test it! open steam on another computer and download a small game like counter strike. delete the game and download it again, you should see a significant speed increase, if not you might want to invest in an SSD('s) more ram or more cpu.
edit:
final note if having any issues with game downloads pausing downloads saying they are queued for 5 minutes or what ever like i was having issues with, then go into your host os's network settings and right click ethernet adapter(on vm switch)> properties> configure> advanced tab > "large send offload v2 (ipv4)" set to "disabled" this fixed my download hangs. only other option i found was to use a legacy adapter that was slow.
- windows operating system that has hyper-v role enabled and running you can get the baremetal hypervisor free from microsoft, but that's alot more advanced.
- a router that is capable of forwarding dns traffic, for this writeup i will be using pfsense
- the more ram and cpu the better
- enough storage space to hold the files you will be caching im going to end up using 1tb worth of 500gb drives in raid10
- an iso of ubuntu 16.04 i used desktop which works fine
- must have a dedicated nic for the vm's dont want the host os to be sharing with the vm's it can make stuff messy.
[note: if installing on a physical machine scroll down to where the other note is under virtual machine part II]
ok first we are going to create a virtual switch to share between vm's and a virtual machine and for our caching server.
creating virtual switch
1. open hyper-v manager and click "virtual switch manager"
2. click "new virtual network switch" make sure external is selected then click "create virtual switch"
3. it should have went to settings for the new switch, give it a name, pick a network adapter that is dedicated just for the vm's.
- uncheck the box next to "allow management operating system to share this network adapter".
- make sure external network is still selected
- make sure "enable single-root i/o virtualization is not checked
4. click apply this will create the virtual switch. then click the "+" next to the new switch and click extensions, make sure no boxes are checked in there.
5. click apply if anything needed unchecked in "extensions"
now we will move on to creating the virtual machine.
1. open hyper-v manager in the right panel click new > virtual machine a dialogue box will appear, on "before you begin" read that then click next.
2. "specify name and location" any name will work i have mine named "cache" also you can use the default storage space or if you want it to use its own dedicated hard drive click next.
3. "specify generation" make sure generation 1 is selected and click next.
4. "assign memory" id prefer to have ATLEAST 4gb of memory so "4096"MB is a good starting point the more the better as the OS will use this to store the most recently shared files and will have faster access next time they are needed before they are flushed from memory. click next.
5. "configure networking" pick the virtual switch we created in the last section.
6. "connect virtual hard disk" ok this is crucial we need to have enough storage for what we need so put the virtual disk location somewhere that will have enough make the "size" eg if you want to be able to cache 500gb worth of games you need to have the virtual disk closer to 550gb.
7. "installation options" select the radio button next to "stall an operating system from a bootable cd/dvd-rom. then select "image file" then nagivate to your ubuntu iso we downloaded earlier. then click finish.
8. start the virtual machine from the hyper -v manager do the ubuntu install im not going to cover that its simple.
9. once its installed and you have rebooted, shut the machine down and right click on it in hyper- v manager we need to change some settings.
virtual machine part II.
im breaking this off as now we have the vm created and are changing settings to make this work best.
1. you should have the vm's settings open from the last instruction. select "processor" and give it as many cores as you can afford, i have an i3 and i gave it 4 cores (2c4t cpu).
2. click apply, then click ok. we are done with configuring the vm.
3. next we will start configuring the OS for the install, so put on your big girl panties its about to get fun.
OK so now we can power the vm back on and boot into Ubuntu. we want to install some hyper-v drivers, and needed software.
source: https://technet.microsoft.com/en-us/library/dn531029.aspx
1. open a terminal window (ctrl+alt+t) and run the following commands
Code:
apt-get update
apt-get install --install-recommends linux-virtual-lts-xenial
[note: anything after this point will work for setting it up on a dedicated physical machine with a fresh ubuntu 16.04 install as well]
2. next we are going to install nginx 1.10.1 https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
Code:
sudo -s
nginx=stable # use nginx=development for latest development version
add-apt-repository ppa:nginx/$nginx
apt-get update
apt-get install nginx
2.5 in terminal run
Code:
nginx -v
3. now that nginx is installed we are going to open the file browser and go to computer>/etc/nginx/ and delete everything but "mime.types" you might have to chmod this directory to delete them. for more information on that https://help.ubuntu.com/community/FilePermissions i usually chmod 777 the folder plus /etc/nginx/* that will give permissions to all files in the folder. some people dont condone 777 being used though do some searching and see what's best for you.
4. next we will download the new nginx config there are alot of them but this one seems promising as its used for a huge lan party "q-con" and they actively update their stuff on there. https://github.com/Q-Con/ds-lancache/archive/master.zip open that zip folder then there should be a folder inside labeled "nginx" open that and copy everything from inside there into your /etc/nginx/ folder.
5. last thing in this section we need to create some folders this will be the directory where the caches are stored, open computer> /srv/ (chmod this directory first) create a folder called www, inside that folder one called cache, inside that folder we need to put 3 folders installs, other, and tmp. so the stucture of the folders should be
/srv/www/cache/installs/
/srv/www/cache/tmp/
/srv/www/cache/other/
now everything should be ready to rock and roll just a few more steps to go bear with me.
creating the virutal nic's
this is essential as this is where our dns forwarding is going to come in handy.
1. navigate in the file browser to /etc/networking/ (will likely have to chmod the directory and directory/*) and open the "interfaces" file.
2. now we need to create some virtual nic's inside this file we need to add some lines i will post my config in here you will have to change the all of the ip's to match your local network and router ect.
Code:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.218
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
dns-nameservers 192.168.1.1
auto eth0:0
iface eth0:0 inet static
address 192.168.1.219
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
dns-nameservers 192.168.1.1
auto eth0:1
iface eth0:1 inet static
address 192.168.1.220
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
dns-nameservers 192.168.1.1
auto eth0:2
iface eth0:2 inet static
address 192.168.1.221
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
dns-nameservers 192.168.1.1
auto eth0:3
iface eth0:3 inet static
address 192.168.1.222
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
dns-nameservers 192.168.1.1
auto eth0:4
iface eth0:4 inet static
address 192.168.1.223
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
dns-nameservers 192.168.1.1
if you dont understand what to assign all these addresses then read here
we need all of these because that's what our dns forwards are going to point to later on.
3. reboot the machine. to ensure everything configured correctly open a terminal window and run ifconfig and make sure you have all 6 of the network adapters listed
ok now everything should be ready on the ubuntu side, now we are going to move onto the router configuration.
router dns forwarding config
ok this is the fun part every router is different im using pfsense i will give you the example of my config in dnsmasq you will see how the ip's match the above virtual nic's and that needs to happen so what everip's you assign to your virtual nics MUST MATCH all of your dns forwards.
im not going to go much more indepth on this part besides
NOTE: if when you go to run nginx with the new config and it says "host at lancache-steam cannot be found" that means you dont have the dns forwarded correctly.
if not using pfsense you might or might not need to use .localdomain after the names depending on your router.
open /etc/nginx/vhosts/lancache-single.conf and under all of the listen tags E.G. "lancache-steam" and "lancache-riot" add .yourdomain if you are using pfsense as you can see mine is "lancache-steam.localdomain"
Code:
address=/lancache-steam.localdomain/192.168.1.218
address=/cs.steampowered.com/192.168.1.218
address=/.cs.steampowered.com/192.168.1.67/192.168.1.218
address=/content1.steampowered.com/192.168.1.218
address=/content2.steampowered.com/192.168.1.218
address=/content3.steampowered.com/192.168.1.218
address=/content4.steampowered.com/192.168.1.218
address=/content5.steampowered.com/192.168.1.218
address=/content6.steampowered.com/192.168.1.218
address=/content7.steampowered.com/192.168.1.218
address=/content8.steampowered.com/192.168.1.218
address=/.hsar.steampowered.com.edgesuite.net/192.168.1.218
address=/clientconfig.akamai.steamstatic.com/192.168.1.218
address=/.akamai.steamstatic.com/192.168.1.218
address=/content-origin.steampowered.com/192.168.1.218
address=/content-download.steampowered.com/192.168.1.218
address=/client-download.steampowered.com/192.168.1.218
address=/.steamcontent.com/192.168.1.218
address=/lancache-riot.localdomain/192.168.1.219
address=/l3cdn.riotgames.com/192.168.1.219
address=/lancache-blizzard.localdomain/192.168.1.220
address=/dist.blizzard.com.edgesuite.net/192.168.1.220
address=/llnw.blizzard.com/192.168.1.220
address=/dist.blizzard.com/192.168.1.220
address=/blzddist1-a.akamaihd.net/192.168.1.220
address=/blzddist1-b.akamaihd.net/192.168.1.220
address=/blzddist2-a.akamaihd.net/192.168.1.220
address=/blzddist2-b.akamaihd.net/192.168.1.220
address=/lancache-hirez.localdomain/192.168.1.221
address=/hirez.http.internapcdn.net/192.168.1.221
address=/lancache-origin.localdomain/192.168.1.222
address=/akamai.cdn.ea.com/192.168.1.222
address=/lvlt.cdn.ea.com/192.168.1.222
address=/origin-a.akamaihd.net/192.168.1.122
address=/origin-b.akamaihd.net/192.168.1.122
address=/lancache-sony.localdomain/192.168.1.223
address=/pls.patch.station.sony.com/192.168.1.223
last thing there is to do is to start nginx.
1. open a terminal window and run the following"
Code:
sudo nginx -t
-if this fails because access to a folder or folder not existing then chmod or make the directory it needs go back and check what ones we made earlier.
-if this fails because of "user permissions" you didnt use sudo. lol i did this too many times to count.
2. only if the last step passes, run:
Code:
sudo service nginx start
3. if it successfully runs then we will need to test it! open steam on another computer and download a small game like counter strike. delete the game and download it again, you should see a significant speed increase, if not you might want to invest in an SSD('s) more ram or more cpu.
edit:
final note if having any issues with game downloads pausing downloads saying they are queued for 5 minutes or what ever like i was having issues with, then go into your host os's network settings and right click ethernet adapter(on vm switch)> properties> configure> advanced tab > "large send offload v2 (ipv4)" set to "disabled" this fixed my download hangs. only other option i found was to use a legacy adapter that was slow.
Last edited: