<?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>Mark Nelson &#187; Networking</title>
	<atom:link href="http://marknelson.us/category/networking/feed/" rel="self" type="application/rss+xml" />
	<link>http://marknelson.us</link>
	<description>Programming, mostly.</description>
	<lastBuildDate>Fri, 13 Apr 2012 19:25:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sendmail on Linux &#8211; the Easy Way</title>
		<link>http://marknelson.us/2011/12/09/sendmail-on-linux-the-easy-way/</link>
		<comments>http://marknelson.us/2011/12/09/sendmail-on-linux-the-easy-way/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 16:11:05 +0000</pubDate>
		<dc:creator>Mark Nelson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://marknelson.us/?p=465</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://marknelson.us/2011/12/09/sendmail-on-linux-the-easy-way/' addthis:title='Sendmail on Linux &#8211; the Easy Way' ><a class="addthis_button_twitter"></a><a class="addthis_button_favorites"></a><a class="addthis_button_print"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div>This summer I&#8217;m teaching a graduate class, Principles of UNIX, which is more or less a crash course in the Mother of All Operating Systems. One of our early topics is email on UNIX, in which I try to impart to the class just how transformative email was back in the day. For early Internet [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://marknelson.us/2011/12/09/sendmail-on-linux-the-easy-way/' addthis:title='Sendmail on Linux &#8211; the Easy Way' ><a class="addthis_button_twitter"></a><a class="addthis_button_favorites"></a><a class="addthis_button_print"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div><p>This summer I&#8217;m teaching a graduate class, Principles of UNIX, which is more or less a crash course in the Mother of All Operating Systems. One of our early topics is email on UNIX, in which I try to impart to the class just how transformative email was back in the day. For early Internet users (mostly UNIX users), this was an incredibly big deal.</p>
