<?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>G1FEF</title>
	<atom:link href="https://g1fef.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>https://g1fef.co.uk</link>
	<description></description>
	<lastBuildDate>Mon, 01 Sep 2025 11:49:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>APC Master Switch Serial Cable</title>
		<link>https://g1fef.co.uk/apc-master-switch-serial-cable/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Mon, 01 Sep 2025 11:42:01 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=321</guid>

					<description><![CDATA[The APC Master Switch series PDUs have an RJ11 socket for the serial port, if you have a spare Cisco serial cable lying about here is a quick trick to make up a 9 pin D-Type socket to RJ11 plug cable: Cisco Pin Colour RJ11 Pin Description 1 Grey CTS 2 Blue DSR 3 Green [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The APC Master Switch series PDUs have an RJ11 socket for the serial port, if you have a spare Cisco serial cable lying about here is a quick trick to make up a 9 pin D-Type socket to RJ11 plug cable:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><strong>Cisco Pin</strong></td><td><strong>Colour</strong></td><td><strong>RJ11 Pin</strong></td><td><strong>Description</strong></td></tr><tr><td>1</td><td>Grey</td><td></td><td>CTS</td></tr><tr><td>2</td><td>Blue</td><td></td><td>DSR</td></tr><tr><td>3</td><td>Green</td><td>3</td><td>TX</td></tr><tr><td>4</td><td>Yellow</td><td>5</td><td>GND</td></tr><tr><td>5</td><td>Orange</td><td>2</td><td>GND</td></tr><tr><td>6</td><td>Red</td><td>4</td><td>RX</td></tr><tr><td>7</td><td>Brown</td><td></td><td>DTR</td></tr><tr><td>8</td><td>Black</td><td></td><td>RTS</td></tr></tbody></table></figure>



<div style="height:57px" aria-hidden="true" class="wp-block-spacer"></div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-large is-resized"><a href="https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6834-scaled.jpeg"><img fetchpriority="high" decoding="async" width="768" height="1024" src="https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6834-768x1024.jpeg" alt="" class="wp-image-322" style="width:256px;height:auto" srcset="https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6834-768x1024.jpeg 768w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6834-225x300.jpeg 225w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6834-1152x1536.jpeg 1152w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6834-1536x2048.jpeg 1536w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6834-scaled.jpeg 1920w" sizes="(max-width: 768px) 100vw, 768px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-large"><a href="https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6835-scaled-e1756726994113.jpeg"><img decoding="async" width="1024" height="972" src="https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6835-scaled-e1756726994113-1024x972.jpeg" alt="" class="wp-image-323" srcset="https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6835-scaled-e1756726994113-1024x972.jpeg 1024w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6835-scaled-e1756726994113-300x285.jpeg 300w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6835-scaled-e1756726994113-768x729.jpeg 768w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6835-scaled-e1756726994113-1536x1459.jpeg 1536w, https://g1fef.co.uk/wp-content/uploads/2025/09/IMG_6835-scaled-e1756726994113.jpeg 2022w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>
</div>
</div>



<p>Pins 1 and 6 on the RJ11 are not connected.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Cisco SPA504G VoIP phones</title>
		<link>https://g1fef.co.uk/cisco-spa504g-voip-phones/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Wed, 01 Jan 2025 17:09:31 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=283</guid>

					<description><![CDATA[These phones are available at very low cost, e.g. on eBay and work great as a VoIP phone. They support up to 4 &#8220;lines&#8221; or SIP accounts and are very easy to program. For anyone interested in hacking the onboard CPU there is a serial interface available on the PCB &#8211; Look for &#8220;J3&#8221; which [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>These phones are available at very low cost, e.g. on eBay and work great as a VoIP phone. They support up to 4 &#8220;lines&#8221; or SIP accounts and are very easy to program. For anyone interested in hacking the onboard CPU there is a serial interface available on the PCB &#8211; Look for &#8220;J3&#8221; which is a 5 pin header near the MX T122541 surface mount IC (this chip is a flash memory chip, presumably where the CPU stores it&#8217;s firmware).</p>



<p>With the 5 pin header to your left and the MX T122541 IC to your right, the top pin is GND, moving down the next pin is not used, the next one down is RX, then TX, the bottom pin is VCC (+3.3 volts). The CPU sends booting information from this serial interface, connect it up to your PC and set the terminal software to 9600 baud, 8 bits, no parity and 1 stop bit (96008n1). The easiest way to connect this 3.3v serial port to a PC is by using one of the cheap converter boards found on eBay/Amazon/AliExpress, they can be bought for a few pounds, just search for &#8220;FT232RL PCB&#8221;.</p>



<p>The next chip to the right is labelled WINBOND W9812G6JH-6 and is a 16MB RAM chip. The next chip to the right is labelled TNETV1057ZDW and is a SoC made by Texas Instruments. This is the CPU that runs the firmware for the phone. I was unable to obtain a datasheet for this, however I did manage to get hold of a datasheet for a TNETV1056 which is very similar, I don&#8217;t know the exact differences between the two but if you&#8217;re interested in hacking the chip the datasheet shows it has a JTAG interface.</p>



<p><a href="https://g1fef.co.uk/wp-content/uploads/2025/01/TNETV1056-Data-Manual.pdf" data-type="attachment" data-id="287">You can download the datasheet here</a>.</p>



<p>At the time of writing I had just bought 100 of these phones as a &#8216;job lot&#8217; off eBay, they cost me £4 each and I am happy to sell them at cost. If you&#8217;re interested get in touch, you can either collect from High Wycombe, Buckinghamshire or I will post them at cost. Every phone I sell will be powered up and factory reset beforehand, they are what I would describe as &#8220;Class B&#8221; in that they may have minor signs of use but are generally in good condition, here&#8217;s a photo of one of them&#8230;</p>



<figure class="wp-block-image size-large"><a href="https://g1fef.co.uk/wp-content/uploads/2025/01/IMG_5405-scaled-e1736157473708.jpeg"><img decoding="async" width="1024" height="866" src="https://g1fef.co.uk/wp-content/uploads/2025/01/IMG_5405-scaled-e1736157473708-1024x866.jpeg" alt="" class="wp-image-289" srcset="https://g1fef.co.uk/wp-content/uploads/2025/01/IMG_5405-scaled-e1736157473708-1024x866.jpeg 1024w, https://g1fef.co.uk/wp-content/uploads/2025/01/IMG_5405-scaled-e1736157473708-300x254.jpeg 300w, https://g1fef.co.uk/wp-content/uploads/2025/01/IMG_5405-scaled-e1736157473708-768x649.jpeg 768w, https://g1fef.co.uk/wp-content/uploads/2025/01/IMG_5405-scaled-e1736157473708-1536x1299.jpeg 1536w, https://g1fef.co.uk/wp-content/uploads/2025/01/IMG_5405-scaled-e1736157473708.jpeg 1786w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<h2 class="wp-block-heading">Upgrading the firmware</h2>



<p>To upgrade the firmware you need to plug the phone into a network and power it up. You need to download the firmware from Cisco (it&#8217;s freely available) unzip it and put the .bin file onto a webserver. You then need to point your web browser at the phone&#8217;s IP address (you can find this from the &#8220;Network&#8221; menu on the phone). Click the &#8220;Admin Login&#8221; and &#8220;Advanced&#8221; buttons in the top right. There will now appear a &#8220;Provisioning&#8221; menu &#8211; click this. About halfway down the page there is a field called &#8220;Upgrade Rule:&#8221; enter the URL of the firmware you placed on the webserver here then click the &#8220;Submit All Changes&#8221; button. The phone will now download the firmware and upgrade &#8211; this can take several minutes, so be patient!</p>



<p><strong>NOTE: If your phone&#8217;s current firmware is below version 7.5.2 then you must upgrade to 7.5.2b before you can upgrade to anything higher.</strong></p>



<p>To save time I have placed the firmware on a webserver you can access, the URLs are:</p>



<p>http://p.telgw.uk/spa/spa50x-30x-7-5-2b.bin</p>



<p>http://p.telgw.uk/spa/spa50x-30x-7-6-2g.bin</p>



<p>Version 7.6.2 being the latest available on the Cisco site at the time of writing. This firmware was dated 2020 and as the devices are EOL (End Of Life) I think it unlikely Cisco will be producing any later versions.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>M590E hardware mods</title>
		<link>https://g1fef.co.uk/m590e-hardware-mods/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Wed, 21 Nov 2018 17:03:01 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=200</guid>

					<description><![CDATA[The M590E is a 2G GSM module that, at the time of writing, can be bought as a kit on eBay for around £1 complete with PCB and components. The kit is quite straightforward to build, the only tools you will need are: fine tipped soldering iron, solder and a pair of small wire cutters. [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The M590E is a 2G GSM module that, at the time of writing, can be bought as a kit on eBay for around £1 complete with PCB and components.</p>



<span id="more-200"></span>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3642-scaled.jpg"><img loading="lazy" decoding="async" width="225" height="300" src="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3642-225x300.jpg" alt="" class="wp-image-247" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3642-225x300.jpg 225w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3642-768x1024.jpg 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3642-1152x1536.jpg 1152w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3642-1536x2048.jpg 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3642-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a><figcaption class="wp-element-caption">Fig.1 M590E kit before assembly</figcaption></figure>



<p>The kit is quite straightforward to build, the only tools you will need are: fine tipped soldering iron, solder and a pair of small wire cutters.</p>



<p>Unfortunately the kit, as it stands is not designed particularly well, especially if you want to use it with a 5v system, such as an Arduino. The main problems that need addressing are:</p>



<p>1) The module is designed to be powered from between 3.3v and 4.5v. The kit contains a series diode and suggests you power it from 5v. A forward biased diode will drop approximately 0.7v this powering the module at 4.3v. Using a diode in this manner is not ideal and the data sheet advises the best voltage for the M599E module is 3.9v</p>



<p>2) The power rail for the module has a single 100uF capacitor, the data sheet advises additional capacitors to eliminate rf noise.</p>



<p>3) The serial data receive pin cannot have more than 3.3v applied to it, without risking damage to the module, but the kit simply brings the rxd line straight out to the header pins. It needs some additional circuitry if we are to connect it to a 5v / TTL system.</p>



<p>4) The serial data transmit pin again is brought straight out to the header. The data sheet advises a series resister to protect the module.</p>



<p>See figure 2 for the circuit diagram of the kit before modifications.</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2018/11/M590E.png"><img decoding="async" src="https://g1fef.co.uk/wp-content/uploads/2018/11/M590E-300x212.png" alt="" class="wp-image-223"/></a><figcaption class="wp-element-caption">Fig.2 &#8211; Original PCB Circuit</figcaption></figure>



<p>See figure 3 for the circuit diagram after modifications.</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/M590E-New-1-1.png"><img loading="lazy" decoding="async" width="300" height="212" src="https://g1fef.co.uk/wp-content/uploads/2019/11/M590E-New-1-1-300x212.png" alt="" class="wp-image-238" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/M590E-New-1-1-300x212.png 300w, https://g1fef.co.uk/wp-content/uploads/2019/11/M590E-New-1-1-1024x724.png 1024w, https://g1fef.co.uk/wp-content/uploads/2019/11/M590E-New-1-1-768x543.png 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/M590E-New-1-1-1536x1086.png 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/M590E-New-1-1-2048x1448.png 2048w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><figcaption class="wp-element-caption">Fig.3 Circuit diagram after modifications</figcaption></figure>



<p>To address the first problem, I added an LM317 voltage regulator to the PCB to provide a regulated supply rail. This has the advantage that you can supply the board with any voltage between 6.25v and 44v. The disadvantage is that you cannot power it from 5v which many people may prefer due to the prevalence of low cost 5v power supplies. The LM317 loses between 1.5 and 2.25 volts across it at room temperature, depending on the current being pulled through it (see figure 4 taken from the datasheet).</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2018/11/Screenshot-2019-11-17-at-12.53.50.png"><img loading="lazy" decoding="async" width="300" height="270" src="https://g1fef.co.uk/wp-content/uploads/2018/11/Screenshot-2019-11-17-at-12.53.50-300x270.png" alt="" class="wp-image-257" srcset="https://g1fef.co.uk/wp-content/uploads/2018/11/Screenshot-2019-11-17-at-12.53.50-300x270.png 300w, https://g1fef.co.uk/wp-content/uploads/2018/11/Screenshot-2019-11-17-at-12.53.50.png 454w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><figcaption class="wp-element-caption">Fig. 4 &#8211; Graph of LM317 dropout voltage</figcaption></figure>



<p>I investigated using a low dropout (LDO) regulator, the LM1086 is a pin-compatible replacement that has a maximum of 1.3volts dropout at full load (1.5Amps) and only 1.0volts dropout at 500mA, so it could be used at a push as the M590 module only pulls high currents when it is transmitting and then only in short pulses. If you replace the 100uF capacitor on the PCB with a 1,000uF capacitor you could use an LDO regulator and supply it from 5volts. I have tested this successfully, I used the LM317 because it is cheaper and I intended powering it from a 12volt battery. Incidentally, the LM317 does not require a heatsink due to the intermittent nature of the higher current drawn by the M590 module.</p>



<p>The second issue was addressed by adding a 100nF ceramic capacitor across the 100uF capacitor.</p>



<p>The third issue was addressed by adding a diode and a pull up resistor (D2 &amp; R5) in the second circuit diagram (Figure 3). If you use a surface mount device for R5 it can soldered directly between pins 6 &amp; 7 on the LM590 module. Pin 6 outputs 2.85 volts when the module is running.</p>



<p>The fourth issue is solved by adding a 220R series resistor, R6. The datasheet suggests 200R but 220R is a more commonly available value and works just as well.</p>



<p>The modules I modified were to be used for remote data logging. An Arduino Nano was used to collect the data and sent the data on demand via SMS. I wrote a sketch that waits for a received SMS message, it then sends the current data back via SMS. I wanted the M590 modules to boot up as soon as power was applied, so I soldered the BOOT pin directly to GND. In this configuration the module will boot up as soon as power is applied.</p>



<h2 class="wp-block-heading">Modification Details</h2>



<p class="has-text-align-left">Start by carefully cutting the TX &amp; RX tracks with a Stanley knife:</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-rotated.jpg"><img loading="lazy" decoding="async" width="300" height="300" src="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-300x300.jpg" alt="" class="wp-image-244" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-300x300.jpg 300w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-1024x1024.jpg 1024w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-150x150.jpg 150w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-768x768.jpg 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-1536x1536.jpg 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-2048x2048.jpg 2048w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3602-60x60.jpg 60w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><figcaption class="wp-element-caption">Cut the TXD &amp; RXD tracks</figcaption></figure>



<p class="has-text-align-left">Then add D2 (BAT42) and R6 (220R).</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3605-scaled.jpg"><img loading="lazy" decoding="async" width="225" height="300" src="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3605-225x300.jpg" alt="" class="wp-image-243" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3605-225x300.jpg 225w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3605-768x1024.jpg 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3605-1152x1536.jpg 1152w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3605-1536x2048.jpg 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3605-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a><figcaption class="wp-element-caption">Add D2 &amp; R6</figcaption></figure>



<p><span style="font-size: 16px;">Now you can add C4 (100pF):</span></p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3607-scaled.jpg"><img loading="lazy" decoding="async" width="225" height="300" src="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3607-225x300.jpg" alt="" class="wp-image-242" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3607-225x300.jpg 225w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3607-768x1024.jpg 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3607-1152x1536.jpg 1152w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3607-1536x2048.jpg 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3607-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a><figcaption class="wp-element-caption">Add C4 (100pF)</figcaption></figure>



<p class="has-text-align-left">The LM317 adjustable voltage regulator goes in next:</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3608-scaled.jpg"><img loading="lazy" decoding="async" width="225" height="300" src="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3608-225x300.jpg" alt="" class="wp-image-241" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3608-225x300.jpg 225w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3608-768x1024.jpg 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3608-1152x1536.jpg 1152w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3608-1536x2048.jpg 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3608-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a><figcaption class="wp-element-caption">Add LM317</figcaption></figure>



<p class="has-text-align-left">Now add R3 (1k0) &amp; R3 (2k2), followed by C3 (100nF):</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3625-scaled.jpg"><img loading="lazy" decoding="async" width="225" height="300" src="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3625-225x300.jpg" alt="" class="wp-image-239" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3625-225x300.jpg 225w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3625-768x1024.jpg 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3625-1152x1536.jpg 1152w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3625-1536x2048.jpg 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3625-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a><figcaption class="wp-element-caption">Add R3, R4 &amp; C3</figcaption></figure>



<p class="has-text-align-left">Finally add C2 (100nF) across C1 and R5:</p>



<figure class="wp-block-image alignnone"><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3622-scaled.jpg"><img loading="lazy" decoding="async" width="225" height="300" src="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3622-225x300.jpg" alt="" class="wp-image-240" srcset="https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3622-225x300.jpg 225w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3622-768x1024.jpg 768w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3622-1152x1536.jpg 1152w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3622-1536x2048.jpg 1536w, https://g1fef.co.uk/wp-content/uploads/2019/11/IMG_3622-scaled.jpg 1920w" sizes="auto, (max-width: 225px) 100vw, 225px" /></a><figcaption class="wp-element-caption">Add C2 &amp; R5</figcaption></figure>



<h2 class="wp-block-heading">Testing</h2>



<p>From the photo&#8217;s you can see that I modified a PCB that I had already built. My advice would be to do the modifications BEFORE building the PCB. Once you&#8217;ve done the mods, check the voltage on VBAT (pins 2 &amp; 3 of the M590E module), it should be 4.0 volts (or very nearly).</p>



<p>Now you can add your SIM card, I use GiffGaff (www.giffgaff.co.uk) as they are about the cheapest you can get here in the UK.</p>



<p>I tested the unit by connecting it to my iMac via a TTL to USB board, available from ebay for a couple of pounds. The units default to 115200 baud. Try sending &#8220;AT&#8221; followed by a carriage return, you should see &#8220;OK&#8221; returned if all is well.</p>



<p>Once I had tested it was working on my Mac, I hooked it up to an Arduino Nano using the SoftwareSerial library (built into the core since v1.0). I found, by trial and error, that a baud rate of 38400 is about right: too high and the software serial library starts to miss characters, too low a rate and the Arduino spends too long in interrupts and the main loop is affected.</p>



<h2 class="wp-block-heading">References:</h2>



<p><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/neoway-m590-hardware-design-manual-v1.pdf">neoway-m590-hardware-design-manual-v1</a></p>



<p><a href="https://g1fef.co.uk/wp-content/uploads/2019/11/Neoway_M590_AT_Command_Sets_V3.0.pdf">Neoway_M590_AT_Command_Sets_V3.0</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Turning POE on and off on the Cisco 3750 via SNMP</title>
		<link>https://g1fef.co.uk/turning-poe-on-and-off-on-the-cisco-3750-via-snmp/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sat, 08 Sep 2018 09:03:07 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=193</guid>

					<description><![CDATA[I recently had a requirement to be able to turn the POE power off / on on specific ports on a remote c3750 POE switch in order to reboot devices that kept crashing. I had been remotely logging in via SSH and doing the following to turn the power off on port 1: configure terminal [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I recently had a requirement to be able to turn the POE power off / on on specific ports on a remote c3750 POE switch in order to reboot devices that kept crashing.<br />
<span id="more-193"></span></p>
<p>I had been remotely logging in via SSH and doing the following to turn the power off on port 1:</p>
<pre class="text">

configure terminal
interface FastEthernet1/0/1
power inline never
exit
exit
</pre>
<p>Then after a few seconds:</p>
<pre class="text">

configure terminal
interface FastEhernet1/0/1
no power inline never
exit
exit
</pre>
<p>This got to be a real nuisance so I looked for something that I could script, SNMP seemed the logical choice. The first step is to configure a R/W community string on the switch:</p>
<pre class="text">

configure terminal
snmp-server community MyCommunityString rw
exit
write memory
</pre>
<p>After a bit of digging I found the appropriate OID by using snmpwalk (here we assume my switch is on IP address 1.2.3.4):</p>
<pre class="text">

snmpwalk -v2c -On -c MyCommunityString 1.2.3.4 1.3.6.1.2.1.105.1.1.1.3.1
</pre>
<p>My 24 port switch returned the following:</p>
<p>.1.3.6.1.2.1.105.1.1.1.3.1.3 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.4 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.5 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.6 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.7 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.8 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.9 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.10 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.11 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.12 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.13 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.14 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.15 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.16 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.17 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.18 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.19 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.20 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.21 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.22 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.23 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.24 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.25 = INTEGER: 1<br />
.1.3.6.1.2.1.105.1.1.1.3.1.26 = INTEGER: 1</p>
<p>The port number go from .3 to .26 corresponding to the 24 FastEthernet ports.</p>
<p>The integer values need to be 1 to enable POE and 2 to disable it.</p>
<p>So using snmpset we can turn the power on port 1 off:</p>
<pre class="text">

snmpset -v2c -c MyCommunityString 1.2.3.4 1.3.6.1.2.1.105.1.1.1.3.1.7 i 2
</pre>
<p>and back on again:</p>
<pre class="text">

snmpset -v2c -c MyCommunityString 1.2.3.4 1.3.6.1.2.1.105.1.1.1.3.1.7 i 1
</pre>
<p>That&#8217;s it! Simple really. Adding the commands to a script I will leave to the imagination of the reader&#8230;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Asterisk systemd startup script</title>
		<link>https://g1fef.co.uk/asterisk-systemd-startup-script/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sat, 08 Sep 2018 07:50:29 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=190</guid>

					<description><![CDATA[The systemd startup script &#8220;out of the box&#8221; (at least up to version 15.5) for Asterisk does not work properly: on rebooting the server the ownership of /run/asterisk (symlink /var/run/asterisk) reverts to root.root instead of asterisk.asterisk The reason for this is that the o/s removes and re-creates the /run/asterisk directory on reboot. The solution is [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The systemd startup script &#8220;out of the box&#8221; (at least up to version 15.5) for Asterisk does not work properly: on rebooting the server the ownership of /run/asterisk (symlink /var/run/asterisk) reverts to root.root instead of asterisk.asterisk</p>
<p>The reason for this is that the o/s removes and re-creates the /run/asterisk directory on reboot. The solution is to place a &#8220;RuntimeDirectory=&#8221; entry in the systemd service script:</p>
<p>/usr/lib/systemd/system/asterisk.service</p>
<p>The &#8220;RuntimeDirectory=&#8221; needs a directory name relative to /run so you can&#8217;t do this:</p>
<p>RuntimeDirectory=/run/asterisk</p>
<p>nor this:</p>
<p>RuntimeDirectory=/var/run/asterisk</p>
<p>You need to do this:</p>
<p>RuntimeDirectory=asterisk</p>
<p>Here is my fully working script (/usr/lib/systemd/system/asterisk.service):</p>
<pre class="text">
[Unit]
Description=Asterisk PBX and telephony daemon.
Wants=network.target
After=network.target

[Service]
Type=simple
User=asterisk
Group=asterisk
RuntimeDirectory=asterisk
Environment=HOME=/var/lib/asterisk
WorkingDirectory=/var/lib/asterisk

ExecStart=/usr/sbin/asterisk -f -C /etc/asterisk/asterisk.conf
ExecStop=/usr/sbin/asterisk -rx 'core stop now'
ExecReload=/usr/sbin/asterisk -rx 'core reload'

# safe_asterisk emulation
Restart=always
RestartSec=10

#Nice=0
#UMask=0002
LimitCORE=infinity
#LimitNOFILE=

# Prevent duplication of logs with color codes to /var/log/messages
#StandardOutput=null

PrivateTmp=true

[Install]
WantedBy=multi-user.target
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setup MySQL / MariaDB master slave replication</title>
		<link>https://g1fef.co.uk/setup-mysql-mariadb-master-slave-replication/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sun, 02 Jul 2017 08:21:15 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=176</guid>

					<description><![CDATA[mysql -u root -p &#60; dump.sql How to setup a single master with one or more readonly slaves First configure the master by editing the mysql configuration file, this could be /etc/my.cnf or on Centos 7 it is /etc/my.cnf.d/server.cnf Find the [server] section and add the following lines: bind-address = 12.34.56.78 # replace 12.34.56.78 with [&#8230;]]]></description>
										<content:encoded><![CDATA[<pre class="lang:default decode:true ">mysql -u root -p &lt; dump.sql</pre>
<h4>How to setup a single master with one or more readonly slaves</h4>
<p><span id="more-176"></span></p>
<p>First configure the master by editing the mysql configuration file, this could be /etc/my.cnf or on Centos 7 it is /etc/my.cnf.d/server.cnf</p>
<p>Find the [server] section and add the following lines:</p>
<pre class="text">bind-address = 12.34.56.78 # replace 12.34.56.78 with the IP of your server
log_bin
server_id = 1
log_basename = master1
datadir = /var/lib/mysql
binlog-ignore-db = mysql
</pre>
<p>The binlog-ignore-db line tells the master not to replicate the &#8216;mysql&#8217; database, you can add additional entries to not replicate other databases if you wish, e.g.</p>
<pre class="text">binlog-ignore-db = information_schema
binlog-ignore-db = performance_schema
</pre>
<p>Adding the following additional entries allows you to tweak the performance of your server:</p>
<pre class="text">max_allowed_packet=64M
max_heap_table_size = 64M
tmp_table_size = 128M
join_buffer_size = 128M
innodb_buffer_pool_size = 256M
innodb_doublewrite = OFF
innodb_additional_mem_pool_size = 128M
innodb_flush_log_at_timeout = 4
innodb_read_io_threads = 48
innodb_write_io_threads = 32
max_connections = 128
</pre>
<p>Following any changes to the config files you will need to restart MySQL (or MariaDB if you use that instead), so you would do one of the following:</p>
<pre class="text">systemctl restart mysqld
systemctl restart mariadb
</pre>
<p>Now login to your local MySQL server, e.g.</p>
<pre class="text">mysql -u root -p
</pre>
<p>Once logged into the MySQL CLI add a user that the slaves will use to replicate:</p>
<pre class="text">GRANT REPLICATION SLAVE ON *.* TO 'replication'@'1.2.3.4' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
</pre>
<p>Replace 1.2.3.4 with the IP of your slave server. You can run the above command multiple times, once for each slave server. Remember to change &#8216;password&#8217; to an actual password, a good choice would be 12 (or more) characters consisting of a random mix of upper/lowercase letters, numbers and punctuation characters.</p>
<p>Now we&#8217;re ready to take a backup of the master, for this you will need to open a second session on your master server. In the first session, still logged into the MySQL CLI issue the following commands:</p>
<pre class="text">FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
</pre>
<p>You should see something along these lines:</p>
<pre class="text">+--------------------+----------+--------------+------------------+
| File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| master1-bin.000001 |   456    |              | mysql            |
+--------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
</pre>
<p>Leave this session in place whilst you move to the second session to backup the databases you want to replicate by using your preferred method, e.g.</p>
<pre class="text">mysqldump -u root -p --all-databases &gt; dump.sql
</pre>
<p>Now you can go back to the first window and release the lock:</p>
<pre class="text">UNLOCK TABLES;
QUIT;
</pre>
<p>Now copy this backup to your slave server(s). I use scp for this, e.g.</p>
<pre class="text">scp dump.sql username@12.34.56.78:.
</pre>
<p>Now login to the slave server and import the dumped databases:</p>
<p>mysql -u root -p &lt; dump.sql</p>
<p>Now configure MySQL (or mariadb) to be a slave by editing it&#8217;s configuration file, e.g. /etc/my.cnf.d/server.cnf and add the following to the [server] section:</p>
<pre class="text">server-id = 2
datadir = /var/lib/mysql
relay-log = /var/lib/mysql/mysql-relay-bin.log
log_bin = /var/lib/mysql/mysql-bin.log
</pre>
<p>As per the master server, following any changes to the config files you will need to restart MySQL (or MariaDB if you use that instead), so you would do one of the following:</p>
<pre class="text">systemctl restart mysqld
systemctl restart mariadb
</pre>
<p>The next step is to login to the MySQL CLI and tell it where to find the master along with the login details and the starting position in the log:</p>
<pre class="text">CHANGE MASTER TO MASTER_HOST='12.34.56.78',MASTER_USER='replication', MASTER_PASSWORD='password', MASTER_LOG_FILE='master1-bin.000001', MASTER_LOG_POS=456;
</pre>
<p>The last thing we need to do is start the slave process, and check it is running. Do this by issuing the following commands on the slave MySQL CLI:</p>
<pre class="text">START SLAVE;
SHOW SLAVE STATUS\G
</pre>
<p>You can repeat the slave part on each server you want to setup replication, just remember to give each slave a different server_id</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting up and using your own SSL CA</title>
		<link>https://g1fef.co.uk/setting-using-ssl-ca/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Wed, 31 May 2017 18:09:02 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=146</guid>

					<description><![CDATA[This guide shows how to setup a Certificate Authority on Centos 7 Setup the file structure: mkdir /root/ca cd /root/ca mkdir certs crl newcerts private chmod 700 private touch index.txt echo 1000 &#62; serial Create a config file /root/ca/openssl.cnf # OpenSSL root CA configuration file. # Copy to `/root/ca/openssl.cnf`. [ ca ] # `man ca` [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>This guide shows how to setup a Certificate Authority on Centos 7</h4>
<p><span id="more-146"></span></p>
<p>Setup the file structure:</p>
<pre class="SCREEN">mkdir /root/ca
cd /root/ca
mkdir certs crl newcerts private
chmod 700 private
touch index.txt
echo 1000 &gt; serial
</pre>
<p>Create a config file /root/ca/openssl.cnf</p>
<pre class="SCREEN"># OpenSSL root CA configuration file.
# Copy to `/root/ca/openssl.cnf`.

[ ca ]
# `man ca`
default_ca = CA_default

[ CA_default ]
# Directory and file locations.
dir               = /root/ca
certs             = $dir/certs
crl_dir           = $dir/crl
new_certs_dir     = $dir/newcerts
database          = $dir/index.txt
serial            = $dir/serial
RANDFILE          = $dir/private/.rand

# The root key and root certificate.
private_key       = $dir/private/ca.key.pem
certificate       = $dir/certs/ca.cert.pem

# For certificate revocation lists.
crlnumber         = $dir/crlnumber
crl               = $dir/crl/ca.crl.pem
crl_extensions    = crl_ext
default_crl_days  = 30

# SHA-1 is deprecated, so use SHA-2 instead.
default_md        = sha256

name_opt          = ca_default
cert_opt          = ca_default
default_days      = 375
preserve          = no
policy            = policy_strict

[ policy_strict ]
# The root CA should only sign intermediate certificates that match.
# See the POLICY FORMAT section of `man ca`.
countryName             = match
stateOrProvinceName     = match
organizationName        = match
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

[ policy_loose ]
# Allow the intermediate CA to sign a more diverse range of certificates.
# See the POLICY FORMAT section of the `ca` man page.
countryName             = optional
stateOrProvinceName     = optional
localityName            = optional
organizationName        = optional
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

[ req ]
# Options for the `req` tool (`man req`).
default_bits        = 2048
distinguished_name  = req_distinguished_name
string_mask         = utf8only

# SHA-1 is deprecated, so use SHA-2 instead.
default_md          = sha256

# Extension to add when the -x509 option is used.
x509_extensions     = v3_ca

[ req_distinguished_name ]
# See &lt;https://en.wikipedia.org/wiki/Certificate_signing_request&gt;.
countryName                     = Country Name (2 letter code)
stateOrProvinceName             = State or Province Name
localityName                    = Locality Name
0.organizationName              = Organization Name
organizationalUnitName          = Organizational Unit Name
commonName                      = Common Name
emailAddress                    = Email Address

# Optionally, specify some defaults.
countryName_default             = GB
stateOrProvinceName_default     = Buckinghamshire
localityName_default            = High Wycombe
0.organizationName_default      = The Communication Gateway Ltd
organizationalUnitName_default  = Main Office
emailAddress_default            = postmaster@comgw.co.uk

[ v3_ca ]
# Extensions for a typical CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

[ v3_intermediate_ca ]
# Extensions for a typical intermediate CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true, pathlen:0
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

[ usr_cert ]
# Extensions for client certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = client, email
nsComment = "OpenSSL Generated Client Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth, emailProtection

[ server_cert ]
# Extensions for server certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = server
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth

[ crl_ext ]
# Extension for CRLs (`man x509v3_config`).
authorityKeyIdentifier=keyid:always

[ ocsp ]
# Extension for OCSP signing certificates (`man ocsp`).
basicConstraints = CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, digitalSignature
extendedKeyUsage = critical, OCSPSigning
</pre>
<p>Now we can generate the root key:</p>
<pre class="SCREEN">openssl genrsa -aes256 -out private/ca.key.pem 4096
chmod 400 private/ca.key.pem
</pre>
<p>Create the root certificate:</p>
<pre class="SCREEN">openssl req -config openssl.cnf \
      -key private/ca.key.pem \
      -new -x509 -days 7300 -sha256 -extensions v3_ca \
      -out certs/ca.cert.pem
chmod 444 certs/ca.cert.pem
</pre>
<p>Verify the root certificate:</p>
<pre class="SCREEN">openssl x509 -noout -text -in certs/ca.cert.pem
</pre>
<p>Create the intermediate certificate:</p>
<pre class="SCREEN">mkdir /root/ca/intermediate
cd /root/ca/intermediate
mkdir certs crl csr newcerts private
chmod 700 private
touch index.txt
echo 1000 &gt; serial
</pre>
<p>Add a crlnumber file to the intermediate CA directory tree. crlnumber is used to keep track of certificate revocation lists:</p>
<pre class="SCREEN">echo 1000 &gt; /root/ca/intermediate/crlnumber
</pre>
<p>Copy the intermediate CA configuration file: /root/ca/intermediate/openssl.cnf from the main one we created above and alter the following settings:</p>
<pre class="SCREEN">[ CA_default ]
dir             = /root/ca/intermediate
private_key     = $dir/private/intermediate.key.pem
certificate     = $dir/certs/intermediate.cert.pem
crl             = $dir/crl/intermediate.crl.pem
policy          = policy_loose
</pre>
<p>Create the intermediate key:</p>
<pre class="SCREEN">cd /root/ca
openssl genrsa -aes256 \
      -out intermediate/private/intermediate.key.pem 4096
chmod 400 intermediate/private/intermediate.key.pem
</pre>
<p>Create the intermediate certificate:<br />
Use the intermediate key to create a certificate signing request (CSR). The details should generally match the root CA. The Common Name, however, must be different.</p>
<pre class="SCREEN">cd /root/ca
openssl req -config intermediate/openssl.cnf -new -sha256 \
      -key intermediate/private/intermediate.key.pem \
      -out intermediate/csr/intermediate.csr.pem
</pre>
<p>To create an intermediate certificate, use the root CA with the v3_intermediate_ca extension to sign the intermediate CSR. The intermediate certificate should be valid for a shorter period than the root certificate.</p>
<pre class="SCREEN">cd /root/ca
openssl ca -config openssl.cnf -extensions v3_intermediate_ca \
      -days 3650 -notext -md sha256 \
      -in intermediate/csr/intermediate.csr.pem \
      -out intermediate/certs/intermediate.cert.pem
chmod 444 intermediate/certs/intermediate.cert.pem
</pre>
<p>The index.txt file is where the OpenSSL ca tool stores the certificate database. Do not delete or edit this file by hand. It should now contain a line that refers to the intermediate certificate.</p>
<p>Verify the intermediate certificate:</p>
<pre class="SCREEN">openssl x509 -noout -text \
      -in intermediate/certs/intermediate.cert.pem
</pre>
<p>Verify the intermediate certificate against the root certificate. An OK indicates that the chain of trust is intact.</p>
<pre class="SCREEN">openssl verify -CAfile certs/ca.cert.pem \
      intermediate/certs/intermediate.cert.pem
</pre>
<p>Create the certificate chain file:</p>
<pre class="SCREEN">cat intermediate/certs/intermediate.cert.pem \
      certs/ca.cert.pem &gt; intermediate/certs/ca-chain.cert.pem
chmod 444 intermediate/certs/ca-chain.cert.pem
</pre>
<p>NOTE: Our certificate chain file must include the root certificate because no client application knows about it yet. A better option, particularly if you’re administrating an intranet, is to install your root certificate on every client that needs to connect. In that case, the chain file need only contain your intermediate certificate.</p>
<p>We can now sign client and server certificates!</p>
<p>Create a key:</p>
<pre class="SCREEN">cd /root/ca
openssl genrsa -aes256 \
      -out intermediate/private/www.example.com.key.pem 2048
chmod 400 intermediate/private/www.example.com.key.pem
</pre>
<p>If you don&#8217;t want a prompt for a password each time the certificate is used leave out the -aes256 parameter.</p>
<p>Create a certificate Signing Request:</p>
<pre class="SCREEN">cd /root/ca
openssl req -config intermediate/openssl.cnf \
      -key intermediate/private/www.example.com.key.pem \
      -new -sha256 -out intermediate/csr/www.example.com.csr.pem
</pre>
<p>Sign the CSR:</p>
<pre class="SCREEN">cd /root/ca
openssl ca -config intermediate/openssl.cnf \
      -extensions server_cert -days 375 -notext -md sha256 \
      -in intermediate/csr/www.example.com.csr.pem \
      -out intermediate/certs/www.example.com.cert.pem
chmod 444 intermediate/certs/www.example.com.cert.pem
</pre>
<p>Verify the certificate:</p>
<pre class="SCREEN">openssl x509 -noout -text \
      -in intermediate/certs/www.example.com.cert.pem
</pre>
<p>Verify the chain of trust:</p>
<pre class="SCREEN">openssl verify -CAfile intermediate/certs/ca-chain.cert.pem \
      intermediate/certs/www.example.com.cert.pem
</pre>
<p>Deploy the certificate:<br />
ca-chain.cert.pem<br />
www.example.com.key.pem<br />
www.example.com.cert.pem</p>
<p>Reference:<br />
https://jamielinux.com/docs/openssl-certificate-authority/introduction.html</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Centos 7 + Postfix + Amavisd-new + Clamav + OpenDKIM + OpenDMARC</title>
		<link>https://g1fef.co.uk/centos-7-postfix-amavisd-new-clamav/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sun, 28 May 2017 16:55:39 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=96</guid>

					<description><![CDATA[How to setup Postfix, Amavisd-new, Clamav, OpenDKIM &#038; OpenDMARC on Centos 7 Just in case, remove sendmail and install postfix: yum remove sendmail yum install postfix Make sure it starts on reboot: systemctl enable postfix Install amavis and clamav and make sure it starts on reboot: yum install amvisd-new clamav clamav-scanner-systemd systemctl enable amavisd Fix [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to setup Postfix, Amavisd-new, Clamav, OpenDKIM &#038; OpenDMARC on Centos 7</h4>
<p><span id="more-96"></span></p>
<ol>
<li style="list-style-type: none">
<ol>Just in case, remove sendmail and install postfix:</ol>
</li>
</ol>
<pre class="SCREEN">yum remove sendmail
yum install postfix
</pre>
<p>Make sure it starts on reboot:</p>
<pre class="SCREEN">systemctl enable postfix
</pre>
<p>Install amavis and clamav and make sure it starts on reboot:</p>
<pre class="SCREEN">yum install amvisd-new clamav clamav-scanner-systemd
systemctl enable amavisd
</pre>
<p>Fix the issue with clamd not starting:</p>
<pre class="SCREEN">cd /usr/lib/systemd/system
cp clamd\@scan.service clamd\@amavisd.service

systemctl start clamd@amavisd
systemctl enable clamd@amavisd
systemctl restart amavisd
</pre>
<p>Install OpenDKIM:</p>
<pre class="SCREEN">yum install opendkim
</pre>
<p>Create keys and check:</p>
<pre class="SCREEN">opendkim-default-keygen
cd /etc/opendkim/keys/
ll
</pre>
<p>Edit the following files:<br />
/etc/opendkim.conf (Main configuration file for opendkim)<br />
/etc/opendkim/KeyTable (Defines the path of private key for the domain)<br />
/etc/opendkim/SigningTable (Tells OpenDKIM how to apply the keys)<br />
/etc/opendkim/TrustedHosts (Defines which hosts are allowed to use keys)</p>
<p>If you&#8217;re just verifying incoming mail you don&#8217;t actually need to edit any of the above files, the defaults are fine.</p>
<p>Start and enable on reboot:</p>
<pre class="SCREEN">systemctl start opendkim
systemctl enable opendkim
</pre>
<p>Next you need to add the following lines to your Postfix main.cf</p>
<pre class="SCREEN">smtpd_milters = inet:127.0.0.1:8891
non_smtpd_milters = $smtpd_milters
milter_default_action = accept
</pre>
<p>and restart Postfix.</p>
<p>Now we can install OpenDMARC:</p>
<pre class="SCREEN">yum install opendmarc
</pre>
<p>Edit the file /etc/opendmarc.conf and uncomment the line<br />
# AuthservID name<br />
and set &#8220;name&#8221; to the hostname of your server.</p>
<p>Now enable it on reboot and fire it up:</p>
<pre class="SCREEN">systemctl enable opendmarc
systemctl start opendmarc
</pre>
<p>Now we need to hook it into Postfix, just add the port in main.cf as for opendkim above, i.e. the line in main.cf should now read:</p>
<pre class="SCREEN">smtpd_milters = inet:127.0.0.1:8891, inet:127.0.0.1:8893
</pre>
<p>This will pass incoming mail through OpenDKIM first, then OpenDMARC.</p>
<p>It&#8217;s a good idea to enable the PublicSuffixList in the opendmarc.conf file and create a weekly cronjob to keep the list up to date, so create the file /etc/cron.weekly/opendmarc</p>
<pre class="SCREEN">#!/bin/sh
#
#Get latest effective_tld_names for OpenDMARC
/usr/bin/wget --no-check-certificate -q -N -P /etc/opendmarc https://publicsuffix.org/list/effective_tld_names.dat
</pre>
<p>and restart Postfix.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting up a Galera MariaDB Cluster</title>
		<link>https://g1fef.co.uk/setting-galera-mariadb-cluster/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Sat, 27 May 2017 05:58:55 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=89</guid>

					<description><![CDATA[How to setup a Galera MariaDB Cluster Remove any existing packages: yum remove maria* Update: yum update Add the official repo for MariaDB by creating the file /etc/yum.repos.d/MariaDB.repo [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 Now install MariaDB: yum install -y MariaDB-server MariaDB-client MariaDB-compat galera socat jemalloc Setup MariaDB: systemctl start mariadb mysql_secure_installation [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to setup a Galera MariaDB Cluster</h4>
<p><span id="more-89"></span></p>
<p>Remove any existing packages:</p>
<pre class="SCREEN">
yum remove maria*
</pre>
<p>Update:</p>
<pre class="SCREEN">
yum update
</pre>
<p>Add the official repo for MariaDB by creating the file /etc/yum.repos.d/MariaDB.repo</p>
<pre class="SCREEN">
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
</pre>
<p>Now install MariaDB:</p>
<pre class="SCREEN">
yum install -y MariaDB-server MariaDB-client MariaDB-compat galera socat jemalloc
</pre>
<p>Setup MariaDB:</p>
<pre class="SCREEN">
systemctl start mariadb
mysql_secure_installation
systemctl stop mariadb
</pre>
<p>To generate the CA certificate:</p>
<pre class="SCREEN">
openssl genrsa 2048 > ca-key.pem
openssl req -new -x509 -nodes -days 3600 -key ca-key.pem -out ca.pem
</pre>
<p>To generate the server certificate, remove passphrase, and sign it:</p>
<pre class="SCREEN">
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout server-key.pem -out server-req.pem
openssl rsa -in server-key.pem -out server-key.pem
openssl x509 -req -in server-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial -1 -out server-cert.pem
</pre>
<p>(Optional) To generate the client certificate, remove passphrase, and sign it:</p>
<pre class="SCREEN">
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout client-key.pem -out client-req.pem
openssl rsa -in client-key.pem -out client-key.pem
openssl x509 -req -in client-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem
</pre>
<p>Edit the file: /etc/my.cnf.d/server.cnf</p>
<pre class="SCREEN">
[sst]
encrypt=4
ssl-ca=/etc/pki/ca.pem
ssl-cert=/etc/pki/server-cert.pem
ssl-key=/etc/pki/server-key.pem

[galera]
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address='gcomm://a.a.a.a,b.b.b.b,c.c.c.c'
wsrep_cluster_name='cluster.name'
wsrep_node_address='10.0.0.11'
wsrep_node_name='node1'
wsrep_sst_method=rsync
wsrep_sst_receive_address='x.x.x.x'
wsrep_provider_options='socket.ssl_key=/etc/pki/server-key.pem;socket.ssl_cert=/etc/pki/server-cert.pem;socket.ssl_ca=/etc/pki/ca.pem;evs.inactive_timeout=PT45S;evs.install_timeout=PT45S;evs.keepalive_period=PT3S;evs.max_install_timeouts=8;evs.send_window=512;evs.suspect_timeout=PT30S;evs.user_send_window=256;'
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
</pre>
<p>In the file above the line &#8220;wsrep_sst_receive_address=&#8217;x.x.x.x'&#8221; is required if any of the nodes are behind a NAT router on private IP addresses, where x.x.x.x is the public IP address of the router. Without this SST donors will try to send snapshot data to the nodes private IP address which will invariably fail.</p>
<p>The &#8220;wsrep_provider_options&#8221; are tailored to for nodes that talk to each other over a WAN (i.e. the internet). If your nodes are all on the same LAN then you can leave this option out completely &#8211; it adjusts some timeout default values to better cope with varying connectivity quality across a WAN.</p>
<p>Start the primary node:</p>
<pre class="SCREEN">
galera_new_cluster
</pre>
<p>Start the other nodes:</p>
<pre class="SCREEN">
systemctl start mariadb
</pre>
<p>Login to any of the nodes and check status:</p>
<pre class="SCREEN">
show status like 'wsrep%';
</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Update MediWiki</title>
		<link>https://g1fef.co.uk/update-mediwiki/</link>
		
		<dc:creator><![CDATA[G1FEF]]></dc:creator>
		<pubDate>Thu, 11 May 2017 12:42:26 +0000</pubDate>
				<category><![CDATA[System admin]]></category>
		<guid isPermaLink="false">https://g1fef.co.uk/?p=82</guid>

					<description><![CDATA[How to update MediaWiki Put wiki into readonly mode by editing the LocalSettings.php file and adding the line: $wgReadOnly = 'Wiki is currently undergoing maintenance, as a result it is in read only mode for a while'; Backup the SQL database, e.g. mysqldump -h host -u wiki -p wiki > wiki.sql Backup the entire wiki [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4>How to update MediaWiki</h4>
<p><span id="more-82"></span></p>
<p>Put wiki into readonly mode by editing the LocalSettings.php file and adding the line:</p>
<pre class="SCREEN">
$wgReadOnly = 'Wiki is currently undergoing maintenance, as a result it is in read only mode for a while';
</pre>
<p>Backup the SQL database, e.g. mysqldump -h host -u wiki -p wiki > wiki.sql</p>
<p>Backup the entire wiki folder:</p>
<pre class="SCREEN">
mkdir backups/20170218
cp -rp http/* backups/20170218/.
</pre>
<p>Download latest version of MediaWiki from www.mediawiki.org/wiki/Download e.g.</p>
<pre class="SCREEN">
wget https://releases.wikimedia.org/mediawiki/1.28/mediawiki-1.28.2.tar.gz
</pre>
<p>Unpack the file over the existing installation:</p>
<pre class="SCREEN">
tar zxvf mediawiki-1.28.2.tar.gz -C http/w --strip-components=1
</pre>
<p>Now run the update:</p>
<pre class="SCREEN">
cd http/w/maintenance
php update.php
</pre>
<p>Don&#8217;t forget to take it out of readonly mode by removing or commenting out the $wgReadOnly line in LocalSettings.php</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
