Deine öffentliche IP-Adresse lautet:

Deine lokale IP-Adresse lautet:

Was ist ipy.ch?

ipy.ch gibt dir einfach und schnell deine öffentliche IP-Adresse mit einer API bekannt. Das ist nützlich wenn du hinter einer Firewall bist, wenn du einen Proxy oder VPN testen willst, oder wenn du versuchst eine Remoteverbindung zu erstellen. Oder für was auch immer eine öffentliche IP-Adressen API praktisch ist.

API

Die API von ipy.ch ist sehr einfach zu benutzen. Du hast dabei drei Optionen. Du kannst entweder deine öffentliche IP-Adresse unformatiert beziehen (als Text), oder im JSON Format, oder du zeigst dir deine öffentliche IP-Adresse im JSONP Format an. Letzteres braucht man zum Beispiel für die Javascript Entwicklung mit jQuery.

API URL Antwort Typ Beispiel Output (IPv4) Beispiel Output (IPv6)
https://api.ipy.ch text 66.249.64.136 ?
https://api.ipy.ch?format=json json {"ip":"66.249.64.136"} ?
https://api.ipy.ch?format=jsonp jsonp callback({"ip":"66.249.64.136"}); ?
https://api.ipy.ch?format=jsonp&callback=getip jsonp getip({"ip":"66.249.64.136"}); ?

Beispiele

Hier ein paar Code-Beispiele wie man die API in verschiedenen Programmiersprachen verwenden kann.

Bash


#!/bin/bash

ip=$(curl -s https://api.ipy.ch)
echo "Meine öffentliche IP-Adresse lautet: $ip"

Python


# Dieses Beispiel braucht die requests libery
from requests import get

ip = get('https://api.ipy.ch').text
print 'Meine öffentliche IP-Adresse lautet:', ip

Ruby


require "net/http"

ip = Net::HTTP.get(URI("https://api.ipy.ch"))
puts "Meine öffentliche IP-Adresse lautet: " + ip

PHP


<?php
    $ip = file_get_contents('https://api.ipy.ch');
    echo "Meine öffentliche IP-Adresse lautet: " . $ip;
?>

Perl


use strict;
use warnings;
use LWP::UserAgent;

my $ua = new LWP::UserAgent();
my $ip = $ua->get('https://api.ipy.ch')->content;
print 'Meine öffentliche IP-Adresse lautet: '. $ip;

VB.NET


Dim client as New System.Net.WebClient
Dim ip as String = client.DownloadString("https://api.ipy.ch")

NodeJS


var http = require('http');

http.get({'host': 'api.ipy.ch', 'port': 80, 'path': '/'}, function(resp) {
  resp.on('data', function(ip) {
    console.log("Meine öffentliche IP-Adresse lautet: " + ip);
  });
});

Javascript


<script type="application/javascript">
  function getIP(json) {
    document.write("Meine öffentliche IP-Adresse lautet: ", json.ip);
  }
</script>

<script type="application/javascript" src="https://api.ipy.ch?format=jsonp&callback=getIP"></script>

jQuery


<script type="application/javascript">
  $(function() {
    $.getJSON("https://api.ipy.ch?format=jsonp&callback=?",
      function(json) {
        document.write("Meine öffentliche IP-Adresse lautet: ", json.ip);
      }
    );
  });
</script>

C#


using System;
using System.Net;

namespace ipy.Examples {
    class Program {
        public static void Main (string[] args) {
            WebClient webClient = new WebClient();
            string publicIp = webClient.DownloadString("https://api.ipy.ch");
            Console.WriteLine("Meine öffentliche IP-Adresse lautet: {0}", publicIp);
        }
    }
}

PowerShell


$ip = Invoke-WebRequest -Uri https://api.ipy.ch?format=json | ConvertFrom-Json
"Meine öffentliche IP-Adresse lautet: {0}" -f $ip.ip

Objective-C


NSURL *url = [NSURL URLWithString:@"https://api.ipy.ch"];
NSString *ipAddress = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"My public IP address is: %@", ipAddress);

 Öffentliche IP-Adresse

Die öffentliche IP-Adresse (IP=Internet Protocol) zeigt an mit welcher IP-Adresse du dich in das Internet einbindest. Sie wurde mit der ipy.ch IP Adressen API augelesen. Es ist die Adresse an deinem Wide Area Network (WAN) Anschluss und wird innerhalb des Adressbereiches von deinem Provider vergeben. Diese öffentlichen IP-Adress-Bereiche werden von einer internationalen Organisation vergeben ( www.iana.org) bzw. wird die Vergabe an regionale Stellen delegiert (für Europa www.ripe.net)

 Lokale IP-Adresse

Die lokale oder private IP-Adresse zeigt an mit welcher IP-Adresse du in deinem lokalen Netzwerk gefunden wirst. Diese Adresse wurde hier mit WebRTC ausgelesen. Diese Adressen sind Teil von den reservierten Adressbereichen. Diese privaten IP Informationen sollten eigentlich nicht ausserhalb deines lokalen Netzes zugänglich sein. Es ist aber bei Firefox, Chrome und zum Teil auch bei Opera möglich diese Informationen mit WebRTC auszulesen. Heise hat darüber berichtet.
Eure private IP findet ihr ganz einfach mit der Konsole heraus. Bei Windows mit ipconfig und bei unixoiden Systemen mit ifconfig.

Private IP unter Windows findet ihr beim Eintrag IPv4 Address

C:\ipconfig /all

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Intel(R) Transino(R) 1522R Gigabit Network Connection
   Physical Address. . . . . . . . . : FF-
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv6 Address. . . . . . . . . . . : 2002:(Preferred)
   Temporary IPv6 Address. . . . . . : 2002:(Preferred)
   Link-local IPv6 Address . . . . . : fe80::(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.0.2(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Sonntag, 11. Oktober 2035 19:08:00
   Lease Expires . . . . . . . . . . : Samstag, 24. Oktober 2035 08:21:43
   Default Gateway . . . . . . . . . : fe80::f
                                       192.168.0.1
   DHCP Server . . . . . . . . . . . : 192.168.0.1
   DHCPv6 IAID . . . . . . . . . . . : 1111111111
   DHCPv6 Client DUID. . . . . . . . : 00-00
   DNS Servers . . . . . . . . . . . : fe80::
                                       192.168.0.1
   NetBIOS over Tcpip. . . . . . . . : Enabled


Private IP unter Linux oder Mac findet ihr beim Eintrag inet

$ ifconfig

eth0: flags=2344 UP,BROADCAST,RUNNING,MULTICAST  mtu 1500
        inet 192.168.0.3  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80:  prefixlen 0  scopeid 0x00
        ether 00:  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 0  memory 0x000000-f00000

To-Do

Hier ein kleiner Ausblick auf kommende Features und Verbesserungen:

  • IPV6 support verbessern
  • Mehr Anwendungsbeispiele