<p>Unfortunately, setting up email on a Linux or UNIX system is not quite as automatic as it once was. In our class we use mailx and sendmail as tools to send files from background processes or cron jobs &#8211; but mailx will typically not work out of the box. In this post I&#8217;ll discuss how to get it working on an Ubuntu 11 system.<br />
<span id="more-465"></span></p>
<h4>Things Have changed</h4>
<p>Back in the day if you wanted to send mail, you simply found a handy <a href="http://www.webhostingsearch.com/dedicated-server.php" class="newpage">dedicated server</a> that was accepting incoming SMTP connections. There were thousands, and they were undiscriminating, so this was no big deal.</p>
<p>The invention of <a href="http://en.wikipedia.org/wiki/Spam_(electronic)" class="newpage">spam</a> ruined that. </p>
<p>Now any SMTP server you find is going to require you to go through a bit of a dance in order to authenticate and prove you are not a spammer. I started off this post with the intention of showing you how to use your gmail account to access Google&#8217;s SMTP servers. The process was fairly arduous, as it involved creating a certificate authority, your own certificates, and then setting up the mail server to use this authentication.</p>
<p>While working on this, my son <a href="http://wlrs.net/" class="newpage">Joey</a> recommended that I just set up a free account on one of several email gateway providers, such as <a href="http://sendgrid.com" class="newage">SendGrid</a> or <a href="http://mailjet.com" class="newpage">MailJet</a>. Both services will let you access their servers and send up to 200 emails a day for free.</p>
<p>I took him up on it and found the process to be much simpler than using gmail, so I&#8217;ll pass along the setup procedure here.</p>
<h4>Getting an Account</h4>
<p>Obviously, SendGrid is in business to get you to purchase a commercial account so you can send thousands of emails a day from your web site. Accordingly, the don&#8217;t go out of their way to advertise their free plan. If you go to their <a href="https://Sendgrid.com/pricing.html" class="newpage">pricing page</a>, you will find a little tiny link to the <a href="https://sendgrid.com/user/signup" class="newpage">free plan</a> hidden at the bottom.</p>
<p>Setting up an account is easy, but SendGrid insists that you have a web site. For automatic verification they will need to find your email address on the site. I opted for an alternate provisioning plan in which I created a page on my site with the phrase &#8220;Sendgrid&#8221;. </p>
<p>Once you have an account, you have free access to the SendGrid SMTP servers for up to 200 outbound messages a day. So you are ready to configure your UNIX system to take advantage of it.</p>
<h4>Ubuntu Configuration</h4>
<p>Configuring Ubuntu 11 to send email is fairly painless. Using the Ubuntu Software Center, you can locate and install two packages: postfix and bsd-mailx. During the install of postfix, you will get dropped into a debconf window asking you some basic configuration questions:<br />
<center></p>
<table border="0" width="100%">
<tr>
<td><center><img src="/attachments/2011/smtp/PostfixConfig.png"  width="90%"><center></td>
</tr>
<tr>
<td><center>Figure 1 &#8211; The initial configuration screen</center></td>
</tr>
</table>
<p></center><br />
I entered the following answers to the two questions I got hit up with:</p>
<ul>
<li/>General configuration: Internet
<li/>System mail name: dogma.net
</ul>
<p>That seemed to be all I needed for basic configuration.</p>
<h4>Postfix Configuration</h4>
<p>To configure postfix to use SendGrid was just a matter of adding a few lines to /etc/postfix/main.cf, using your SendGrid user name and password. Note that the file probably has an existing <code>relayhost</code> line, this one should replace it:</p>
<pre>
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:username:password
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
relayhost = [smtp.sendgrid.net]:587
</pre>
<p>After making the changes you should restart postfix so it reads the new config options. I also start watching the mail log file so I can see if there are any problems on first use:</p>
<pre>
sudo /etc/init.d/postfix restart
sudo tail -f /var/log/mail.log
</pre>
<p>A test message sent to my cell phone arrived as a text message in just one or two seconds, with the following log messages:</p>
<pre>
Jun 26 17:02:08 ubuntu postfix/pickup[21145]: 51A5E5E1DA6: uid=1000 from=&lt;mark&gt;
Jun 26 17:02:08 ubuntu postfix/cleanup[21336]: 51A5E5E1DA6: message-id=&lt;20110627000208.51A5E5E1DA6@ubuntu&gt;
Jun 26 17:02:08 ubuntu postfix/qmgr[21146]: 51A5E5E1DA6: from=&lt;mark@dogma.net&gt;, size=273, nrcpt=1 (queue active)
Jun 26 17:02:08 ubuntu postfix/smtp[21338]: 51A5E5E1DA6: to=&lt;xxxxxxxx@txt.att.net&gt;, relay=smtp.sendgrid.net[174.36.32.204]:587, delay=0.33, delays=0.04/0.02/0.23/0.04, dsn=2.0.0, status=sent (250 Delivery in progress)
Jun 26 17:02:08 ubuntu postfix/qmgr[21146]: 51A5E5E1DA6: removed
</pre>
<h4>Moving On to Better Things</h4>
<p>Now that postfix is properly configured, I can really start taking advantage of the mail infrastructure on my system. The next obvious step is to create a <code>.forward</code> in my home directory, and give it my external gmail address. That external address will now be the recipient of output from <code>cron</code> jobs, or from <code>at</code> or <code>batch</code>. It&#8217;s nice to have the mail set up as in integral part of the O/S, and if you can just make it through a little bit of setup, it&#8217;s all yours.</p>
<p>With a limit of 200 messages a day you can still make extensive use of outbound email for system monitoring &#8211; whether it is via text to your phone or huge messages being sent to an account used for storing log files. Either way, integral email is still a great feature, almost forty years after it first showed up in UNIX.</p>
]]></content:encoded>
			<wfw:commentRss>http://marknelson.us/2011/12/09/sendmail-on-linux-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DNS Service Discovery</title>
		<link>http://marknelson.us/2011/09/30/dns-service-discovery/</link>
		<comments>http://marknelson.us/2011/09/30/dns-service-discovery/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 02:18:41 +0000</pubDate>
		<dc:creator>Mark Nelson</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://marknelson.us/?p=892</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://marknelson.us/2011/09/30/dns-service-discovery/' addthis:title='DNS Service Discovery' ><a class="addthis_button_twitter"></a><a class="addthis_button_favorites"></a><a class="addthis_button_print"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div>For most of this year I&#8217;ve been working on a new product called Cisco OnPlus, a network management service for small business. In order to do its job effectively, OnPlus needs to know what devices are present on the network, and one of the key tools we use to accomplish this is DNS Service Discovery. [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://marknelson.us/2011/09/30/dns-service-discovery/' addthis:title='DNS Service Discovery' ><a class="addthis_button_twitter"></a><a class="addthis_button_favorites"></a><a class="addthis_button_print"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div><p>For most of this year I&#8217;ve been working on a new product called <a href="http://www.cisco.com/en/US/products/ps11792/index.html" class="newpage">Cisco OnPlus</a>, a network management service for small business. In order to do its job effectively, OnPlus needs to know what devices are present on the network, and one of the key tools we use to accomplish this is <a href="http://www.dns-sd.org/" class="newpage">DNS Service Discovery</a>. In this article I will show you a little bit about how we use DNS-SD, and show you how you can put it to work effectively in your networks.<br />
