<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[mattpearson blog]]></title><description><![CDATA[computer science and quantiative finance]]></description><link>https://mattpearson.github.io</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Dec 2016 22:05:01 GMT</lastBuildDate><atom:link href="https://mattpearson.github.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[S&P500 December Seasonality]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>As we approach the last weeks of the year, something to keep in mind for December&#8217;s seasonality. X axis is day of month, and Y axis is cumulative return of S&amp;P500 over December for years 1953 to 2016.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://mattpearson.github.io/images/dec_seasonality.png" alt="dec seasonality.png">
</div>
</div>
<div class="paragraph">
<p>Average returns are nice, but knowing how volatilite it is would also be good to know. Utilizing a pivot table to calculate, the annualized standard deviation for each day is plotted below:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://mattpearson.github.io/images/dec_seasonality_std.png" alt="dec seasonality std.png">
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_python_code">Python Code</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-python" data-lang="python">import datetime
import pandas_datareader as web
import pandas as pd
import numpy as np

gspc = web.DataReader( '^GSPC', 'yahoo', datetime.datetime(1953,1,1), datetime.datetime(2016, 12, 10))

df = pd.DataFrame( [ gspc['Adj Close'] ] ).transpose()
df.columns=['SPY']
r = df['SPY'].pct_change().shift(-1)
df['SpyRet'] = r
df['DOM'] = df.index.day
df['Month'] = df.index.month

df_dec = df[ df['Month'] == 12 ]
t = pd.pivot_table( df_dec, values='SpyRet', columns='DOM', aggfunc=np.mean)
(t.cumsum()*100.0).plot( grid=True)

