<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PingBin</title>
	<atom:link href="https://pingbin.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://pingbin.com</link>
	<description>Ramblings of a Networking Geek and IT Lover</description>
	<lastBuildDate>Sun, 23 Jan 2022 15:16:10 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Automatically Deploy C# ASP .NET 6.0 Core Applications to Ubuntu using Github Actions CI/CD, with NGINX and MySQL</title>
		<link>https://pingbin.com/2022/01/automatically-deploy-c-asp-net-6-0-core-applications-to-ubuntu-using-github-actions-ci-cd-with-nginx-and-mysql/</link>
					<comments>https://pingbin.com/2022/01/automatically-deploy-c-asp-net-6-0-core-applications-to-ubuntu-using-github-actions-ci-cd-with-nginx-and-mysql/#comments</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Sun, 23 Jan 2022 11:01:14 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://pingbin.com/?p=1930</guid>

					<description><![CDATA[C# .NET Core is a highly performant programming language created by Microsoft, which is an evolution of the legacy .NET Framework. Notably the latest version now natively supports operating systems other than Windows, such as Linux or MACOS making it much more widely adopted. Within this guide we&#8217;ll go through the following steps, feel free to complete all if it&#8217;s a fresh setup, or just pick the bits that suit what you&#8217;re trying to achieve: Create a Ubuntu Virtual Machine Install the .NET Core Runtime Setup Nginx as a Web Server Optionally install MySQL Database Create GitHub Actions for CI/CD 1 &#8211; Create Virtual Machine. To begin we create a Virtual Machine on the Internet which will host our application &#8211; We are using Digital Ocean in this example, however any other provider with a similar specification should work just as well. When creating the droplet within Digital Ocean we&#8217;ve gone for the smallest Virtual Machine available: Distribution &#8211; Ubuntu 20.04 (LTS) x64 Plan &#8211; Shared CPU, Basic &#8211; $5/pm (1GB RAM, 1 vCPU, 25GB Disk) Authentication &#8211; SSH Keys. You must use SSH keys and not password authentication to perform the later CI/CD integration with GitHub. If you are [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="753" height="320" src="https://pingbin.com/wp-content/uploads/2022/01/auto-deploy-1.png" alt="" class="wp-image-1983" srcset="https://pingbin.com/wp-content/uploads/2022/01/auto-deploy-1.png 753w, https://pingbin.com/wp-content/uploads/2022/01/auto-deploy-1-300x127.png 300w" sizes="(max-width: 753px) 100vw, 753px" /></figure>



<p><a href="https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet">C# .NET Core</a> is a highly performant programming language created by Microsoft, which is an evolution of the legacy .NET Framework. Notably the latest version now natively supports operating systems other than Windows, such as Linux or MACOS making it much more widely adopted.</p>



<p>Within this guide we&#8217;ll go through the following steps, feel free to complete all if it&#8217;s a fresh setup, or just pick the bits that suit what you&#8217;re trying to achieve:</p>



<ol class="wp-block-list"><li><a href="#create-virtual-machine" data-type="internal" data-id="#create-virtual-machine">Create a Ubuntu Virtual Machine</a></li><li><a href="#setup-runtime" data-type="URL">Install the .NET Core Runtime</a></li><li><a href="#setup-nginx" data-type="URL">Setup Nginx as a Web Server</a></li><li><a href="#setup-mysql">Optionally install MySQL Database</a></li><li><a href="#github-actions" data-type="URL">Create GitHub Actions for CI/CD</a></li></ol>



<h2 class="wp-block-heading" id="create-virtual-machine">1 &#8211; Create Virtual Machine.</h2>



<p>To begin we create a Virtual Machine on the Internet which will host our application &#8211; We are using Digital Ocean in this example, however any other provider with a similar specification should work just as well. When creating the droplet within Digital Ocean we&#8217;ve gone for the smallest Virtual Machine available:</p>



<ul class="wp-block-list"><li><strong>Distribution </strong>&#8211; Ubuntu 20.04 (LTS) x64</li><li><strong>Plan </strong>&#8211; Shared CPU, Basic &#8211; $5/pm (1GB RAM, 1 vCPU, 25GB Disk)</li><li><strong>Authentication </strong>&#8211; SSH Keys. <span style="text-decoration: underline;">You must use SSH keys</span> and not password authentication to perform the later CI/CD integration with GitHub.</li></ul>



<p>If you are following along then the same specification should be fine too, however websites with higher traffic may need to consider an increase of the CPU/RAM &#8211; This is fairly trivial to upgrade later on once you are setup, so don&#8217;t worry about starting with this amount.</p>



<p>Once the Droplet has finished building you should see it&#8217;s Public IP address which you should now be able to SSH to, remember that you&#8217;ll need to connect using the SSH Key provided when building the Virtual Machine.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="788" height="231" src="https://pingbin.com/wp-content/uploads/2022/01/image-1.png" alt="" class="wp-image-1964" srcset="https://pingbin.com/wp-content/uploads/2022/01/image-1.png 788w, https://pingbin.com/wp-content/uploads/2022/01/image-1-300x88.png 300w, https://pingbin.com/wp-content/uploads/2022/01/image-1-768x225.png 768w" sizes="(max-width: 788px) 100vw, 788px" /></figure>



<p> <p>When using PuTTY on Windows the key file is set within Connection > SSH > Auth and select it within the &#8220;Private key file for authentication&#8221; field. Also, once you connect the Password prompt is to decrypt the key file, it is not for the user of the remote machine.</p></p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img decoding="async" width="454" height="333" src="https://pingbin.com/wp-content/uploads/2022/01/image-3.png" alt="" class="wp-image-1967" srcset="https://pingbin.com/wp-content/uploads/2022/01/image-3.png 454w, https://pingbin.com/wp-content/uploads/2022/01/image-3-300x220.png 300w" sizes="(max-width: 454px) 100vw, 454px" /></figure></div>



<p>To begin with we will ensure the image we have is the most up-to-date by running the update and upgrade commands. </p>



<pre class="wp-block-code"><code>apt update -y
apt upgrade -y</code></pre>



<h2 class="wp-block-heading" id="setup-runtime">2 &#8211; Setup .NET Core Runtimes on Ubuntu and Setup Service</h2>



<p>Now we need to let Ubuntu know about the Microsoft repository for Ubuntu, which once registered we should be able to download the latest .NET SDK&#8217;s from &#8211; To do that we issue these commands in our SSH window:</p>



<pre class="wp-block-code"><code>cd ~
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe
</code></pre>



<p>Now the repository is setup we should be able to install some prerequisites, and then also the actual <a href="https://dotnet.microsoft.com/en-us/download" target="_blank" rel="noreferrer noopener">.NET 6.0 SDK </a></p>



<pre class="wp-block-code"><code>sudo apt install apt-transport-https -y
sudo apt update -y
sudo apt install dotnet-sdk-6.0 -y</code></pre>



<p>So that&#8217;s actually all that needs to be done for getting .NET Core running on an Ubuntu server, <a href="#setup-nginx" data-type="internal" data-id="#setup-nginx">next we&#8217;ll setup a Webserver</a> so that we can accept HTTP requests from clients, and forward them onto our application.</p>



<p>Now we need to create a file that will define our service, so Ubuntu knows how to start/stop the service on our request, at boot and when we want to deploy the service &#8211; The &#8220;yourservicename&#8221; should be replaced with what ever makes sense for your application.</p>



<p>You will also see that we reference a folder in the &#8220;/var/www/&#8221; directory that is not yet created, this is where our application will live &#8211; Again change the &#8220;your_domain&#8221; to something that makes sense, but don&#8217;t worry that this folder doesn&#8217;t exist yet, we&#8217;ll create that when installing Nginx.</p>



<pre class="wp-block-code"><code>
sudo nano /etc/systemd/system/yourservicename.service</code></pre>



<pre class="wp-block-code"><code>&#91;Unit]
Description=YourServiceNameWeb

&#91;Service]
WorkingDirectory=/var/www/your_domain
ExecStart=/usr/bin/dotnet /var/www/your_domain/DemoApplication.dll
Restart=always
RestartSec=10
SyslogIdentifier=YourServiceNameWeb
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

&#91;Install]
WantedBy=multi-user.target
</code></pre>



<p>Within the above you will want to edit the following elements to match your environment</p>



<ul class="wp-block-list"><li>Description &#8211; Call this anything logical, typically I copy the name of the service</li><li>WorkingDirectory &#8211; Should be the folder you created before, that will house your application</li><li>SyslogIdentifier &#8211; I would match the service name again</li><li>User &#8211; Should be the local Linux user that you want to run the application, I normally match that of Nginx which uses www-data, it should not be &#8220;root&#8221;</li></ul>



<p>Finally we want to ensure that if the server ever reboots our service will automatically restart, that is done with the below command &#8211; Again replacing the &#8220;yourservicename&#8221; with what ever you called the above file, before the &#8220;.service&#8221;</p>



<pre class="wp-block-code"><code>sudo systemctl enable yourservicename</code></pre>



<h2 class="wp-block-heading" id="setup-nginx">3 &#8211; Setup the NGINX Web Server for .NET Core</h2>



<p>Here we will install NGINX which is our web server, but we will also install Certbox on the server, this will allow us to automagically request an SSL Certificate from LetsEncrypt (for Free), and it&#8217;ll then update our Web Server configuration to use the newly created certificate &#8211; Gone are the days where we need to pay for SSL certificates, and where the whole process of requesting and installing was a complete pain!</p>



<pre class="wp-block-code"><code>sudo apt install nginx certbot python3-certbot-nginx -y</code></pre>



<p>You should find that NGINX is now actually already running on the server, if you run the following command you should see a running status in the output:</p>



<pre class="wp-block-code"><code>systemctl status nginx
</code></pre>



<pre class="wp-block-code"><code>nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (<strong>running</strong>) since Thu 2021-11-11 13:36:43 UTC; 4min 34s ago
       Docs: man:nginx(8)
   Main PID: 27882 (nginx)
      Tasks: 2 (limit: 1136)
     Memory: 3.8M
     CGroup: /system.slice/nginx.service
             ??27882 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??27884 nginx: worker process
</code></pre>



<p>Also if you open a browser on your local machine such as chrome, you should find that if you go to http://server_ip &#8211; Where server_ip is the IP Address that you SSH&#8217;ed to, you should get an NGINX welcome page.</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://pingbin.com/wp-content/uploads/2021/11/welcome-to-nginx.png" alt="" class="wp-image-1938" width="655" height="233" srcset="https://pingbin.com/wp-content/uploads/2021/11/welcome-to-nginx.png 762w, https://pingbin.com/wp-content/uploads/2021/11/welcome-to-nginx-300x107.png 300w" sizes="auto, (max-width: 655px) 100vw, 655px" /><figcaption>Welcome to NGINX page after installation</figcaption></figure>



<p>We also now want to run the below command to ensure that if the server reboots for any reason, the system knows that we want Nginx to be automatically started without any manual intervention</p>



<pre class="wp-block-code"><code>sudo systemctl enable nginx
</code></pre>



<p>Now we need a place to store our application which will be in the /var/www folder which Nginx will have just created &#8211; So use mkdir to create a directory on the server, replacing &#8220;your_domain&#8221; which what you want the folder to be called.</p>



<pre class="wp-block-code"><code>sudo mkdir /var/www/your_domain</code></pre>



<p>Next we will create a new file within the Nginx sites enabled directory, this can be called anything but it makes sense to match it with the directory that you created within the &#8220;/var/www/&#8221; folder, within that we&#8217;ll paste in the block below, ensuring that you update &#8220;yourdomain&#8221; to your actual domain name.</p>



<pre class="wp-block-code"><code>nano /etc/nginx/sites-enabled/yourdomain</code></pre>



<pre class="wp-block-code"><code>server {

        root /var/www/yourdomain/;

        index index.html index.htm index.nginx-debian.html;

        server_name yourdomain.com;

        location / {
                proxy_pass http://localhost:5000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection keep-alive;
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
        }

}</code></pre>



<p>Now we should be able to restart Nginx to apply our new configuration.</p>



<pre class="wp-block-code"><code>sudo systemctl restart nginx</code></pre>



<p>At this point I will normally browse to &#8220;yourdomain.com&#8221; just to make sure you see an Nginx page, however it should be a &#8220;502 Bad Gateway&#8221; response as our .Net Core application is not yet actually installed on the server for Nginx to pass the request back to.</p>



<h2 class="wp-block-heading" id="setup-mysql">4 &#8211; Setup MySQL on Ubuntu 20.04 (Optional)</h2>



<p>So not all applications will require a database, and even if you have a database it could well be something different such as Postgres or MongoDB &#8211; However if you are using MySQL as your database, you can follow this set to get it installed on Ubuntu as a service.</p>



<p>Firstly we need to add the MySQL repository to our server, so that we&#8217;re able to use APT to install the MySQL packages rather than having to build from source &#8211; You probably want to get the latest version of MySQL rather than the one below, you can do this by going <a rel="noreferrer noopener" href="https://dev.mysql.com/downloads/repo/apt/" target="_blank">here</a> &#8211; Then click the download button, on the next page right click on the &#8220;no thanks, just start my download&#8221; link, and copy the link address, this you can replace with the URL we WGET below.</p>



<p>Now we will move into the temp directory, and download the files:</p>



<pre class="wp-block-code"><code>cd /tmp</code></pre>



<pre class="wp-block-code"><code>wget https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb</code></pre>



<pre class="wp-block-code"><code>sudo dpkg -i mysql-apt-config*
sudo apt update
rm mysql-apt-config*
</code></pre>



<p>Now we have the package downloaded and installed we should be able to install the MySQL server via APT &#8211; Follow through the wizard that this pops up.</p>



<pre class="wp-block-code"><code>sudo apt install mysql-server -y
</code></pre>



<p>Now we want to ensure that MySQL is running as it should have automatically started once the install was complete, if it was you&#8217;ll see a running output similar to below.</p>



<pre class="wp-block-code"><code>sudo systemctl status mysql
</code></pre>



<pre class="wp-block-code"><code>mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (<strong>running</strong>) since Thu 2021-11-11 15:24:23 UTC; 15s ago
       Docs: man:mysqld(8)
             http:&#47;&#47;dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 30003 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 30052 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 1136)
     Memory: 360.0M
     CGroup: /system.slice/mysql.service
             ??30052 /usr/sbin/mysqld
</code></pre>



<p>Then we need to ensure that the MySQL Service is set to enabled, so that in the event of a server reboot the MySQL service will be automatically started. We also follow this up with the secure install command, which will take you through a few steps to clean-up the install and keep things secure.</p>



<pre class="wp-block-code"><code>sudo systemctl enable mysql
mysql_secure_installation</code></pre>



<p>Finally check you can login using your root user</p>



<pre class="wp-block-code"><code>mysql -u root -p</code></pre>



<h2 class="wp-block-heading" id="github-actions">5 &#8211; Github .NET Core Automated Deployments CI/CD</h2>



<h3 class="wp-block-heading">Create GitHub Secrets</h3>



<p>Login to GitHub, navigate to your project, click secrets, and create the following:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="574" src="https://pingbin.com/wp-content/uploads/2021/11/github-secrets-1024x574.png" alt="" class="wp-image-1945" srcset="https://pingbin.com/wp-content/uploads/2021/11/github-secrets-1024x574.png 1024w, https://pingbin.com/wp-content/uploads/2021/11/github-secrets-300x168.png 300w, https://pingbin.com/wp-content/uploads/2021/11/github-secrets-768x430.png 768w, https://pingbin.com/wp-content/uploads/2021/11/github-secrets.png 1114w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<ul class="wp-block-list"><li>REMOTE_HOST &#8211; IP Address (or Hostname) of your VM</li><li>REMOTE_USER &#8211; User (such as root) that you wish to login as</li><li>REMOTE_SSH_KEY &#8211; The SSH Key file that you login to your VM with</li><li>PASSPHRASE &#8211; The Password that protects the SSH Key file</li><li>REMOTE_TARGET &#8211; The directory on the VM where your files should be copied to</li></ul>



<h3 class="wp-block-heading">Create Github Actions / Workflow Template</h3>



<p>So at this point we have a Web Server (Nginx) pointing to our Service (.Net Core) and if needed for your application we also have a Database (MySQL) installed on the same server, now all we need to do is get the application built and installed on the server.</p>



<p>What we&#8217;re using for this is Github actions, basically every time that we check code into Github it will automagically build the application, and copy the resulting files to our server and restart the service as needed, this is continuous deployment &#8211; You can also have Github run other tasks such as Unit tests on your code during the deployment, to ensure it&#8217;s working and safe.</p>



<p>So login to Github and go over to the Actions tab on your repository and create a new work flow &#8211; There is a .NET workflow which you can select, or even just the &#8220;setup a workflow yourself&#8221; will do, as the full script you need is given in detail below.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="925" height="719" src="https://pingbin.com/wp-content/uploads/2021/11/github-actions.png" alt="" class="wp-image-1946" srcset="https://pingbin.com/wp-content/uploads/2021/11/github-actions.png 925w, https://pingbin.com/wp-content/uploads/2021/11/github-actions-300x233.png 300w, https://pingbin.com/wp-content/uploads/2021/11/github-actions-768x597.png 768w" sizes="auto, (max-width: 925px) 100vw, 925px" /></figure>



<p>Now you&#8217;ll see a text editor window, all the contents within this can be replaced with the following, however before you save there are a few changes that you need to make:</p>



<ul class="wp-block-list"><li>Where you see &#8220;ServiceName&#8221; this needs to be replaced with the name of the service created earlier.</li><li>Within the SCP Copy command you&#8217;ll see a Path, this path will be dependant on your application, and where it saves the binaries on a build. I normally take a best guess at it, then look in the GitHub action logs to see where it was actually saved, then update the actions file to match this. You can work it out, but this just seems easier.</li></ul>



<p>The script has the following stages</p>



<ul class="wp-block-list"><li>Checkout the latest code from &#8220;master&#8221;</li><li>Perform a Dotnet Restore, Build, Run Tests and Publish</li><li>Stop the service on the remote VM, so avoid issues (this is service affecting)</li><li>SCP Copy the Published files from GitHub&#8217;s build server to our live server</li><li>Start the service on the remote VM with the new application in place</li></ul>



<p>The script is as follows:</p>



<pre class="wp-block-code"><code>name: .NET Core

on:
  push:
    branches: &#91; master ]
  pull_request:
    branches: &#91; master ]

jobs:
  Deploy:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 6.0.x
        
    - name: DotNet Restore
      run: dotnet restore
    
    - name: DotNet Build
      run: dotnet build --no-restore
      
    - name: DotNet Run Tests
      run: dotnet test --no-build --verbosity normal
      
    - name: DotNet Publish
      run: dotnet publish -c Release
      
    - name: Stop ServiceName Service
      uses: garygrossgarten/github-action-ssh@v0.6.3
      with:
        command: service ServiceName stop
        host: ${{ secrets.REMOTE_HOST }}
        username: ${{ secrets.REMOTE_USER }}
        passphrase: ${{ secrets.PASSPHRASE }}
        privateKey: ${{ secrets.REMOTE_SSH_KEY }}
      
    - name: Copy to Server via SCP
      uses: garygrossgarten/github-action-scp@release
      with:
        local: /home/runner/work/DemoApp/DemoApp/DemoApp/bin/Release/net5.0/publish/
        concurrency: 10
        remote: ${{ secrets.REMOTE_TARGET }}
        host: ${{ secrets.REMOTE_HOST }}
        username: ${{ secrets.REMOTE_USER }}
        passphrase: ${{ secrets.PASSPHRASE }}
        privateKey: ${{ secrets.REMOTE_SSH_KEY }}
      env:
        ASPNETCORE_ENVIRONMENT: Production
        
    - name: Start ServiceName Service
      uses: garygrossgarten/github-action-ssh@v0.6.3
      with:
        command: service ServiceName start
        host: ${{ secrets.REMOTE_HOST }}
        username: ${{ secrets.REMOTE_USER }}
        passphrase: ${{ secrets.PASSPHRASE }}
        privateKey: ${{ secrets.REMOTE_SSH_KEY }}</code></pre>



<p>Once you are ready click &#8220;Commit&#8221; that will save this file via a GIT Commit into your repository &#8211; As this is just like any other &#8220;Commit&#8221; on this repository Github will actually automatically trigger the action you just created and run through the workflow, meaning this is a great way to test if your script is working. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1017" height="694" src="https://pingbin.com/wp-content/uploads/2021/11/actions-log.png" alt="" class="wp-image-1949" srcset="https://pingbin.com/wp-content/uploads/2021/11/actions-log.png 1017w, https://pingbin.com/wp-content/uploads/2021/11/actions-log-300x205.png 300w, https://pingbin.com/wp-content/uploads/2021/11/actions-log-768x524.png 768w" sizes="auto, (max-width: 1017px) 100vw, 1017px" /></figure>



<p>So that&#8217;s all we need, any future commit such as from your IDE or Code Editor to the &#8220;master&#8221; branch will also run the same actions, which automatically build and deploy your application. I would suggest on the first few watching through the log to resolve any errors that could arise.</p>



<p>If you have any questions pop them in the comments below, and I&#8217;ll do my best to help answer them!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2022/01/automatically-deploy-c-asp-net-6-0-core-applications-to-ubuntu-using-github-actions-ci-cd-with-nginx-and-mysql/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Quickly Deploy ClickHouse Docker Server</title>
		<link>https://pingbin.com/2021/11/quickly-deploy-clickhouse-docker-server/</link>
					<comments>https://pingbin.com/2021/11/quickly-deploy-clickhouse-docker-server/#respond</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Wed, 10 Nov 2021 10:42:37 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<guid isPermaLink="false">https://pingbin.com/?p=1906</guid>

					<description><![CDATA[Clickhouse is a column-oriented database created by Yandex and open sourced, which supports real-time SQL queries for Online Analytic Processing. It is designed from the ground up to support billions of rows and terabytes of data, but still return results to analytical queries in hundreds of milliseconds, even on fairly normal and commodity server hardware. ClickHouse is quite commonly used in website analytics services, were you stream ingest events into a long-term data warehouse, but have the ability to quickly query data at a later point, to perhaps graph unique visitors, browser adoption, page performance etc. Getting started is really simple, especially with Docker which is what we&#8217;ll go through in this guide. 1 &#8211; Setup Storage Clickhouse persists it&#8217;s data to a physical disk, so while you can just run the docker image as is, it makes sense to define a permanent storage location for your data. Here we create a folder to contain the docker files &#8220;clickhouse&#8221; within our home directory, and within that we create another folder called &#8220;dbfiles&#8221; which will simply contain the stored data &#8211; You can change these to match your preferred partitioning layout. 2 &#8211; Create Docker Compose FIle Next we need to [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="753" height="320" src="https://pingbin.com/wp-content/uploads/2021/11/Clickhouse.png" alt="clickhouse docker" class="wp-image-1917" srcset="https://pingbin.com/wp-content/uploads/2021/11/Clickhouse.png 753w, https://pingbin.com/wp-content/uploads/2021/11/Clickhouse-300x127.png 300w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>



<p>Clickhouse is a column-oriented database created by Yandex and open sourced, which supports real-time SQL queries for Online Analytic Processing.</p>



<p>It is designed from the ground up to support billions of rows and terabytes of data, but still return results to analytical queries in hundreds of milliseconds, even on fairly normal and commodity server hardware.</p>



<p>ClickHouse is quite commonly used in website analytics services, were you stream ingest events into a long-term data warehouse, but have the ability to quickly query data at a later point, to perhaps graph unique visitors, browser adoption, page performance etc.</p>



<p>Getting started is really simple, especially with Docker which is what we&#8217;ll go through in this guide.</p>



<h2 class="wp-block-heading">1 &#8211; Setup Storage</h2>



<p>Clickhouse persists it&#8217;s data to a physical disk, so while you can just run the docker image as is, it makes sense to define a permanent storage location for your data.</p>



<p>Here we create a folder to contain the docker files &#8220;clickhouse&#8221; within our home directory, and within that we create another folder called &#8220;dbfiles&#8221; which will simply contain the stored data &#8211; You can change these to match your preferred partitioning layout.</p>



<pre class="wp-block-code"><code>cd ~
mkdir clickhouse
cd clickhouse
mkdir dbfiles</code></pre>



<h2 class="wp-block-heading"> 2 &#8211; Create Docker Compose FIle</h2>



<p>Next we need to create a Docker Compose file, simply put this is a file that will tell docker what image we want to run, where we want the data to be stored, and how we want the networking to be setup &#8211; This will go in our newly created folder, so just open the file up in a text editor like nano.</p>



<pre class="wp-block-code"><code>nano ~/clickhouse/docker-compose.yml</code></pre>



<p>Then paste in the following, making any changes you need (if you changed the folder names in step one then you must reflect that here).</p>



<pre class="wp-block-code"><code>version: '3'

services:
  click_server:
    image: yandex/clickhouse-server
    ports:
      - "8123:8123"
    volumes:
      - ./dbfiles:/var/lib/clickhouse

  click_client:
    image: yandex/clickhouse-client
    entrypoint:
      - /bin/sleep
    command:
      - infinity

</code></pre>



<h2 class="wp-block-heading">3 &#8211; Start and Connect to Clickhouse</h2>



<p>Next we simply need to tell Docker that we want to run our compose file, that&#8217;s just a case of running docker compose, with the up command.</p>



<pre class="wp-block-code"><code>sudo docker-compose up -d</code></pre>



<p>If this is the first time running a Clickhouse server on this host you&#8217;ll see it start to download the image files from the internet, which could take a few minuets &#8211; Once that&#8217;s done you can connect to the Clickhouse server using the command:</p>



<pre class="wp-block-code"><code># <strong>docker-compose exec click_server clickhouse-client</strong>


  ClickHouse client version 21.8.10.19 (official build).
  Connecting to localhost:9000 as user default.
  Connected to ClickHouse server version 21.8.10 revision 54449.
  66c76cb18f7b :)</code></pre>



<h2 class="wp-block-heading">4 &#8211; Create a Database and Test</h2>



<p>Below are some examples of how we can create a database, tables, insert data and perform some basic selects &#8211; If you&#8217;ve ever used MySQL or another SQL based database before, this will all look very familiar.</p>



<h3 class="wp-block-heading">Create and Use a Clickhouse Database</h3>



<p>Just as you would in any other SQL database, there isn&#8217;t anything special to consider when creating a Clickhouse database &#8211; Simply use the &#8220;create&#8221; command to generate a new database, and &#8220;use&#8221; to select a database. </p>



<pre class="wp-block-code"><code>66c76cb18f7b :) <strong>create database pingbin</strong>;

CREATE DATABASE pingbin
Query id: b648f3a8-ccf4-43a0-8e25-da881ce9196b
Ok.
0 rows in set. Elapsed: 0.025 sec.


66c76cb18f7b :) <strong>use pingbin</strong>
</code></pre>



<h3 class="wp-block-heading">Create a Clickhouse Table</h3>



<p>Again creating a new Clickhouse Table is fairly simple, and very similar to how you create any other SQL database table &#8211; One thing you should pay attention to is to how you partition and order your data, here we use the date, as each day is granular enough to allow good partitioning, and the order is going to be on all of our queries.</p>



<pre class="wp-block-code"><code>CREATE TABLE visits (
 Id UUID,
 EventDate DateTime,
 DomainId UUID,
 Path String,
 Referrer String,
 OperatingSystem String,
 OperatingSystemVersion String,
 CountryCode String,
 Browser String,
 BrowserVersion String,
 ScreenWidth UInt16,
 ScreenHeight UInt16
) 
ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(EventDate)
ORDER BY (EventDate);</code></pre>



<h3 class="wp-block-heading">Insert and Select from a Clickhouse Table</h3>



<p>Finally we will insert an example row, again this is extremely similar to any other SQL database, just ensure the order of your data matches the column order.</p>



<pre class="wp-block-code"><code>INSERT INTO visits VALUES (
    'd9c544bd-ec6c-4b58-b34d-b24cb51c0904',
    '2021-02-03 00:01:01',
    'd9c544bd-ec6c-4b58-b34d-b24cb51c0911',
    '/domains',
    '',
    'Windows',
    'Windows 10.101.1',
    'GB',
    'Chrome',
    'Chrome 123',
    1200,
    600
);</code></pre>



<p>Then here we select that row back out of the database.</p>



<pre class="wp-block-code"><code>66c76cb18f7b :) <strong>select * from visits</strong>