<span id="more-892"></span></p>
<h4>OnPlus</h4>
<p>Cisco OnPlus is a cloud-based network management tool that helps resellers support their customers. The figure below shows you a typical view of a customer network from an OnPlus browser screen. (The customer in this case being my Dad.) OnPlus not only identifies the devices on the customer&#8217;s network, it also performs configuration backups, firmware updates, and monitors network performance.<br />
<center></p>
<table border="0">
<tr>
<td><img src="/attachments/2011/dns-sd/OnPlusView.png"/></td>
</tr>
<tr>
<td><center>The OnPlus Topology View</center></td>
</tr>
</table>
<p></center><br />
In order to get this information about the customer&#8217;s network, OnPlus relies on the OnPlus Network Agent &#8211; an ARM-based Linux PC about the size of a paperback book. This computer is a close relative of the <a href="http://en.wikipedia.org/wiki/SheevaPlug" class="newpage">Sheeva Plug</a>, and despite its small size it runs a fairly complete distribution of Linux.<br />
<center></p>
<table border="0">
<tr>
<td><img src="/attachments/2011/dns-sd/OnPlusAppliance.png"/></td>
</tr>
<tr>
<td><center>The OnPlus Network Agent</center></td>
</tr>
</table>
<p></center><br />
The agent regularly runs a complete inventory of the network, attempting to learn as much as possible about all of the devices it can find. The inventory process uses a huge list of protocols when scanning the network, including:</p>
<ul>
<li/>DNS Service Discovery
<li/>DHCP Packet Inspection
<li/>DNS Packet Inspection
<li/>Windows Management Instrumentation
<li/>Cisco Discovery Protocol, or CDP
<li/>NETBIOS/SMB
<li/>UPnP
<li/>SLP
<li/>Traceroute
<li/>ARP
</ul>
<p>When it comes to locating devices made by my business unit at Cisco, the most useful protocols are DNS Service Discovery and Cisco Discovery Protocol. DNS Service Discovery provides all the information the inventory process needs to fully identify a device: its specific Product ID (more or less a model number), the version number of both the hardware and the firmware, its MAC address, and its IP address. (CDP provides a nearly, but not identical bundle of data.) This information is readily available because devices made by Cisco&#8217;s Small Business Technology Group use DNS-SD to broadcast information using our proprietary service type: <code>csco-sb</code>.</p>
<h4>A Quick Overview of DNS Service Discovery</h4>
<p>So what exactly is DNS Service Discovery? If you&#8217;re like me, you became aware of DNS-SD because Apple uses it as part of <a href="http://www.apple.com/support/bonjour/" class="newpage">Bonjour</a>. Bonjour is a proprietary implementation of <a href="http://en.wikipedia.org/wiki/Zeroconf" class="newpage">Zeroconf</a>, a set of technologies marked by by <a href="http://theangryhedgehog.com/2010/12/19/three-shall-be-the-number-thou-shalt-count/" class="newpage">three</a> key network components:</p>
<ul>
<li/>Address assignment
<li/>Service discovery
<li/>Name resolution
</ul>
<p>The history of Zeroconf is a somewhat quixotic story, based around the shared idea that setting up small networks ought to be a painless and simple process. The components of Zeroconf provide a nice, vendor-agnostic way to set up networks in such a way that no consumer would ever have to manually assign an IP address, set up a DHCP server, or manually enter the address of a printer.</p>
<p>Apple has embraced this idea, with their implementation of Zeroconf called Bonjour, an Apple trademark. If you run iTunes on your Apple or Windows PC, you may well see that there are other users out there running iTunes who would be happy to share their collections with you. This happens more or less with no work on your part, and can be a really nice feature in a big office:<br />
<center></p>
<table border="0">
<tr>
<td><img src="/attachments/2011/dns-sd/Itunes.png"/></td>
</tr>
<tr>
<td><center>Sharing iTunes Libraries</center></td>
</tr>
</table>
<p></center><br />
iTunes accomplishes this sharing using DNS-SD, which is built into OS X and is configured on Windows machines as part of the iTunes installation. Every instance of iTunes that is configured to share its library uses Bonjour to advertise an instance of the <code>daap</code> service. If we look in the official roster of <a href="http://www.dns-sd.org/ServiceTypes.html" class="newpage">registered DNS Service types</a>, we find this record:</p>
<pre>
daap Digital Audio Access Protocol (iTunes)
     Amandeep Jawa <daap at apple.com>
     Defined TXT keys: txtvers, Version, iTSh Version, Machine ID,
                       Database ID, Machine Name, Password
