Lets install apt-cacher
Code:
apt-get install apt-cacher
While the install is running you will be prompted for a daemon mode for apt-cacher. Select 'daemon'
When the install is finished, restart apache2 with the following command
Code:
/etc/init.d/apache2
Navigate to http://192.168.0.50:3142 and you will receive a plain white page (no error messages). This indicates that apt-cacher is running.
I had issues until I set my allowed hosts. Adjust the following setting to allow all clients to fetch packages through the apt-cacher server
Code:
nano +178 /etc/apt-cacher/apt-cacher.conf
adjust the line to read what is below by removing the #
allowed_hosts = *
Restart apt-cacher
Code:
/etc/init.d/apt-cacher restart
Now to configure Apt-get to run through apt-cacher by using a proxy. An example of my file is included below. Change the IP to match your apt-cacher host.
My file
Code:
root@kali:~#cat /etc/apt/apt.conf.d/01proxy
Acquire::http::Proxy "http://192.168.0.50:3142";
root@kali:~#
That is all the configuration we need if the host is the same as the client. If you have a dedicated machine to act as the server (the one apt-cacher is installed on) and want clients to make use of it, you can alter either of the following files on the client machine to point them at the apt-cacher server.
The 01proxy file
On the client machine, create file at /etc/apt/apt.conf.d/01proxy and populate it the same as the file shown above (that is, with the ip address of the machine running apt-cacher) and then run apt-get update.
The sources file
I don't like this method as much as it takes more effort. As with before, it's all about pointing to the apt-cacher server.
Open the sources file with nano /etc/apt/sources.list and then change your entries using the same method as below.
Assuming an entry looks like this
Code:
deb http://http.kali.org/kali kali main non-free contrib
Becomes what is shown below. The IP is the apt-cacher server
Code:
deb http://192.168.0.50:3142/http.kali.org/kali kali main non-free contrib
On the clients, it is time to update the cache. Run the following
if you receive errors about 'unable to access cache' you didn't run '/etc/init.d/apt-cacher restart' when you finished making configuration changes to proxies or sources.list
Go ahead and install something, I picked something large-ish to start with so I used
Code:
apt-get install linux-headers-$(uname -r)
Now, check the cache folder on the apt-cacher server. For me (as I haven't moved it yet this is located at the default location shown below.
Code:
cd /var/cache/apt-cacher/packages
ls -lha
Look at that! all those .deb files are now in our cache folder! Lets see if it actually saves time.
Code:
apt-get remove linux-headers-$(uname -r) && apt-get autoremove
Now they are deleted, reinstall them.
Code:
apt-get install linux-headers-$(uname -r)
Did you notice how they packages did not need to download? I know that is only one file. Imagine that is the ~500mb of updates normally facing a reinstall of Kali. Big time and download saver, right?