t = pd.pivot_table( df_dec, values='SpyRet', columns='DOM', aggfunc=np.std)
(t*np.sqrt(252)*100).plot( grid=True, title='December Return Annualized Volatility By Day')</code></pre>
</div>
</div>
</div>]]></description><link>https://mattpearson.github.io/2016/12/11/S-P00-December-Seasonality.html</link><guid isPermaLink="true">https://mattpearson.github.io/2016/12/11/S-P00-December-Seasonality.html</guid><pubDate>Sun, 11 Dec 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Decoding CME's MDP 3.0]]></title><description><![CDATA[<div class="paragraph">
<p>MDP stands for Market Data Protocol, and CME is on their third revision of it. In this latest revision, they decomissioned <a href="https://en.wikipedia.org/wiki/FAST_protocol">FAST</a> encoding and replaced it with SBE, which stands for Simple Binary Encoding. <a href="http://www.real-logic.co.uk/">Real Logic</a>, a firm based in the UK, has developed an example SBE implementation that generates code in both Java and C++ from a SBE template file. CME&#8217;s confluence wiki page has a good <a href="https://goo.gl/EegRYL">primer</a> on SBE and is a must-read for anybody serious in connecting with CME&#8217;s market data feed.</p>
</div>
<div class="paragraph">
<p>Once you are familiar with SBE you can jump right in to see the different types of messages by perusing their <a href="ftp://ftp.cmegroup.com/SBEFix/NRCert/Templates/templates_FixBinary.xml">template</a> file.</p>
</div>
<div class="paragraph">
<p>Note, Real Logic&#8217;s tool requires that you have Java JDK installed, so if you don&#8217;t, then run:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">su -c "yum install java-1.8.0-openjdk-devel"</code></pre>
</div>
</div>
<div class="paragraph">
<p>Next, use git to download and install Real Logic&#8217;s simple binary encoding example implementation. The following linux commands will walk you through getting the latet snapshot from their github repository, building the software, downloading the CME SBE template file, and generating C++ code that implements SBE to the CME&#8217;s spec.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">$ git clone https://github.com/real-logic/simple-binary-encoding.git
$ ./gradlew
$ cd ./sbe-tool/build/libs
$ wget ftp://ftp.cmegroup.com/SBEFix/NRCert/Templates/templates_FixBinary.xml
$ java -jar -Dsbe.target.language=cpp -Dsbe.keyword.append.token=_ sbe-tool-1.5.2-SNAPSHOT-all.jar templates_FixBinary.xml</code></pre>
</div>
</div>
<div class="paragraph">
<p>Once these commands are completed, you will have a new folder called 'mktdata' with classes (using the namespace 'mktdata') created for you by the Real Logic SBE tool using the CME-provided template file.</p>
</div>
<div class="paragraph">
<p>A huge plus is that it supports and utilizes C++11 <a href="http://blog.smartbear.com/c-plus-plus/the-biggest-changes-in-c11-and-why-you-should-care/">features</a>.</p>
</div>]]></description><link>https://mattpearson.github.io/2016/10/07/Decoding-CM-E-MDP-30.html</link><guid isPermaLink="true">https://mattpearson.github.io/2016/10/07/Decoding-CM-E-MDP-30.html</guid><pubDate>Fri, 07 Oct 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Hedging Factors]]></title><description><![CDATA[<div class="sect3">
<h4 id="_review">Review</h4>
<div class="paragraph">
<p>The CAPM suggests that a firm&#8217;s expected excess return (Ri) above the risk-free rate (Rf) is simply a scaled version of the market portfolio (Rm) expected excess return. Risk-free rate can be the rate of return on US treasury bonds. In other words:  ( Ri - Rf ) = scaling factor * ( Rm - Rf ). Put differently,</p>
</div>
<div class="paragraph">
<p>( Ri - Rf ) = alpha + beta * ( Rm - Rf ).</p>
</div>
<div class="paragraph">
<p>Gene Fama and Ken French argued convincingly that there are additional risk factors that can better describe the expected excess return, namely a size premium (SMB) and a value premium (HML). Recent research has shown that the expected return can further be improved with additional factors beyond size and value. Cliff Asness eloquently  <a href="https://www.aqr.com/cliffs-perspective/our-model-goes-to-six-and-saves-value-from-redundancy-along-the-way">describes them</a> as follows:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Premium Factors</p>
<div class="ulist">
<ul>
<li>
<p>RM-RF - The return spread between the capitalization weighted stock market and cash.</p>
</li>
<li>
<p>SMB - The return spread of small minus large stocks (i.e., the size effect).</p>
</li>
<li>
<p>HML - The return spread of cheap minus expensive stocks (i.e., the value effect).</p>
</li>
<li>
<p>RMW - The return spread of the most profitable firms minus the least profitable.</p>
</li>
<li>
<p>CMA - The return spread of firms that invest conservatively minus aggressively.</p>
</li>
</ul>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>With this knowledge, how can you evaluate the exposure a portfolio has to these risk factors?</p>
</div>
</div>
<div class="sect3">
<h4 id="_regression">Regression</h4>
<div class="paragraph">
<p>By re-expressing the CAPM to use the additional risk factors, the regression can be expressed as:</p>
</div>
<div class="paragraph">
<p>( Ri - Rf ) = alpha + beta1 * ( Rm - Rf ) + beta2 * HML + beta3 * SMB + beta4 * RWM + beta5 * CMA</p>
</div>
<div class="paragraph">
<p>Ken French maintains a library of factors for doing exactly these kinds of regressions. You can access it <a href="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html">here</a>.</p>
</div>
<div class="paragraph">
<p>One of the most famous portfolio managers of the 20th century is Peter Lynch, who was the PM for Fidelity&#8217;s Magellan Fund. What were his factor exposures during the time he was managing the fund, from 1977 to 1990?</p>
</div>
<div class="paragraph">
<p>The regression results follow:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://mattpearson.github.io/images/magellan_fivefactors.PNG" alt="magellan fivefactors.PNG">
</div>
</div>
<div class="paragraph">
<p>Obviously, his fund had a statistically strong positive relationship with the market (MKT-RF), and clearly a statistically strong negative relationship with HML and RMW factors. The negative relationship with HML suggests he was exposed to more growth stocks than value stocks, and firms that were least profitable rather than most profitable. Given the small t-statistics to SMB and CMA we can not make statistically significant conclusions as to his portfolio&#8217;s exposures to these risk factors.</p>
</div>
<div class="paragraph">
<p>Remember when you are running such regressions, subtract out the risk free rate from the returns of the market and the security or fund you are analyzing. While the current ZIRP regime we&#8217;re currently in won&#8217;t make much of a difference, when you go back to the 80s and 90s it definitely will.</p>
</div>
</div>
<div class="sect3">
<h4 id="_how_to_hedge">How to hedge?</h4>
<div class="paragraph">
<p>The analysis above, the risk factors are not tradable. Within the past few years, however, there has been a large increase in the number of exchange traded funds that provide factor exposure. If you, as an investor in the Magellan fund, wanted to hedge the exposure to growth stocks (HML factor), you can simply buy $0.30 worth of a fund that tracks HML for each $1.00 that is invested in Magellan:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://mattpearson.github.io/images/magellan_fivefactors_hedge.PNG" alt="magellan fivefactors hedge.PNG">
</div>
</div>
<div class="paragraph">
<p>After running the same regression, you can now see that the coefficient and t-statistic for the HML factor are effectively zero. In practice, use an ETF that is both easily shortable with low short-rate fee to achieve the best results.</p>
</div>
</div>
<div class="sect3">
<h4 id="_python_code">Python Code</h4>
<div class="paragraph">
<p>This code is adapted from the solid work by <a href="https://github.com/nakulnayyar/FF3Factor">nakulnayyar</a>. It has been changed to use the new five factor model, and show an example of hedging.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-python" data-lang="python">import pandas as pd
import numpy as np
from StringIO import StringIO
from zipfile import ZipFile
from urllib import urlopen
import pandas.io.data as web
import statsmodels.api as sm
url = urlopen("http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_5_Factors_2x3_CSV.zip")
zipfile = ZipFile(StringIO(url.read()))
FFdata = pd.read_csv(zipfile.open('F-F_Research_Data_5_Factors_2x3.CSV'),
                     header = 0, names = ['Date','MKT-RF','SMB','HML','RMW','CMA','RF'],
                     skiprows=3)