</pre>
<p>This is a pretty simple definition &#8211; let&#8217;s see what it looks like on the network. </p>
<p>On my desktop Linux sytem, I have the <a href="http://avahi.org/" class="newpage">avahi</a> utilities installed. Avahi provides a nice suite of tools used to implement DNS-SD. I&#8217;ll use the <code>avahi-browse</code> command to see what these <code>daap</code> services actually look like:</p>
<pre>
mark@ubuntu:~$ avahi-browse _daap._tcp -t
+   eth0 IPv4 Itunes NAS Server on nas                      iTunes Audio Access  local
+   eth0 IPv4 Denise___s Library                            iTunes Audio Access  local
+   eth0 IPv4 Mark___s Library                              iTunes Audio Access  local
mark@ubuntu:~$
</pre>
<p>If I ask <code>avahi-browse</code> to resolve the services, it will query the service provider for the details in the advertisement. A partial output is shown below:</p>
<pre>

mark@ubuntu:~$ avahi-browse _daap._tcp -r -t
+   eth0 IPv4 Itunes NAS Server on nas                      iTunes Audio Access  local
+   eth0 IPv4 Denise___s Library                            iTunes Audio Access  local
+   eth0 IPv4 Mark___s Library                              iTunes Audio Access  local
=   eth0 IPv4 Itunes NAS Server on nas                      iTunes Audio Access  local
   hostname = [nas.local]
   address = [192.168.1.165]
   port = [3689]
   txt = ["ffid=075abcc4" "Password=false" "Version=196610" "iTSh Version=131073"
          "mtd-version=svn-1676" "Machine Name=Itunes NAS Server" "Machine ID=BE8926F6"
          "Database ID=BE8926F6" "txtvers=1"]
