Popular recipes tagged "ipv4"http://code.activestate.com/recipes/tags/ipv4/2017-03-05T11:00:27-08:00ActiveState Code RecipesServer supporting IPv4 and IPv6 (Python) 2017-03-05T11:00:27-08:00Giampaolo RodolĂ http://code.activestate.com/recipes/users/4178764/http://code.activestate.com/recipes/578504-server-supporting-ipv4-and-ipv6/ <p style="color: grey"> Python recipe 578504 by <a href="/recipes/users/4178764/">Giampaolo RodolĂ </a> (<a href="/recipes/tags/dualstack/">dualstack</a>, <a href="/recipes/tags/ipv4/">ipv4</a>, <a href="/recipes/tags/ipv6/">ipv6</a>, <a href="/recipes/tags/ipv6_v6only/">ipv6_v6only</a>, <a href="/recipes/tags/networking/">networking</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/socket/">socket</a>). Revision 13. </p> <p>Utility functions to create a single server socket which able to listen on both IPv4 and IPv6. Inspired by: <a href="http://bugs.python.org/issue17561" rel="nofollow">http://bugs.python.org/issue17561</a></p> <p>Expected usage:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; sock = create_server_sock(("", 8000)) &gt;&gt;&gt; if not has_dual_stack(sock): ... sock.close() ... sock = MultipleSocketsListener([("0.0.0.0", 8000), ("::", 8000)]) &gt;&gt;&gt; </code></pre> <p>From here on you have a socket which listens on port 8000, all interfaces, serving both IPv4 and IPv6. You can start accepting new connections as usual:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; while True: ... conn, addr = sock.accept() ... # handle new connection </code></pre> <p>Supports UNIX, Windows, non-blocking sockets and socket timeouts. Works with Python &gt;= 2.6 and 3.X.</p> Get external IP (Text) 2013-07-01T05:52:39-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578584-get-external-ip/ <p style="color: grey"> Text recipe 578584 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/ipv4/">ipv4</a>). Revision 2. </p> <p>In addition to the posts about IPv4. Examples on Python.</p> Get external IP (Ruby) 2013-07-01T05:51:36-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578580-get-external-ip/ <p style="color: grey"> Ruby recipe 578580 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/ipv4/">ipv4</a>). Revision 3. </p> <p>Checks IPv4</p> Get external IP (Perl) 2013-07-01T05:48:51-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578581-get-external-ip/ <p style="color: grey"> Perl recipe 578581 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/ipv4/">ipv4</a>). Revision 2. </p> <p>Checks IPv4</p> Get external IP (Bash) 2013-07-01T05:50:43-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578578-get-external-ip/ <p style="color: grey"> Bash recipe 578578 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/ipv4/">ipv4</a>). Revision 3. </p> <p>Checks IPv4</p> Get external IP (Batch) 2013-07-01T05:49:57-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578579-get-external-ip/ <p style="color: grey"> Batch recipe 578579 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/ipv4/">ipv4</a>). Revision 2. </p> <p>Checks IPv4</p> dhcp query (Python) 2011-04-10T15:41:14-07:00hassanehttp://code.activestate.com/recipes/users/4177610/http://code.activestate.com/recipes/577649-dhcp-query/ <p style="color: grey"> Python recipe 577649 by <a href="/recipes/users/4177610/">hassane</a> (<a href="/recipes/tags/dhcp/">dhcp</a>, <a href="/recipes/tags/ipv4/">ipv4</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/query/">query</a>, <a href="/recipes/tags/querying_dhcp_for_free_ip_address/">querying_dhcp_for_free_ip_address</a>). </p> <p>a simple python script that sends a dhcp discover packet and recieves the dhcp offer that contains a suggested ip address, gateway, dns servers and displays them.</p> IP and MAC addresses (Python) 2016-07-07T17:52:15-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/577191-ip-and-mac-addresses/ <p style="color: grey"> Python recipe 577191 by <a href="/recipes/users/2984142/">Jean Brouwers</a> (<a href="/recipes/tags/ios/">ios</a>, <a href="/recipes/tags/ip/">ip</a>, <a href="/recipes/tags/ipv4/">ipv4</a>, <a href="/recipes/tags/mac/">mac</a>, <a href="/recipes/tags/macos/">macos</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/python2_4/">python2_4</a>, <a href="/recipes/tags/python3_5/">python3_5</a>, <a href="/recipes/tags/uuid/">uuid</a>, <a href="/recipes/tags/windows/">windows</a>). Revision 3. </p> <p>This module collects all IP and MAC addresses from several available sources on the underlying system. See the module documentation for more details, supported Python releases and platforms.</p> IP address and CIDR mask conversion to network and broadcast (Python) 2010-08-25T21:37:16-07:00Rafael Zanellahttp://code.activestate.com/recipes/users/4165925/http://code.activestate.com/recipes/577375-ip-address-and-cidr-mask-conversion-to-network-and/ <p style="color: grey"> Python recipe 577375 by <a href="/recipes/users/4165925/">Rafael Zanella</a> (<a href="/recipes/tags/cidr/">cidr</a>, <a href="/recipes/tags/ipv4/">ipv4</a>, <a href="/recipes/tags/mask/">mask</a>, <a href="/recipes/tags/network/">network</a>). Revision 2. </p> <p>Convert dotted-quad IPv4 addresses along with CIDR mask to host-byte-order long integer ip, network and broadcast, along with their dotted-quad IPv4 representation.</p>