FFdata = FFdata[:638]

//#Convert YYYYMM into Date
FFdata['Date'] = pd.to_datetime(FFdata['Date'], format = "%Y%m")
FFdata.index = FFdata['Date']
FFdata.drop(FFdata.columns[0], axis=1,inplace=True)

#Drop Days in YYYY-MM-DD
FFdata.index = FFdata.index.map(lambda x: x.strftime('%Y-%m'))

#Convert into float
FFdata = FFdata.astype('float')
FFdata.tail()

#Get Data from Yahoo
start = datetime(1980,1,1)
end = datetime(1990,10,1)
f = web.get_data_yahoo("FMAGX", start, end, interval='m')

#Delete Columns
f.drop(f.columns[[0,1,2,3,4]], axis=1, inplace=True)
#Fix Date Column
f.index = f.index.map(lambda x: x.strftime('%Y-%m'))

f['Return'] = f['Adj Close'].pct_change().shift(0) * 100.0
f.head()



data2 = pd.concat([f,FFdata], axis = 1)
data2['XRtrn'] = (data2['Return'] - data2['RF'])
df = data2[np.isfinite(data2['XRtrn'])]
df.tail()


y = df['XRtrn']


X = df.ix[:,[2,3,4,5,6]]
X = sm.add_constant(X)
model = sm.OLS(y, X)
results = model.fit()
print(results.summary())

y.plot()

#Hedge HML
y1 = y - results.params[3] * df['HML']