</pre>
<p>From this information, I know have everything I need in order to connect to to a server and start playing music. I have a hostname, IP address, and a port, all of which can be used to access the service. Finally I have a txt record that contains an aribtrary set of name/value pairs, as defined in the service definition. The us of these fields is up to the creator of the service, and in this case most of them are self-evident.</p>
<h4>Browsing the Network</h4>
<p>We use the avahi toolkit in OnPlus to browse the network for devices. It is worth doing a little exploring on my home network to see what kind of information we get out of this process.</p>
<p>To get a high-level view, I can ask <code>avahi-browse</code> to query for a special service: <code>_services._dns-sd._udp</code>. When this browse request goes out on the network, all the active nodes using DNS-SD issue records detailing the types of services they support. The result on my home network looks like this:</p>
<pre>
mark@ubuntu:~$ avahi-browse _services._dns-sd._udp -t
+   eth0 IPv4 _udisks-ssh                                   _tcp                 local
+   eth0 IPv4 _workstation                                  _tcp                 local
+   eth0 IPv4 _ir-hvac-021                                  _tcp                 local
+   eth0 IPv4 _ir-hvac-020                                  _tcp                 local
+   eth0 IPv4 _ir-hvac-000                                  _tcp                 local
+   eth0 IPv4 _pdl-datastream                               _tcp                 local
+   eth0 IPv4 _printer                                      _tcp                 local
+   eth0 IPv4 _tivo-videos                                  _tcp                 local
+   eth0 IPv4 _readynas                                     _tcp                 local
+   eth0 IPv4 _smb                                          _tcp                 local
+   eth0 IPv4 _afpovertcp                                   _tcp                 local
+   eth0 IPv4 _rsp                                          _tcp                 local
+   eth0 IPv4 _daap                                         _tcp                 local
+   eth0 IPv4 _http                                         _tcp                 local
+   eth0 IPv4 _csco-sb                                      _tcp                 local
mark@ubuntu:~$
</pre>
<p>As you can see, there are a surprising number of DNS-SD services present. On my network, an explanation for each of the services is:</p>
<table border=0">
<tr>
<td valign="top">_udisks-ssh:</td>
<td>A remote disk management tool being advertised by my Ubuntu systems</td>
</tr>
<tr>
<td valign="top">_workstation:</td>
<td>Some sort of workgroup management interface support by various Linux systems.</td>
</tr>
<tr>
<td valign="top">_ir-hvac-0xx:</td>
<td>Management interfaces on a Trane thermostat that happens to have wireless access to my network</td>
</tr>
<tr>
<td valign="top"><nobr>_pdl-datastream:</nobr></td>
<td>Printer page description language interface. This is a service that is used in Bonjour printing. Both of my networked printers support it.</td>
</tr>
<tr>
<td valign="top">_printer</td>
<td>Both of my printers use this advertisement to offer TCP port 515 up for LPR print spooling</tr>
</td>
<tr>
<td valign="top">_tivo-videos</td>
<td>My Tivo sends out this advertisement which provides a complete URL I can use to get an XML-formatted version of the <em>Now Playing</em> section of the Tivo UI.</td>
</tr>
<tr>
<td valign="top">_readynas</td>
<td>My Netgear ReadyNAS uses this unregistered service type to advertise something that can be reached on port 9. Exactly what, I don&#8217;t know, but I think it might be just a way for PC users to find the NAS with RAIDar.</td>
</tr>
<tr>
<td valign="top">_smb</td>
<td>My Netgear ReadyNAS advertises its Windows shares with this service type</td>
</tr>
<tr>
<td valign="top">_afpovertcp</td>
<td>My Netgear ReadyNAS uses this registered service type to advertise its Apple File Sharing volumes</td>
</tr>
<tr>
<td valign="top">_rsp</td>
<td>I have a Firefly iTunes server running on my NAS. In addition to serving music via DAAP, it uses the Roku Server Protocol as well, presumably working with software that doesn&#8217;t support iTunes protocols.</td>
</tr>
<tr>
<td valign="top">_http</td>
<td>Most of the devices on my network that are running web servers issue an HTTP advertisement, which points to that interface.</td>
</tr>
<tr>
<td valign="top">_csco-sb</td>
<td>My two Cisco SB devices advertise their presence using this service</td>
</tr>
</table>
<p>This special command to show me the services available is not actually used in OnPlus. Instead, we call <code>avahi-browse</code> with the -r and -p commands, asking it to do a full resolution on all discovered services.</p>
<h4>Cisco Devices</h4>
<p>The place where we get the most interesting results from <code>avahi-browse</code> is when we tell it to look specifically for instances of the <code>cisco-sb</code> service. That command produces output like this:</p>
<pre>
mark@ubuntu:~$ avahi-browse -r -t _csco-sb._tcp
+   eth0 IPv4 switch32026a                                  _csco-sb._tcp        local
+   eth0 IPv4 onplus005229                                  _csco-sb._tcp        local
=   eth0 IPv4 switch32026a                                  _csco-sb._tcp        local
   hostname = [sg200-26p.local]
   address = [192.168.1.168]
   port = [80]
   txt = ["hostname=sg200-26p" "serialNo=DNI1515005U" "MACAddress=44E4D932026A"
          "PIDVID=SLM2024PT V01" "fmVersion=1.1.1.8"
          "deviceDescr=26-port Gigabit PoE Smart Switch" "deviceType=Switch"
          "model=SG 200-26P"]
