<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: NAT code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 08:50:13 GMT</pubDate>
    <description>DZone Snippets: NAT code</description>
    <item>
      <title>Ruby one-liner to find external IP address across NAT router.</title>
      <link>http://snippets.dzone.com/posts/show/3947</link>
      <description>Sometimes you just have to know what your external IP address is when there's a NAT between you and the rest of the world.  Say you're in a DHCP environment that's constantly changing your IP, for example.  This one-liner gives you your IP address as a string (in this case stored as "my_ip").&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;my_ip = (require 'open-uri' ; open("http://myip.dk") { |f| /([0-9]{1,3}\.){3}[0-9]{1,3}/.match(f.read)[0].to_a[0] })&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 02 May 2007 14:23:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3947</guid>
      <author>ttmrichter (Michael T. Richter)</author>
    </item>
  </channel>
</rss>