SELECT *
FROM visits

Query id: 74a724a1-8b33-4130-8c26-fcb0bdc9f0c3


? d9c544bd-ec6c-4b58-b34d-b24cb51c0904 ? 2019-01-01 00:01:01 ? d9c544bd-ec6c-4b58-b34d-b24cb51c0911 ? /domains ?          ? Windows         ? Windows 10.101.1       ? IM          ? Chrome  ? Chrome 101001  ?        1231 ?          500 ?

1 rows in set. Elapsed: 0.012 sec.</code></pre>



<p>Hopefully that was helpful, we&#8217;ve tested the above process on both Windows and Linux (Ubuntu) so it should work fine for you, however if you have any queries or issues just let us know and we&#8217;ll try to help out.</p>



<p>One thing to mention is that you probably want a minimum of 4GB RAM free to run Clickhouse, and enough storage space to obviously hold the data that you plan to load into it, however it does compress the data quite well in comparison to other databases.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2021/11/quickly-deploy-clickhouse-docker-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MAC/OSX &#8211; How to disable Youtube / Chrome media keys</title>
		<link>https://pingbin.com/2019/05/mac-osx-disable-youtube-chrome-media-keys/</link>
					<comments>https://pingbin.com/2019/05/mac-osx-disable-youtube-chrome-media-keys/#comments</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Mon, 06 May 2019 09:01:37 +0000</pubDate>
				<category><![CDATA[OSX]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1832</guid>

					<description><![CDATA[So if you&#8217;re anything like me you might be using Spotify to listen to music on your iMac/MacBook, and also use the built-in keyboard media keys to control Spotify while it&#8217;s minimised and you&#8217;re working in other applications. After a recent Chrome update it seems to be deciding that it wants control of them buttons while it&#8217;s got media playing &#8211; So I would open up a Youtube video in Chrome, click Pause on the keyboard media keys, I was&#160;expect the background music to stop, but instead the Youtube video would pause&#8230; Not idea! There&#8217;s a fix! 1 &#8211; Open up chrome and put the below in your address bar at the top, and hit enter/return. chrome://flags/#hardware-media-key-handling 2 &#8211; You should see a &#8220;Hardware Media Key Handling&#8221; setting there, change this to Disabled 3 &#8211; Restart Chrome Your back to normal now!]]></description>
										<content:encoded><![CDATA[
<p>So if you&#8217;re anything like me you might be using Spotify to listen to music on your iMac/MacBook, and also use the built-in keyboard media keys to control Spotify while it&#8217;s minimised and you&#8217;re working in other applications.</p>



<p>After a recent Chrome update it seems to be deciding that it wants control of them buttons while it&#8217;s got media playing &#8211; So I would open up a Youtube video in Chrome, click Pause on the keyboard media keys, I was&nbsp;expect the background music to stop, but instead the Youtube video would pause&#8230; Not idea!</p>



<p><strong>There&#8217;s a fix!</strong></p>



<p>1 &#8211; Open up chrome and put the below in your address bar at the top, and hit enter/return.</p>



<pre class="wp-block-preformatted">chrome://flags/#hardware-media-key-handling</pre>



<p>2 &#8211; You should see a &#8220;Hardware Media Key Handling&#8221; setting there, change this to Disabled</p>



<p>3 &#8211; Restart Chrome</p>



<p>Your back to normal now!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2019/05/mac-osx-disable-youtube-chrome-media-keys/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Cisco Router 887V &#8211; VPN Example Configuration</title>
		<link>https://pingbin.com/2015/01/cisco-887-client-vpn-example-configuration/</link>
					<comments>https://pingbin.com/2015/01/cisco-887-client-vpn-example-configuration/#comments</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Sun, 25 Jan 2015 18:18:43 +0000</pubDate>
				<category><![CDATA[Firewalls]]></category>
		<category><![CDATA[Networking]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1615</guid>

					<description><![CDATA[Overview This is going to be a quick guide on how to setup VPN access on your Cisco router (in my case a Cisco 887 router with VDSL), for remote clients to access your network and get access to the local resources. There&#8217;s a few different ways of doing this however we&#8217;re going to use IPSec, mainly because it&#8217;s more secure than the alternatives and doesn&#8217;t require any third party clients to get it working (most of the time). The guide will assume you&#8217;ve already got your LAN (VLAN1) and WAN (PPPoE/A on Dialer1) setup and working, also it assumes you have some Cisco knowledge to actually get the commands applied in the right places as I wont be covering the basics. If you need a base configuration for a Cisco 887 look at the post here, otherwise jump straight into it below! 1) Enable Authentication So the first part is to enable authentication on the router so that we can create users and have the VPN authenticate against these, you could also use an external radius server however if you&#8217;ve only got a few users this is going to be simpler to manage aaa new-model aaa session-id common aaa authentication login [&#8230;]]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1712" src="http://pingbin.com/wp-content/uploads/2015/01/Screen-Shot-2017-04-30-at-16.01.43.png" alt="" width="640" height="320" srcset="https://pingbin.com/wp-content/uploads/2015/01/Screen-Shot-2017-04-30-at-16.01.43.png 640w, https://pingbin.com/wp-content/uploads/2015/01/Screen-Shot-2017-04-30-at-16.01.43-300x150.png 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<h1 style="text-align: justify;">Overview</h1>
<p style="text-align: justify;">This is going to be a quick guide on how to setup VPN access on your Cisco router (in my case a Cisco 887 router with VDSL), for remote clients to access your network and get access to the local resources. There&#8217;s a few different ways of doing this however we&#8217;re going to use IPSec, mainly because it&#8217;s more secure than the alternatives and doesn&#8217;t require any third party clients to get it working (most of the time).</p>
<p style="text-align: justify;">The guide will assume you&#8217;ve already got your LAN (VLAN1) and WAN (PPPoE/A on Dialer1) setup and working, also it assumes you have some Cisco knowledge to actually get the commands applied in the right places as I wont be covering the basics.</p>
<p style="text-align: justify;">If you need a base configuration for a Cisco 887 look at the post <a href="http://pingbin.com/2014/09/cisco-887va-m-vdsl2-pppoe-configuration/">here</a>, otherwise jump straight into it below!</p>
<h2 style="text-align: justify;">1) Enable Authentication</h2>
<p style="text-align: justify;">So the first part is to enable authentication on the router so that we can create users and have the VPN authenticate against these, you could also use an external radius server however if you&#8217;ve only got a few users this is going to be simpler to manage</p>
<pre class="prettyprint">aaa new-model
aaa session-id common

aaa authentication login default local
aaa authentication login vpn_xauth_ml_1 local
aaa authentication login sslvpn local
aaa authorization network vpn_group_ml_1 local 

username vpn_username password 0 vpn_password</pre>
<h2 style="text-align: justify;">2) IP Address Pool</h2>
<p style="text-align: justify;">Next we need to create an IP pool that we&#8217;ll use to give the VPN clients unique IP addresses that appear to be on the LAN (VLAN1), the second step is to ensure that we don&#8217;t hand out these same IP&#8217;s as part of the normal DHCP process.</p>
<pre class="prettyprint">ip local pool vpn_client_pool 192.168.0.100 192.168.0.109
ip dhcp excluded-address 192.168.0.100 192.168.0.109
</pre>
<h2 style="text-align: justify;">3) Split Tunnel</h2>
<p style="text-align: justify;">Now normally when a client to connects to our VPN we want it to send all traffic to us for the LAN, there&#8217;s usually no point in sending internet or DNS traffic to us if they already have an internet connection, we do that with an access list.</p>
<p style="text-align: justify;">Basically the below is saying &#8216;any&#8217; of the clients have access to &#8216;192.168.0.0/24&#8217;, you should be able to modify to your specific requirements.</p>
<pre class="prettyprint">ip access-list extended vpn_resources
 permit ip 192.168.0.0 0.0.0.255 any
!
</pre>
<h2 style="text-align: justify;">4) IPSec</h2>
<p style="text-align: justify;">IPsec uses two different phases for user authentication and traffic encryption, therefore we need to create two different policies. There are more secure settings than what I&#8217;m using in the policy below, however you&#8217;re realistically going to have more compatibility problems as you tune up these, and the below are still very secure for most installs.</p>
<pre class="prettyprint">crypto isakmp policy 1
 encr 3des
 authentication pre-share
 group 2
!
crypto isakmp policy 2
 encr 3des
 hash md5
 authentication pre-share
 group 2
!</pre>
<h2 style="text-align: justify;">5) VPN Group</h2>
<p style="text-align: justify;">Now we need to define the group, the group name and group key that you pick here will need to be also entered on all of the clients that are using the VPN (laptops/iphones etc&#8230;), so you want to pick something secure but something that you also don&#8217;t mind disclosing to people with VPN access.</p>
<p>In the below configuration my group is &#8216;oracle&#8217; and we&#8217;re using a shared password of &#8216;qwerty&#8217;, you should also notice this is where we&#8217;re referencing the ip address pool that these clients will be given, and the access list that defines where they&#8217;re allowed to go within our network &#8216;vpn_resources&#8217;</p>
<p><em>(If you want to redirect the client&#8217;s DNS queries you could also do that here with the &#8216;dns&#8217; setting, however theres usually not much point in that unless you have some kind of intranet.)</em></p>
<pre class="prettyprint">crypto isakmp client configuration group oracle
 key qwerty
 pool vpn_client_pool
 acl vpn_resources
 max-users 10
!</pre>
<p><figure id="attachment_1626" aria-describedby="caption-attachment-1626" style="width: 300px" class="wp-caption alignleft"><a href="http://pingbin.com/wp-content/uploads/2015/01/cisco-vpn-client-13.jpg"><img loading="lazy" decoding="async" class="wp-image-1626 size-medium" src="http://pingbin.com/wp-content/uploads/2015/01/cisco-vpn-client-13-300x165.jpg" alt="cisco-vpn-client-13" width="300" height="165" srcset="https://pingbin.com/wp-content/uploads/2015/01/cisco-vpn-client-13-300x165.jpg 300w, https://pingbin.com/wp-content/uploads/2015/01/cisco-vpn-client-13.jpg 600w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-1626" class="wp-caption-text">OSX Cisco VPN Client</figcaption></figure></p>
<p style="text-align: justify;">So the above configuration was mostly for Phase 1 (ISAKMP) of the tunnel, really this is concerned with securely authenticating the users and defining how were going to configure them on the network once they&#8217;re connected.</p>
<p>Naturally that brings us onto Phase 2 (IPSec), which is how the already authenticated users are going to securely encrypt there traffic between the router and client. First we&#8217;ll setup a transform set and bind that to an IPSec profile</p>
<pre class="prettyprint">crypto ipsec transform-set vpn_transform esp-3des esp-sha-hmac 
!
crypto ipsec profile vpn_profile
 set transform-set vpn_transform
!</pre>
<h2 style="text-align: justify;">6) Virtual Tunnel</h2>
<p style="text-align: justify;">Now we need somewhere on the router that clients can actually bind there internal IP to, for example the ip route and ARP table on the router needs to know where to send that traffic, this is a &#8216;virtual-template&#8217;. The configuration is simply saying our virtual-template2 is part of the IPSec profile we just created and is on the VLAN1 internal network.</p>
<pre class="prettyprint">interface Virtual-Template2 type tunnel
 ip unnumbered Vlan1
 tunnel mode ipsec ipv4
 tunnel protection ipsec profile vpn_profile
!</pre>
<p style="text-align: justify;">Now the last part should be to glue our VPN group, how we want to authenticate users and virtual template configuration together using the ISAKMP profile.</p>
<pre class="prettyprint">crypto isakmp profile vpn_ike_profile
   match identity group oracle
   client authentication list vpn_xauth_ml_1
   isakmp authorization list vpn_group_ml_1
   client configuration address respond
   virtual-template 2
!</pre>
<h2 style="text-align: justify;">7) Testing Clients</h2>
<p style="text-align: justify;">The final step is to go over to one of your clients and actually try the<img loading="lazy" decoding="async" class="alignright wp-image-1623 size-medium" src="http://pingbin.com/wp-content/uploads/2015/01/unnamed-169x300.png" alt="iPhone Example Confiig" width="169" height="300" srcset="https://pingbin.com/wp-content/uploads/2015/01/unnamed-169x300.png 169w, https://pingbin.com/wp-content/uploads/2015/01/unnamed.png 517w" sizes="auto, (max-width: 169px) 100vw, 169px" /> VPN connection, below are the five bits of information that these clients will require a minimum, most will dynamically pick up the rest of the required information.</p>
<p style="text-align: justify;">Clients like an iPhone (shown at the right) have a built in client, however if yours doesn&#8217;t go over to the cisco website and download the &#8216;Cisco VPN Client&#8217;, it&#8217;s currently available for most operating systems like Windows, Linux, OSX and Solaris.</p>
<ul>
<li><strong>Public IP</strong> or DNS Name &#8211; vDSL Dialer1 Public IP</li>
<li><strong>Group Name</strong> &#8211; oracle</li>
<li><strong>Group Pass</strong> &#8211; qwerty</li>
<li><strong>User</strong> &#8211; vpn_username</li>
<li><strong>Pass</strong> &#8211; vpn_password</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2015/01/cisco-887-client-vpn-example-configuration/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Cisco IOS &#8211; Schedule CLI Commands and Scripts with KRON/CRON</title>
		<link>https://pingbin.com/2014/09/cisco-router-scheduler-cli-commands/</link>
					<comments>https://pingbin.com/2014/09/cisco-router-scheduler-cli-commands/#respond</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Sat, 27 Sep 2014 15:35:19 +0000</pubDate>
				<category><![CDATA[Networking]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1579</guid>

					<description><![CDATA[Cisco IOS has a build in Command Scheduler called KRON, with very similar functionality to the Linux CRON service many will be familiar with, we are able to use this scheduler to run customizable tasks on a predefined interval &#8211; Within this guide you can learn how to schedule common IOS commands, or sequences of commands, to perform useful tasks, such as backups of configuration or daily reboots of your Cisco device. It&#8217;s a little known feature of Cisco devices, however KRON actually first appeared in IOS 12.3(1) back in 2008, so if you check the running software on your device and find this version or higher, you should be good to go. Cisco Scheduled Auto Configuration Save One of the most common uses for the scheduler, is to defined a daily configuration save of the router (or switches) running configuration that&#8217;s stored in Volatile RAM, over to the startup configuration file which is stored in VNRAM &#8211; This helps to ensure that device configuration is likely not going lost if an engineer forgets to manually save the configuration after making some changes, and there&#8217;s an unexpected reboot or power loss to the device. The example below is fairly simple, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="800" height="399" src="http://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.17.16-1.png" alt="" class="wp-image-1715" srcset="https://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.17.16-1.png 800w, https://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.17.16-1-300x150.png 300w, https://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.17.16-1-768x383.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></figure></div>



<p>Cisco IOS has a build in Command Scheduler called KRON, with very similar functionality to the Linux CRON service many will be familiar with, we are able to use this scheduler to run customizable tasks on a predefined interval &#8211; Within this guide you can learn how to schedule common IOS commands, or sequences of commands, to perform useful tasks, such as backups of configuration or daily reboots of your Cisco device.</p>



<p>It&#8217;s a little known feature of Cisco devices, however KRON actually first appeared in IOS 12.3(1) back in 2008, so if you check the running software on your device and find this version or higher, you should be good to go.</p>



<h2 class="wp-block-heading">Cisco Scheduled Auto Configuration Save</h2>



<p>One of the most common uses for the scheduler, is to defined a daily configuration save of the router (or switches) running configuration that&#8217;s stored in Volatile RAM, over to the startup configuration file which is stored in VNRAM &#8211; This helps to ensure that device configuration is likely not going lost if an engineer forgets to manually save the configuration after making some changes, and there&#8217;s an unexpected reboot or power loss to the device.</p>



<p>The example below is fairly simple, first we create a &#8220;policy-list&#8221; which should just be thought of as a script, for example the bash script part if this was a Linux device using Cron &#8211; Here we are just running &#8220;cli write&#8221; which is the command to save the configuration, and giving the script a name.</p>



<p>An important note here is that you must use a none interactive command &#8211; Basically your command cannot require user input otherwise it will not work, that is why the script is using &#8220;cli write&#8221; and perhaps not the more commonly used &#8220;copy run start&#8221; command.</p>



<p>The second part is setting up the occourance, which is the schedule it&#8217;s self, here it&#8217;s configured to run at 04:00 every day and recur until the schedule is manually removed. The Akron occourance quite simply points to the script that was created above.</p>



<p></p>



<pre class="wp-block-preformatted prettyprint">kron policy-list daily-save-config
 cli write
!
kron occurrence daily-save-config at 4:00 recurring
 policy-list daily-save-config
!
</pre>



<p>You might also want to check that everything is as you expect, to do that the most useful display command is &#8220;show kron schedule&#8221;</p>



<h1 class="wp-block-heading">Cisco Scheduled Reboot</h1>



<p>This may seem like a strange command, however I&#8217;ve seen a number of branches/houses with DSL based connectivity perform a daily reboot at night, in attempt to force a re-sync of the line out of business hours.</p>



<p>Again the process is as you saw above, first we create a kron policy called &#8220;reloadrouter&#8221;, then within this we simply define that we wish the router to invoke a &#8220;cli&#8221; command which is &#8220;reload&#8221;</p>



<pre class="wp-block-preformatted prettyprint">kron policy-list reloadrouter
 cli reload
!</pre>



<p>Now we&#8217;ve got a simple script defined the router knows what we expect it to do, the next part is to let is know when we would like that to be run, so again within Cisco IOS we must create an occurrence of the script policy, with a time that we want it to &#8220;occur&#8221;</p>



<p>The below will run our reloadrouter policy at 04:00 AM, and reoccur every day.</p>



<pre class="wp-block-preformatted prettyprint">kron occurrence reloadrouter at 4:00 recurring
 policy-list reloadrouter
!</pre>



<h2 class="wp-block-heading"> Cisco Daily Debug Removal </h2>



<p>Another useful trick on Cisco routers is to perform a daily removal of the debug commands, without this it&#8217;s possible that someone will forget that debug was enabled, and leave it running for weeks or months at a time. Best case this could just be an annoyance of filling up your local log storage, or syslog server, however it could actually be much worse and cause performance issues on the device.</p>



<p>In the below we simply have a daily command running at 01:00 AM each morning to remove all debug.</p>



<pre class="wp-block-preformatted prettyprint">kron policy-list daily-un-debug
 cli undeb all
!
kron occurrence daily-un-debug at 1:00 recurring
 policy-list daily-un-debug
!</pre>



<h2 class="wp-block-heading">Cisco Daily TFTP Configuration Backup</h2>



<p>Here is another quick example, where if you don&#8217;t have a centralised configuration management system in place, you could have a quick script running on the Cisco device each day to copy it&#8217;s startup (or running) configuration off to a remote server.</p>



<pre class="wp-block-preformatted prettyprint">kron policy-list config-backup
cli show startup-config | redirect tftp://10.1.1.1/bkup.cfg
!
kron occurrence config-backup at 1:00 recurring
 policy-list config-backup
!
</pre>



<p>As a final hint its always good to remember that your device will run these based on the device time, so if you don&#8217;t have NTP in place to keep your Cisco device time insync and accurate, you may want to look into that first.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2014/09/cisco-router-scheduler-cli-commands/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Cisco 887VA-M &#8211; vDSL2 PPPoE Example Configuration</title>
		<link>https://pingbin.com/2014/09/cisco-887va-m-vdsl2-pppoe-configuration/</link>
					<comments>https://pingbin.com/2014/09/cisco-887va-m-vdsl2-pppoe-configuration/#comments</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Sat, 27 Sep 2014 15:19:39 +0000</pubDate>
				<category><![CDATA[Networking]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1573</guid>

					<description><![CDATA[Overview After spending quite a bit of time getting my Cisco VDSL router working with PPPoE I though others might benefit from an example configuration, please read through and tune the configuration to match your requirements. &#160; Basically this will setup the vDSL connection and obtain an IP address from your ISP using PPPoE CHAP authentication, the 192.168.0.0/24 range will be used on the inside network and DHCP will handout IP&#8217;s within the range 192.168.0.6-99/24, the router will take the address 192.168.0.1 and perform PAT based NAT on any outbound traffic. Configuration no service pad service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption service internal ! hostname HOME-GW-1 ! boot-start-marker boot-end-marker ! ! logging buffered 4096 enable secret {PASSWORD-GOES-HERE} enable password {PASSWORD-GOES-HERE} ! aaa new-model ! ! aaa authentication login default local ! ! ! ! ! aaa session-id common memory-size iomem 10 clock timezone gmt 0 0 clock summer-time BST recurring last Sun Mar 2:00 last Sun Oct 3:00 crypto pki token default removal timeout 0 ! ! no ip source-route ! ! ! ip dhcp excluded-address 192.168.0.0 192.168.0.5 ip dhcp excluded-address 192.168.0.100 192.168.0.255 ! ip dhcp pool 10 import all network 192.168.0.0 255.255.255.0 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1721" src="http://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.44.04.png" alt="" width="800" height="399" srcset="https://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.44.04.png 800w, https://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.44.04-300x150.png 300w, https://pingbin.com/wp-content/uploads/2014/09/Screen-Shot-2017-04-30-at-17.44.04-768x383.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<h1>Overview</h1>
<p>After spending quite a bit of time getting my Cisco VDSL router working with PPPoE I though others might benefit from an example configuration, please read through and tune the configuration to match your requirements.</p>
<p>&nbsp;<br />
Basically this will setup the vDSL connection and obtain an IP address from your ISP using PPPoE CHAP authentication, the 192.168.0.0/24 range will be used on the inside network and DHCP will handout IP&#8217;s within the range 192.168.0.6-99/24, the router will take the address 192.168.0.1 and perform PAT based NAT on any outbound traffic.</p>
<h1>Configuration</h1>
<pre class="prettyprint">no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
service internal
!
hostname HOME-GW-1
!
boot-start-marker
boot-end-marker
!
!
logging buffered 4096
enable secret {PASSWORD-GOES-HERE}
enable password {PASSWORD-GOES-HERE}
!
aaa new-model
!
!
aaa authentication login default local
!
!
!
!
!
aaa session-id common
memory-size iomem 10
clock timezone gmt 0 0
clock summer-time BST recurring last Sun Mar 2:00 last Sun Oct 3:00
crypto pki token default removal timeout 0
!
!
no ip source-route
!
!
!
ip dhcp excluded-address 192.168.0.0 192.168.0.5
ip dhcp excluded-address 192.168.0.100 192.168.0.255
!
ip dhcp pool 10
 import all
 network 192.168.0.0 255.255.255.0
 ! Change to your ISP DNS
 dns-server 8.8.8.8 4.2.2.2 
 default-router 192.168.0.1 
!
!
ip cef
! Change to your ISP DNS
ip name-server 8.8.8.8
ip name-server 4.2.2.2
ip inspect WAAS flush-timeout 10
ipv6 cef
!
!
!
archive
 log config
  logging enable
  logging size 500
  hidekeys
username {username} secret {password}
!
!
!
!
controller VDSL 0
 operating mode vdsl2
 modem customUKAnnexM
 modem customUKAnnexA
 modem UKfeature
!
ip ssh version 2
! 
!
!
!
!
!
bba-group pppoe global
!
!
interface Ethernet0
 no ip address
 pppoe-client dial-pool-number 1
!
interface ATM0
 no ip address
 shutdown
 no atm ilmi-keepalive
!
interface FastEthernet0
 description Link-to-Dist-Switch
 no ip address
 duplex full
 speed 100
!
interface FastEthernet1
 no ip address
!
interface FastEthernet2
 no ip address
!
interface FastEthernet3
 no ip address
!
interface Vlan1
 ip address 192.168.0.1 255.255.255.0
 ip nat inside
 no ip virtual-reassembly in
 ip tcp adjust-mss 1452
!
interface Dialer1
 description vDSL
 mtu 1492
 ip address negotiated
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip nat outside
 no ip virtual-reassembly in
 encapsulation ppp
 dialer pool 1
 dialer idle-timeout 0
 dialer-group 1
 ppp authentication chap pap callin
 ppp chap hostname {ISP-USERNAME-HERE}
 ppp chap password 0 {ISP-PASSWORD-HERE}
 ppp pap sent-username {ISP-USERNAME-HERE} password 0 {ISP-PASSWORD-HERE}
 ppp ipcp dns request accept
 ppp ipcp route default
 ppp ipcp address accept
 no cdp enable
!
no ip forward-protocol nd
no ip http server
no ip http secure-server
!
ip dns server
ip nat inside source list 10 interface Dialer1 overload
!
access-list 10 permit 192.168.0.0 0.0.0.255
access-list 10 remark nat-pool
access-list 23 permit 192.168.0.0 0.0.0.255
access-list 23 remark vty
access-list 23 deny   any log
dialer-list 1 protocol ip permit
!
!
!
!
!
!
!
ipv6 access-list ipv6_deny
 deny ipv6 any any
!
ipv6 access-list V6-FILTER
 permit icmp any any
 deny ipv6 any any log
banner login ^CC
THIS IS A PRIVATE SYSTEM. UNAUTHORISED ACCESS IS NOT
PERMITTED AND OFFENDERS ARE LIABLE TO PROSECUTION.

YOUR IP HAS BEEN LOGGED AND AN ALERT GENERATED
^C
!
line con 0
 logging synchronous
line aux 0
line vty 0 4
 access-class 23 in
 ipv6 access-class ipv6_deny in
 transport input telnet
 escape-character 3
!
scheduler max-task-time 5000
ntp server {YOUR-NTP-Server}
end
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2014/09/cisco-887va-m-vdsl2-pppoe-configuration/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>CentOS Bash Patch &#8211; ShellShock</title>
		<link>https://pingbin.com/2014/09/centos-bash-patch-shellshock/</link>
					<comments>https://pingbin.com/2014/09/centos-bash-patch-shellshock/#respond</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Sat, 27 Sep 2014 14:59:14 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1562</guid>

					<description><![CDATA[ShellSock &#8211; Patching Unless you&#8217;ve been under a rock for the last few days you&#8217;ve probably heard about the new Bash exploit (CVE-2014-6271) &#8216;ShellShock&#8217; that allows remote code execution through bash, because of the amount of servers and applications using the bash service it&#8217;s a fairly big deal in the security world. How To Patch Here&#8217;s a few simple commands to get your CentOS servers patched, please for your sake do this ASAP. # Check if vulnerable env x='() { :;}; echo Vulnerable system' bash -c "echo Testing..." Vulnerable system Testing... # # If you need to access the web via a proxy, add that here. nano ~/.bash_profile export http_proxy=http://192.168.1.123:3128 # Apply the patch yum update bash -y # Remove proxy (if used nano ~/.bash_profile # export http_proxy=http://192.168.1.123:3128 # Check if vulnerable env x='() { :;}; echo Vulnerable system' bash -c "echo Testing..." Testing... # Any problems or questions, please leave a comment.]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1710" src="http://pingbin.com/wp-content/uploads/2014/09/Untitled-Design-2.jpg" alt="" width="1200" height="600" /></p>
<h1>ShellSock &#8211; Patching</h1>
<p>Unless you&#8217;ve been under a rock for the last few days you&#8217;ve probably heard about the new Bash exploit (CVE-2014-6<wbr />271) &#8216;ShellShock&#8217; that allows remote code execution through bash, because of the amount of servers and applications using the bash service it&#8217;s a fairly big deal in the security world.</p>
<h1>How To Patch</h1>
<p>Here&#8217;s a few simple commands to get your CentOS servers patched, please for your sake do this ASAP.</p>
<pre class="prettyprint"># Check if vulnerable
env x='() { :;}; echo Vulnerable system'  bash -c "echo Testing..."
 Vulnerable system
 Testing...
#
</pre>
<pre class="prettyprint"># If you need to access the web via a proxy, add that here.
nano ~/.bash_profile
export http_proxy=http://192.168.1.123:3128</pre>
<pre class="prettyprint"># Apply the patch
yum update bash -y</pre>
<pre class="prettyprint"># Remove proxy (if used
nano ~/.bash_profile
# export http_proxy=http://192.168.1.123:3128</pre>
<pre class="prettyprint"># Check if vulnerable
env x='() { :;}; echo Vulnerable system'  bash -c "echo Testing..."
 Testing...
#</pre>
<p>Any problems or questions, please leave a comment.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2014/09/centos-bash-patch-shellshock/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PHP5 FPM Sock Failed- Permission denied</title>
		<link>https://pingbin.com/2014/09/php5-fpm-sock-failed-permission-denied/</link>
					<comments>https://pingbin.com/2014/09/php5-fpm-sock-failed-permission-denied/#respond</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Sat, 27 Sep 2014 14:49:17 +0000</pubDate>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1555</guid>

					<description><![CDATA[The Problem After the bash exploit &#8216;shellshock&#8217; was released a few days ago I&#8217;ve been going around my servers and applying the required patches, however after doing a &#8216;apt-get update&#8217; on one of the web servers PHP based requests were no longer working. Having a look in the Nginx error logs I found that the issue appeared to be at the PHP-FPM layer of the server (which I kind of expected), as it did have an update included in the bulk install and it was PHP that seemed to be broken, heres an example log: 2014/09/26 05:24:28 [crit] 26963#0: *19 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 46.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im" 2014/09/26 05:24:29 [crit] 26963#0: *19 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 123.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im" 2014/09/26 05:24:30 [crit] 26963#0: *19 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 123.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im" 2014/09/26 05:24:32 [crit] 26964#0: *28 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 123.226.191.96, server: subnet.im, request: "GET / [&#8230;]]]></description>
										<content:encoded><![CDATA[<h3>The Problem</h3>
<p>After the bash exploit &#8216;shellshock&#8217; was released a few days ago I&#8217;ve been going around my servers and applying the required patches, however after doing a &#8216;apt-get update&#8217; on one of the web servers PHP based requests were no longer working.</p>
<p>Having a look in the Nginx error logs I found that the issue appeared to be at the PHP-FPM layer of the server (which I kind of expected), as it did have an update included in the bulk install and it was PHP that seemed to be broken, heres an example log:</p>
<pre class="brush:bash">2014/09/26 05:24:28 [crit] 26963#0: *19 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 46.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im"
2014/09/26 05:24:29 [crit] 26963#0: *19 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 123.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im"
2014/09/26 05:24:30 [crit] 26963#0: *19 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 123.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im"
2014/09/26 05:24:32 [crit] 26964#0: *28 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 123.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im"
2014/09/26 05:24:38 [crit] 26964#0: *37 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 123.226.191.96, server: subnet.im, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "subnet.im"</pre>
<p>After some digging around I found that this was caused by a PHP bug fix #67060 (<a href="https://bugs.php.net/bug.php?id=67060">linky here</a>), the bug was basically providing possible privilege escalation on the web server which they&#8217;ve fixed, however this changes some of the permissions stopping Nginx connecting to the required stocket used for PHP processing.</p>
<h3>The Fix</h3>
<p>Fortunately the fix is fairly simple, edit the PFP-FPM configuration.</p>
<pre class="brush:bash"> nano /etc/php5/fpm/pool.d/www.conf</pre>
<p>Add in these three lines, they are probably already there and just need the comment marks removing.</p>
<pre class="brush:bash">listen.owner = www-data
listen.group = www-data
listen.mode = 0660
</pre>
<p>Finally re-start the PHP-FPM service and you should be back in business.</p>
<pre class="brush:bash">sudo service php5-fpm restart</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2014/09/php5-fpm-sock-failed-permission-denied/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CentOS &#8211; Update/Install applications via Proxy using Yum</title>
		<link>https://pingbin.com/2014/08/centos-updateinstall-applications-proxy-yum/</link>
					<comments>https://pingbin.com/2014/08/centos-updateinstall-applications-proxy-yum/#respond</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Wed, 27 Aug 2014 11:53:36 +0000</pubDate>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1537</guid>

					<description><![CDATA[Introduction. TL,DR; &#8211; Go to Installing Squid Yum is a great package manager for CentOS that is the secret envy of every Windows system administrator on the planet, however there will come a time when you attempt a &#8220;yum update&#8221; or &#8220;yum install tcpdump&#8221; to find out there is a problem with internet access from your server. 90% of the time you&#8217;ll probably find a network issue or someones messed up the DNS resolver configuration, however in some instances the server will legitimately have no internet access and setting up this access is either not allowed or high innocent. Recently I worked on a server with two network connections, one to the management network and another to a VoIP signalling/media network, in this setup the default gateway was configured via the VoIP network as that&#8217;s the mission critical services, all the management elements had static routes via the management interface gateway. The problem was the VoIP network was internal and had no internet access available where as the management network did. Placing a static route for every possible Yum repository and mirror obviously isn&#8217;t an option and neither was switching around the network configuration, so here comes the Proxy. The concept of a [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2><a href="http://pingbin.com/wp-content/uploads/2014/08/yum-via-proxy-yum-package-management-mascot.png"><img loading="lazy" decoding="async" class="alignright wp-image-1551" src="http://pingbin.com/wp-content/uploads/2014/08/yum-via-proxy-yum-package-management-mascot.png" alt="yum-via-proxy-yum-package-management-mascot" width="230" height="205" /></a><strong>Introduction</strong>.</h2>
<p><span style="color: #999999;"><em>TL,DR; &#8211; Go to Installing Squid</em></span></p>
<p>Yum is a great package manager for CentOS that is the secret envy of every Windows system administrator on the planet, however there will come a time when you attempt a &#8220;yum update&#8221; or &#8220;yum install tcpdump&#8221; to find out there is a problem with internet access from your server.</p>
<p>90% of the time you&#8217;ll probably find a network issue or someones messed up the DNS resolver configuration, however in some instances the server will legitimately have no internet access and setting up this access is either not allowed or high innocent.</p>
<p>Recently I worked on a server with two network connections, one to the management network and another to a VoIP signalling/media network, in this setup the default gateway was configured via the VoIP network as that&#8217;s the mission critical services, all the management elements had static routes via the management interface gateway. The problem was the VoIP network was internal and had no internet access available where as the management network did. Placing a static route for every possible Yum repository and mirror obviously isn&#8217;t an option and neither was switching around the network configuration, so here comes the Proxy.</p>
<p>The concept of a proxy is fairly simple, we&#8217;re going to tell Yum that all of it&#8217;s traffic should be sent to a specific IP address on a specific port, this IP address will be on a server with internet access and will have the Squid proxy installed and listening on that port for inbound connections. Assuming the access lists on the proxy are configured correctly this will then route that traffic to the internet and back on behalf of the originating server, therefore giving the illusion of internet access for Yum, simple!</p>
<p>&nbsp;</p>
<h2><strong>Initialling Squid</strong></h2>
<p>So you need to find a server on your network that has IP connectivity to the internet and to your other server that doesn&#8217;t have internet access, this is where the proxy (Squid) will reside.</p>
<p>First step use Yum to install the Squid application on this server, and then ensure that it&#8217;s going to start at boot.</p>
<pre class="prettyprint">yum -y install squid
chkconfig squid on</pre>
<p>Now you need to define which client IP addresses are permitted to use your proxy, in our case this range should include the IP of the client that doesn&#8217;t have internet access. So edit the squid configuration as below replacing the IP range as per your network.</p>
<pre class="prettyprint">nano /etc/squid/squid.conf
acl allowed_clients_acl src 192.168.0.0/24
http_access allow allowed_clients_acl</pre>
<p>Now restart the Squid service to apply the configuration changes:</p>
<pre class="prettyprint">service squid restart</pre>
<p>It&#8217;s always worth checking that Squid is actually running and listening on the correct network port using netstat</p>
<pre class="prettyprint">netstat -lnutp | grep 3128
tcp        0      0 0.0.0.0:3128                0.0.0.0:*                   LISTEN      20653/(squid)</pre>
<h2><strong>Client/Yum configuration</strong></h2>
<p>So our Squid proxy server should be working now, the next step is to actually configure the clients to use this server. Simply in the users (in this case root) bash profile were going to specific an environment variable that yum will pick up on, so edit that profile text file:</p>
<pre class="prettyprint">nano /root/.bash_profile</pre>
<p>Then just paste in this line, replacing the IP address with your Squid server (you can also use a hostname).</p>
<pre class="prettyprint">export http_proxy=http://192.168.204.251:3128</pre>
<p>Bingo &#8211; Try some yum commands on the server and you should be in business!</p>
<p>Any problems leave a question in the comments <img src="https://s.w.org/images/core/emoji/16.0.1/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2014/08/centos-updateinstall-applications-proxy-yum/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Passive Bandwidth Meter</title>
		<link>https://pingbin.com/2014/03/passive-bandwidth-meter/</link>
					<comments>https://pingbin.com/2014/03/passive-bandwidth-meter/#respond</comments>
		
		<dc:creator><![CDATA[Tom]]></dc:creator>
		<pubDate>Sun, 23 Mar 2014 13:23:57 +0000</pubDate>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Raspberry PI]]></category>
		<guid isPermaLink="false">http://pingbin.com/?p=1527</guid>

					<description><![CDATA[The home and small business routers these days that us geeks would be interested in buying are shipping with SNMP server functionality built in as standard, and when their not there&#8217;s normally some way of breaking into the Busybox Linux distro (that most of them use) and installing some kind of SNMP daemon. However there&#8217;s always cases where that options not available for some reason or another, in these cases you can use a setup like Kurt&#8217;s, where he decided to build a passive bandwidth monitor (even through the router in his pictures does support SNMP?!). See a basic video of it in operation here: The basic setup consists of a passive network tap; This is basically just a fancy way of saying that you&#8217;ve cut into the pairs of a Cat5e network cable and added in an extension of the pairs to your own device. The device that you add in should be doing nothing other than monitoring, so that it&#8217;s not transmitting any data on to the cable that would confuse the other two host which assume their are directly connected to each other with no other hosts on the network segment. The limitation of this setup is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="http://pingbin.com/wp-content/uploads/2014/03/bwMeterCase.jpg"><img loading="lazy" decoding="async" class="alignright" src="http://pingbin.com/wp-content/uploads/2014/03/bwMeterCase-300x264.jpg" alt="bwMeterCase" width="240" height="211" /></a>The home and small business routers these days that us geeks would be interested in buying are shipping with SNMP server functionality built in as standard, and when their not there&#8217;s normally some way of breaking into the <a href="http://www.busybox.net" target="_blank" rel="noopener noreferrer">Busybox</a> Linux distro (that most of them use) and installing some kind of SNMP daemon.</p>
<p style="text-align: justify;">However there&#8217;s always cases where that options not available for some reason or another, in these cases you can use a setup like Kurt&#8217;s, where <a href="https://www.bonafidegeek.com/category/in-line-bandwidth-meter/" target="_blank" rel="noopener noreferrer">he decided to build a passive bandwidth monitor</a> (even through the router in his pictures does support SNMP?!).</p>
<p style="text-align: justify;">See a basic video of it in operation here:</p>
<p><iframe loading="lazy" src="//www.youtube.com/embed/LnkB1wg1tqc" width="640" height="360" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p style="text-align: justify;">The basic setup consists of a passive network tap; This is basically just a fancy way of saying that you&#8217;ve cut into the pairs of a Cat5e network cable and added in an extension of the pairs to your own device. The device that you add in should be doing nothing other than monitoring, so that it&#8217;s not transmitting any data on to the cable that would confuse the other two host which assume their are directly connected to each other with no other hosts on the network segment. The limitation of this setup is you need physical access to the cable, and due to the nature of high speed ethernet it would only work on 100Mbps connections or less.</p>
<p style="text-align: justify;">The electronic brains behind the setup is a ENC624J600 chip to interface with the ethernet layer, chosen because of it&#8217;s raw ethernet functionality, this was connected up to an Atmega128 using the SPI interface which would run the core code to count packets and plot on the LED display.</p>
<p style="text-align: justify;">To have a look at Kurt&#8217;s full write up on the project, <a href="https://www.bonafidegeek.com/category/in-line-bandwidth-meter/#MAC%20+%20PHY%20chip" target="_blank" rel="noopener noreferrer">head over to here.</a><a href="http://pingbin.com/wp-content/uploads/2014/03/bwMeterCase.jpg"><br />
</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://pingbin.com/2014/03/passive-bandwidth-meter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