=   eth0 IPv4 onplus005229                                  _csco-sb._tcp        local
   hostname = [PLG1000F0AD4E005229.local]
   address = [192.168.1.167]
   port = [80]
   txt = ["accessType=http" "MDFID=Unassigned" "hostname=onplus005229"
          "serialNo=PLGF0AD4E005229" "MACAddress=F0:AD:4E:00:52:29"
          "PIDVID=Unassigned" "fmVersion=6.2.2.007" "deviceDescr=Cisco OnPlus Network Agent"
          "deviceType=Service Appliance" "model=PLG1000" "version=1.0"]
mark@ubuntu:~$
</pre>
<p>If you look at the first &#8216;=&#8217; records that is issued by <code>avahi-browse</code>, you can see that when it comes to discovery, I have really hit the jackpot. I&#8217;ve identified a device on my system that I can reach with a specific IP address. I have a MAC address that I can now use as a globally unique identifier. And I have the Cisco Product ID, the hardware version, and the firmware version, as well as the user-assigned host name and a friendly model name. </p>
<p>When I have information like this, it allows me to fill in the details in the topology map quite accurately. Better yet, since this is a Cisco device, the OnPlus appliance can now send it some queries to find out more network information. As an example, the switch&#8217;s CAM table provides me with a list of devices and the ports they are attached to, which helps me fill in some of the details of the topology picture.</p>
<h4>Processing This Data</h4>
<p>If you are a programmer, the natural question you might be asking is how you access these service advertisements from inside your program. In the case of Cisco OnPlus, most of the code running the inventory task consists of PHP scripts. As far as I know, there are no bindings in PHP to DNS-SD services, and we elected not to try to invent that wheel.</p>
<p>Instead, we use PHP&#8217;s <code>popen()</code> function to run instances of <code>avahi-browse</code>, collecting the output from the program and parsing it accordingly. We actually have three instances of the browser running at any time. Two are dedicated to Cisco-specific services, while the third looks at all other services. Even though other services might not give us as munch information as <code>csco-sb</code>, they still supply host names, MAC addresses, IP addresses, descriptions, and more, and we use whatever we can find.</p>
<p>These instances of <code>avahi-browse</code> run as independent discovery processes, collecting and storing data as it is seen on the network. The records that they collect are then used by the inventory process when it is periodically launched.</p>
<p>The DNS-SD discovery processes actually take an active role in the inventory scheme. When one of the avahi-based processes discovers a significant new device on the network, such as one advertising <code>cisco-sb</code>, it stores the data record and then triggers an early start to the inventory process. This allows OnPlus to respond to new devices on the network in something close to real-time.</p>
<h4>Advertising</h4>
<p>So let&#8217;s say you decide you want to use DNS-SD for some form of network discovery. I&#8217;ve shown you how you can you discover network nodes that are advertising a service, but how do you actually perform that advertisment?</p>
<p>In the OnPlus Network we use the avahi package to advertise services as well as to find them. The <code>avahi-publish</code> command does the job, typically started as a daemon to run for the lifetime of the system. When executing <code>avahi-publish</code>, you will normally want to specify:</p>
<ul>
<li/>A service type
<li/>The name of the service instance
<li/>A port to access the service
<li/>Text records containing whatever name/value pairs you want to publish
</ul>
<p>One thing to note is that you can use DNS-SD to advertise things that don&#8217;t necessarily map directly to a port. For example, if you just want to let everyone know of your existence, the port parameter might be irrelevant, but the name/value pairs could still be valuable.</p>
<p>As an example, I might create a photo sharing service that I advertise on the network using a service I&#8217;ll call <code>PhotoMark</code>. To let everyone know about this, I execute the following command when my system starts up:</p>
<pre>
avahi-publish -s mark _PhotoMark._tcp 9999 "payload=.gif" "folder=/pictures"
</pre>
<p>Anyone on the network using DNS-SD could then see that I was advertising photo sharing with photos of type GIF accessible on my <code>pictures</code> folder. Of course, the details of the protocol are not included in the advertisement &#8211; that&#8217;s outside the scope of DNS-SD.</p>
<p>Often a good choice for the service instance is to simply use the computer name:</p>
<pre>
avahi-publish -s `uname -n` _PhotoMark._tcp 9999 "payload=.gif" "folder=/pictures"
</pre>
<h4>What&#8217;s Next</h4>
<p>In this article I showed you how we use DNS-SD on the Cisco OnPlus Network Agent. Mostly it involves calling the avahi command line tools and parsing their output with PHP scripts.</p>
<p>In my next post, I&#8217;ll show you how to do the same thing on a Windows PC using the Apple Bonjour SDK. Unfortunately, Windows has not included DNS-SD support in the O/S, so instead of using the Win32 API to do service discovery, you will have to rely on some slightly less elegant methods. But when it comes to network discovery, functionality and interoperability trump elegance every day of the week.</p>
]]></content:encoded>
			<wfw:commentRss>http://marknelson.us/2011/09/30/dns-service-discovery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More on Sending Mail With Linux &#8211; Postfix Tweaks and Mailjet</title>
		<link>http://marknelson.us/2011/07/31/more-on-sending-mail-with-linux-postfix-tweaks-and-mailjet/</link>
		<comments>http://marknelson.us/2011/07/31/more-on-sending-mail-with-linux-postfix-tweaks-and-mailjet/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 18:42:03 +0000</pubDate>
		<dc:creator>Mark Nelson</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://marknelson.us/?p=530</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://marknelson.us/2011/07/31/more-on-sending-mail-with-linux-postfix-tweaks-and-mailjet/' addthis:title='More on Sending Mail With Linux &#8211; Postfix Tweaks and Mailjet' ><a class="addthis_button_twitter"></a><a class="addthis_button_favorites"></a><a class="addthis_button_print"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div>In my last post I showed a particularly easy way to to set up an SMTP server so postfix could send mail from your Linux system. In this post I&#8217;m going to add a few tips that might help you get through some rough spots in the whole process. Results From the Field After writing [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://marknelson.us/2011/07/31/more-on-sending-mail-with-linux-postfix-tweaks-and-mailjet/' addthis:title='More on Sending Mail With Linux &#8211; Postfix Tweaks and Mailjet' ><a class="addthis_button_twitter"></a><a class="addthis_button_favorites"></a><a class="addthis_button_print"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div><p>In my <a href="http://marknelson.us/2011/07/06/sendmail-on-linux-the-easy-way/" class="newpage">last post</a> I showed a particularly easy way to to set up an SMTP server so postfix could send mail from your Linux system. In this post I&#8217;m going to add a few tips that might help you get through some rough spots in the whole process.<br />