model = sm.OLS(y1, X)
results = model.fit()
print(results.summary())</code></pre>
</div>
</div>
</div>]]></description><link>https://mattpearson.github.io/2016/09/27/Hedging-Factors.html</link><guid isPermaLink="true">https://mattpearson.github.io/2016/09/27/Hedging-Factors.html</guid><pubDate>Tue, 27 Sep 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[Linux Security]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>What should be the first thing you do with a new linux installation? Make it more secure! They include:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Disable root login from sshd</p>
</li>
<li>
<p>Allow authentication only through pre-configured ssh keys.</p>
</li>
<li>
<p>Install fail2ban</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_sshd_changes">sshd changes</h2>
<div class="sectionbody">
<div class="paragraph">
<p>First, edit /etc/ssh/sshd_config  (sudo vi /etc/ssh/sshd_config), and change</p>
</div>
<div class="literalblock">
<div class="content">
<pre>#PermitRootLogin yes
#AuthorizedKeysFile      .ssh/.authorized_keys</pre>
</div>
</div>
<div class="paragraph">
<p>to</p>
</div>
<div class="literalblock">
<div class="content">
<pre>PermitRootLogin no
AuthorizedKeysFile      .ssh/.authorized_keys</pre>
</div>
</div>
<div class="paragraph">
<p>Next, generate a ssh key on your local computer for authentication. There are plenty of how-to guides to do this (such as <a href="https://devops.profitbricks.com/tutorials/use-ssh-keys-with-putty-on-windows/" class="bare">https://devops.profitbricks.com/tutorials/use-ssh-keys-with-putty-on-windows/</a>  for Windows and <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys&#8212;&#8203;2" class="bare">https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys&#8212;&#8203;2</a> for linux) but the essence is as follows for Windows users:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Download PuTTYgen and generate a key.</p>
</li>
<li>
<p>For "key comment", enter your username</p>
</li>
<li>
<p>For "key passphrase", you can enter a passphrase for extra security if wanted.</p>
</li>
<li>
<p>click "Save private key" and note location and filename.</p>
</li>
<li>
<p>In PuTTY, create a new session, and go to Connection&#8594;SSH&#8594;Auth&#8594;Browse and choose your private key.  Save this session with the IP address.</p>
</li>
<li>
<p>On your linux box, edit ~/.ssh/.authorized_keys and paste in the content stored in PuTTYgen section titled "Public key for pasting into OpenSSH authorized_keys file". Make sure you copy ALL of it, including the beginning "ssh-rsa" text, AND the ending text after the "==" symbols.</p>
</li>
<li>
<p>Confirm the .authorized_keys file is mode 600 (chmod 600 .authorized_keys).</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Wrap up these changes with a sshd restart:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>sudo service sshd restart</pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_fail2ban">fail2ban</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Fail2ban is a service that modifies your iptables rules based on activity that is seen in your log files. If someone attempts to repeatedly log in with incorrect credentials, you can choose to have their IP banned from connecting again for a period of time. A good how-to guide for installing and configuring fail2ban is here:</p>
</div>
<div class="paragraph">
<p><a href="https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-centos-7" class="bare">https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-centos-7</a></p>
</div>
</div>
</div>]]></description><link>https://mattpearson.github.io/2016/09/05/Linux-Security.html</link><guid isPermaLink="true">https://mattpearson.github.io/2016/09/05/Linux-Security.html</guid><pubDate>Mon, 05 Sep 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[CME New Release VPN]]></title><description><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This guide is written to help others go through the process of configuring a system to connect to the Chicago Mercantile Exchange&#8217;s New Release environment over a self-hosted VPN connection. It&#8217;s meant not to be an in-depth explanation of all terms and concepts, but rather a guide/map to go from a new router to having a working connection for those with only a high level understanding of routers.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_1_router">Step 1: Router</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You will need a router with built-in ISAKMP and IPSEC capabilities. One of the low cost options is to go with an 800 series Cisco router such as the 871W which you can pick up on Ebay in the $50 to $60 range, and it includes 802.11 wireless capabilities. This guide is written using an 871W router.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>For those readers who are not networking experts or Cisco CCNAs, there are many acronyms that are used. A few of them are briefly explained here to help get you up to speed.</p>
<div class="ulist">
<ul>
<li>
<p>ISAKMP - This is part of the security mechanism and is a subset of IKE.  <a href="http://networkengineering.stackexchange.com/questions/1/whats-the-difference-between-ike-and-isakmp" class="bare">http://networkengineering.stackexchange.com/questions/1/whats-the-difference-between-ike-and-isakmp</a></p>
</li>
<li>
<p>GRE - Generic Routing Encapsulation. This allows multicast traffic to be sent over the VPN tunnel. <a href="http://www.cisco.com/c/en/us/support/docs/ip/ip-multicast/43584-mcast-over-gre.html" class="bare">http://www.cisco.com/c/en/us/support/docs/ip/ip-multicast/43584-mcast-over-gre.html</a></p>
</li>
<li>
<p>PIM - Protocol Independent Multicast. You&#8217;ll need to "enable multicast routing" and "pim sparse-mode" on the router for the multicast traffic to work properly.  <a href="http://www.cisco.com/c/en/us/td/docs/ios/solutions_docs/ip_multicast/White_papers/mcst_ovr.html" class="bare">http://www.cisco.com/c/en/us/td/docs/ios/solutions_docs/ip_multicast/White_papers/mcst_ovr.html</a></p>
</li>
<li>
<p>VLAN - Virtual LAN. Note that on the 871W, you can not assign a specific IP or DHCP group to the physical interfaces. You must assign the interfaces to be part of a VLAN and then the VLAN can be assigned a DHCP pool for IP assignment.</p>
</li>
<li>
<p>Advanced Security or Advanced IP - Cisco offers two flavors of software to run on their routers. The "PIM" capabilities are in the Advanced IP package, not the Advanced Security package despite the need for a VPN tunnel! Make sure you are running a package with the K9 designator because it has AES/3DES encryption.</p>
</li>
<li>
<p>ACL - Access Lists. These allow you to choose what traffic can and can not go through your router.</p>
</li>
<li>
<p>NAT - Network Address Translation. This is a technology that allows your router to create a sub network and, through the use of differing ports, pass the traffic through one (public) IP. "ip nat inside" tells the vlan to NAT ip that are connected to it, and "ip nat outside" tells the interface (you would execute this command on your WAN port) to NAT traffic to the outside world.</p>
</li>
<li>
<p>dot1Q - This is to tell your wireless interface to use a specific vlan. For example "encapsulation dot1Q 10 native" uses vlan 10.</p>
</li>
</ul>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_2_hardware">Step 2: Hardware</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In addition to the 800 series Router, to get started, you&#8217;ll need a so-called "Rollover Cable". <a href="http://www.ebay.com/sch/i.html?_nkw=cisco+rollover+usb&amp;_sacat=0" class="bare">http://www.ebay.com/sch/i.html?_nkw=cisco+rollover+usb&amp;_sacat=0</a>
This allows you to configure the router over a serial protocol. Use putty to connect, and choose Serial for the method. For my setup, it was COM3 and 9600 baud.
To connect to CME you&#8217;ll need to have two physical interfaces available on your server. One for public IP traffic, and the other for CME New Release traffic.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_3_the_big_picture">Step 3: The Big Picture</h2>
<div class="sectionbody">
<div class="paragraph">
<p>A high level overview of how your network topology can look is as follows. You will have two separate networks (VLANs), one for public internet traffic, and the other specifically for CME NR traffic. The Vlan IDs (10 and 20, below) correspond to the sample configuration at the end.</p>
</div>
<div class="paragraph">
<p>You&#8217;ll create two VLANs, one for public IP traffic ("Vlan 10"), and the other for CME New Release traffic ("Vlan 20"). For wireless router models, you&#8217;ll add the wireless connection to be part of Vlan 10.  Assign two of the fast ethernet ports to vlan 10 (FA0 and FA1), and the other two (FA2 and FA3) to Vlan 20. This will allow you to have two physical connections to public IP and two to New Release. You can always attach a networking switch to a vlan 10 port to expand internet access to other devices.  To have the appropriate IPs assigned to each VLAN, you&#8217;ll create two DHCP pools for which IPs can come. On vlan 10, you can stay with the traditional 192.168.1.x range and on vlan 20, you must use the range that the CME assigns you.</p>
</div>
<div class="paragraph">
<p>Note for Wireless users: In order to get wireless working propertly, you&#8217;ll need to create a both a sub interface and a "bridge group". At a high level, a bridge group allows you to connect the physical interface with the wireless interface into the same group. This is important: you won&#8217;t assign an IP address range to vlan 10, just tell it to be part of the bridge group and with "no ip address". Then, in the bridge group configuration, you will assign the IP range for which the DHCP pool exits. However, for vlan 20 (because it&#8217;s not part of a bridge group with a wireless interface), you will assign an ip range that matches what CME tells you.
This is evident in the sample configuration.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_4_configure_router_cisco_101">Step 4: Configure Router / "Cisco 101"</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To connect to the router, you do not use the Netgear/Linksys approach of pointing your browser to 192.168.1.1. Instead, you need to connect via the serial "rollover" cable.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Once you connect to the router, there will be a few key commands that you&#8217;ll use over and over:</p>
<div class="ulist">
<ul>
<li>
<p>"write erase"&#8201;&#8212;&#8201;This will erase the "running-config" and the "startup-config". These are the file names of the two configuration files on the router.</p>
</li>
<li>
<p>"copy running-config startup-config"&#8201;&#8212;&#8201;This will copy the configuration that you have created to be the one run when the router is rebooted.</p>
</li>
<li>
<p>"enable"&#8201;&#8212;&#8201;This will bring the router into priviledged mode so you can issue basic show commands.</p>
</li>
<li>
<p>"config t"&#8201;&#8212;&#8201;This will bring the router into global configuration mode where you can actually change settings.</p>
</li>
<li>
<p>"exit"&#8201;&#8212;&#8201;Go back up one "level" in your configuration. For example if you are configuring a sub-interface and want to return back to the interface level, just type exit.</p>
</li>
<li>
<p>"shut"&#8201;&#8212;&#8201;Brings down an interface.</p>
</li>
<li>
<p>"no XXXX"&#8201;&#8212;&#8201;Removes or takes away a command. For example, if you type "no shut", then it will bring UP an interface. Likewise, "no ip pim sparse-mode" will REMOVE the "ip pim sparse-mode" from the configuration.</p>
</li>
<li>
<p>"switchport access"&#8201;&#8212;&#8201;This tells the router to associate a physical interface to a particular vlan.</p>
</li>
</ul>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>A couple notes on wifi connection:
You&#8217;ll notice there exists an entry "interface Dot11Radio0.10". This means you are creating a sub-interface off the 802.11 wireless interface (that&#8217;s where the ".10" comes in). The number after the period is for the vlan number for which the subinterface should be part of. You also use this vlan number with your dot1Q encapulation command. See the sample configuration.
"guest mode" means that the SSID is broadcast (you&#8217;ll pick it up on your access point list on your laptop/phone).</p>
</div>
<div class="paragraph">
<p>To get started, connect to the router through putty, and follow these instructions:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Execute "write erase" first (to restore factory configuration).</p>
</li>
<li>
<p>Next, "enable" to go into priviledged mode.</p>
</li>
<li>
<p>Then, "show running-config" to see what the initial configuration looks like.</p>
</li>
<li>
<p>Lastly, "config t" so you can start changing settings (you should see the '#' prompt which means you can now issue commands).</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Once you are in this mode, type in the commands from the attached configuration file. Replace the XXX.XXX.XXX.XXX IPs with those provided by CME.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_5_configure_linux">Step 5: Configure Linux</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In order to get this to work properly, you will need to: 1. diable RP filtering, 2. configure your firewall properly (or just turn it off), and 3. add the appropriate routing table entries so that traffic to CME goes to the correct interface. On the commands that follow, the interface for CME is enp3s0 (change it to match yours).</p>
</div>
<div class="paragraph">
<p>Routing table:
route add -net XXX.YYY.ZZZ.0 netmask 255.255.255.0 gw AAA.BBB.CCC.1 dev enp3s0
(Change the X,Y,Z, and A,B,C to the IP range assignedby CME).</p>
</div>
<div class="paragraph">
<p>Also add the route for multicast traffic to the appropriate interface:
sudo route add -net 224.0.0.0/8 dev enp3s0</p>
</div>
<div class="paragraph">
<p>To join a multicast group on ip 224.0.28.1:14310, you can use the command: iperf -s -u -B 224.0.28.1 -i 1 -p 14310</p>
</div>
<div class="paragraph">
<p>To see if multicast traffic is coming in on the interface:
tcpdump -i enp3s0 -s0 -vv net 224.0.28.0/24</p>
</div>
<div class="paragraph">
<p>Note, on Centos 7, the commands to change your interfaces have changed. Here is a helpful cheat-sheet for relevant commands: <a href="https://access.redhat.com/sites/default/files/attachments/rh_ip_command_cheatsheet_1214_jcs_print.pdf" class="bare">https://access.redhat.com/sites/default/files/attachments/rh_ip_command_cheatsheet_1214_jcs_print.pdf</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_useful_links">Useful Links:</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="http://stevehardie.com/2013/05/cisco-877w-configure-wireless-and-wired-on-single-subnet/" class="bare">http://stevehardie.com/2013/05/cisco-877w-configure-wireless-and-wired-on-single-subnet/</a>
<a href="https://supportforums.cisco.com/discussion/11801006/does-configuring-two-vlans-cisco-871-router-divides-bandwidth-internet-half" class="bare">https://supportforums.cisco.com/discussion/11801006/does-configuring-two-vlans-cisco-871-router-divides-bandwidth-internet-half</a>
<a href="https://supportforums.cisco.com/discussion/10567086/change-ip-router-cisco-871" class="bare">https://supportforums.cisco.com/discussion/10567086/change-ip-router-cisco-871</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_sample_router_configuration">Sample Router Configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Current configuration : 4011 bytes<br>
!<br>
version 12.4<br>
no service pad<br>
service timestamps debug datetime msec<br>
service timestamps log datetime msec<br>
no service password-encryption<br>
!<br>
hostname Router<br>
!<br>
boot-start-marker<br>
boot-end-marker<br>
!<br>
!<br>
no aaa new-model<br>
!<br>
resource policy<br>
!<br>
ip cef<br>
!<br>
!<br>
no ip dhcp use vrf connected<br>
ip dhcp excluded-address 192.168.1.32 192.168.1.255<br>
!<br>
ip dhcp pool vlan20pool<br>
   network XXX.XXX.XXX.0 255.255.255.0<br>
   default-router XXX.XXX.XXX.1<br>
   dns-server 8.8.8.8<br>
!<br>
ip dhcp pool vlan10pool<br>
   network 192.168.1.0 255.255.255.0<br>
   default-router 192.168.1.1<br>
   dns-server 8.8.8.8<br>
!<br>
!<br>
ip multicast-routing<br>
!<br>
!<br>
!<br>
!<br>
!<br>
!<br>
crypto isakmp policy 2<br>
 encr 3des<br>
 hash md5<br>
 authentication pre-share<br>
crypto isakmp key SECRET_KEY address XXX.XXX.XXX.XXX<br>
!<br>
!<br>
crypto ipsec transform-set cmevpn esp-3des esp-md5-hmac<br>
!<br>
crypto map cmevpn 1 ipsec-isakmp<br>
 set peer XXX.XXX.XXX.XXX<br>
 set transform-set cmevpn<br>
 match address 100<br>
!<br>
bridge irb<br>
!<br>
!<br>
!<br>
interface Tunnel0<br>
 ip address XXX.XXX.XXX.XXX 255.255.255.252<br>
 ip pim sparse-mode<br>
 tunnel source XXX.XXX.XXX.XXX<br>
 tunnel destination XXX.XXX.XXX.1<br>
!<br>
interface Loopback0<br>
 ip address XXX.XXX.XXX.XXX 255.255.255.255<br>
!<br>
interface FastEthernet0<br>
 switchport access vlan 10<br>
!<br>
interface FastEthernet1<br>
 switchport access vlan 10<br>
!<br>
interface FastEthernet2<br>
 switchport access vlan 20<br>
!<br>
interface FastEthernet3<br>
 switchport access vlan 20<br>
!<br>
interface FastEthernet4<br>
 ip address dhcp<br>
 ip nat outside<br>
 ip virtual-reassembly<br>
 duplex auto<br>
 speed auto<br>
 crypto map cmevpn<br>
!<br>
interface Dot11Radio0<br>
 no ip address<br>
 !<br>
 broadcast-key vlan 10 change 45<br>
 !<br>
 !<br>
 encryption vlan 10 mode ciphers tkip<br>
 !<br>
 ssid YOUR_SSID_NETWORK_NAME<br>
    vlan 10<br>
    authentication open<br>
    authentication key-management wpa<br>
    guest-mode<br>
    wpa-psk ascii 0 YOUR_SSID_PASSWORD<br>
 !<br>
 speed basic-1.0 basic-2.0 basic-5.5 6.0 9.0 basic-11.0 12.0 18.0 24.0 36.0 48.0 54.0<br>
 station-role root<br>
 no cdp enable<br>
!<br>
interface Dot11Radio0.10<br>
 encapsulation dot1Q 10 native<br>
 no cdp enable<br>
 bridge-group 1<br>
 bridge-group 1 subscriber-loop-control<br>
 bridge-group 1 spanning-disabled<br>
 bridge-group 1 block-unknown-source<br>
 no bridge-group 1 source-learning<br>
 no bridge-group 1 unicast-flooding<br>
!<br>
interface Vlan1<br>
 no ip address<br>
 ip access-group 102 in<br>
 shutdown<br>
!<br>
interface Vlan10<br>
 no ip address<br>
 ip access-group 102 in<br>
 ip nat inside<br>
 ip virtual-reassembly<br>
 bridge-group 1<br>
 bridge-group 1 spanning-disabled<br>
!<br>
interface Vlan20<br>
 ip address XXX.XXX.XXX.1 255.255.255.0<br>
 ip pim sparse-mode<br>
 ip nat inside<br>
 ip virtual-reassembly<br>
!<br>
interface BVI1<br>
 ip address 192.168.1.1 255.255.255.0<br>
 ip nat inside<br>
 ip virtual-reassembly<br>
!<br>
ip route XXX.XXX.XXX.1 255.255.255.255 FastEthernet4<br>
ip route XXX.XXX.XXX.0 255.255.255.128 Tunnel0<br>
ip route XXX.XXX.XXX.128 255.255.255.128 FastEthernet4<br>
ip route XXX.XXX.XXX.255 255.255.255.255 Tunnel0<br>
!<br>
!<br>
no ip http server<br>
no ip http secure-server<br>
ip pim rp-address XXX.XXX.XXX.254<br>
ip mroute XXX.XXX.XXX.0 255.255.255.128 Tunnel0<br>
ip nat inside source list 1 interface FastEthernet4 overload<br>
!<br>
access-list 1 permit 192.168.1.0 0.0.0.255<br>
access-list 102 permit ip any any<br>
!<br>
!<br>
!<br>
!<br>
control-plane<br>
!<br>
bridge 1 protocol ieee<br>
bridge 1 route ip<br>
!<br>
line con 0<br>
 no modem enable<br>
line aux 0<br>
line vty 0 4<br>
 login<br>
!<br>
scheduler max-task-time 5000<br>
end</p>
</div>
</div>
</div>]]></description><link>https://mattpearson.github.io/2016/09/03/CME-New-Release-VPN.html</link><guid isPermaLink="true">https://mattpearson.github.io/2016/09/03/CME-New-Release-VPN.html</guid><pubDate>Sat, 03 Sep 2016 00:00:00 GMT</pubDate></item><item><title><![CDATA[RP Filtering]]></title><description><![CDATA[<div class="sect1">
<h2 id="_why_is_my_server_not_receiving_multicast_traffic">Why is my server not receiving multicast traffic?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Out of the box linux installations oftentimes enable so-called "reverse path" filtering. This essentially means that if the source ip of the udp packet is not routable through the interface in which the packet arrived, then it will be dropped.</p>
</div>
<div class="paragraph">
<p>To turn off (disable) this filtering, and allow multicast traffic through, set the rp_filter to 0:</p>
</div>
<div class="paragraph">
<p>echo "0" &gt; /proc/sys/net/ipv4/conf/all/rp_filter</p>
</div>
<div class="paragraph">
<p>Lastly, edit /etc/sysctl.conf and change:
ipv4.conf.all.rp_filter = 0</p>
</div>
<div class="paragraph">
<p>More information available:
<a href="http://www.slashroot.in/linux-kernel-rpfilter-settings-reverse-path-filtering" class="bare">http://www.slashroot.in/linux-kernel-rpfilter-settings-reverse-path-filtering</a>
and
<a href="http://centoshowtos.org/network-and-security/rp_filter/" class="bare">http://centoshowtos.org/network-and-security/rp_filter/</a></p>
</div>
</div>
</div>]]></description><link>https://mattpearson.github.io/2016/09/02/RP-Filtering.html</link><guid isPermaLink="true">https://mattpearson.github.io/2016/09/02/RP-Filtering.html</guid><pubDate>Fri, 02 Sep 2016 00:00:00 GMT</pubDate></item></channel></rss>