<span id="more-530"></span></p>
<h4>Results From the Field</h4>
<p>After writing a HOWTO page, there is no better test of its quality than to try it out with a group of students performing the task for the first time. That&#8217;s just what I did with my SMTP configuration post &#8211; I created a homework problem that asked my students to set up outbound email on their personal Linux systems.</p>
<p>Their resulting glitches highlighted a few rough spots in the process, most of which can be handled pretty easily.</p>
<h4>Debian Package Configuration</h4>
<p>When you install postfix on Ubuntu, you will normally get kicked into a simple package configuration dialog after the package has been downloaded and installed. This final step performs some very basic setup on postfix, getting into a roughly functional state.</p>
<p>If this configuration doesn&#8217;t run, postfix seems to be configured to only handle local mail &#8211; messages from one user to another. In some cases this may be just what you want, but normally it is not all that useful.</p>
<p>For unknown reasons, this configuration pass doesn&#8217;t always kick off properly. I&#8217;ve seen it fail to run, and some students have as well. Fortunately, you can execute the same process by hand from the command line:</p>
<pre>
sudo dpkg-reconfigure postfix
</pre>
<p>Running through this, I take the default settings for everything except <em>Root and postmaster mail recipient</em>, which I change to <em>student</em>, the name of my account on this system. After this is complete, following the instructions from my previous post will give you a proper Internet email setup.</p>
<h4>Using Mailjet instead of SendGrid</h4>
<p>After some glitches getting accounts on SendGrid, I had a couple of students decide to use <a href="http://mailjet.com/" class="newpage">Mailjet</a> as an STMP provider. Registering with Mailjet <i>is</i> easier, as it an automated process. However, using Mailjet as your SMTP provider comes with a couple of interesting twists.</p>
<p>First, instead of using your Mailjet account credentials to authenticate with their SMTP server, Mailjet gives you  a set of strong credentials specifically for SMTP authentication. You have to copy these from your Account Info page. No problem there, as long as you RTFM.</p>
<p>Slight more problematic is that Mailjet insists that the return address you use in your outbound emails must be an authenticated address. In other words, you have to be able to receive an email sent to that address and click on an authentication link.</p>
<p>When using postfix&#8217;s default settings, email sent by my students was going out with a return address of student@ubuntu, and there is obviously no way to authenticate that address. So we have to rewrite that address to something usable.</p>
<p>After taking that additional requirement into account, my changes to /etc/postfix/main.cf for Mailjet are shown below. The file had a default relayhost entry, which is replaced, and the remaining lines are all new. The username and password have to be replaced with the ones from your Mailjet account page:</p>
<pre>
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:username:password
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
relayhost = [in.mailjet.com]:587
smtp_generic_maps=texthash:/etc/postfix/generic
</pre>
<p>The last line I added to the configuration tells postfix to look in a file called /etc/postfix/generic for a list of substitutions to make to email addresses found in headers being processed. I create a single line in this file:</p>
<pre>
student@ubuntu yourmail@yourprovider.tld
</pre>
<p>This entry in the map file changes the local student account to an authenticated email address. After making this change, emails sent from the student account will have their headers rewritten to give a sender identity of your personal email address, which means Mailjet will happily forward your messages to their final destination.</p>
<p>Once that&#8217;s done, I restart postfix and send a test message:</p>
<pre>
sudo /etc/init.d/postfix restart
echo hello | mailx -s "test mail" myemailaddress
</pre>
<p>The headers on my received email show that things worked more or less as expected:</p>
<table border="0">
<tr>
<td width="100%"><center><image src="/attachments/2011/postfix-tweaks/headers.png"/><center></td>
</tr>
</table>
<p>One nice thing about using the generic substitution file is that now you can accommodate different sender email addresses for every account on your system. Since you have to enter account info by hand, this doesn&#8217;t scale to a large enterprise, but it works just fine for your personal system.</p>
<p>There&#8217;s no doubt that the complexities of managing mail on a Linux system is still a bit daunting, but at least the process of simply getting outbound mail working is manageable. Give it a shot!</p>
]]></content:encoded>
			<wfw:commentRss>http://marknelson.us/2011/07/31/more-on-sending-mail-with-linux-postfix-tweaks-and-mailjet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

