Showing posts with label network. Show all posts
Showing posts with label network. Show all posts

Sunday, March 23, 2014

Become an expert in TCP/IP networking

In our connected world nothing works without the TCP/IP protocol family. Whether you use a web browser or mail or your favorite social network, a reliable network connection is the base of all this applications. So every network administrator should have a in depth knowledge of this technology. To get this knowledge you can read all RFC (Request for Comments) of the protocols you use which will be not an easy task, or you can read the redbook TCP/IP Tutorial and Technical Overview from IBM.

This redbook is not new, but it is a very valuable resource to learn how the internet works. In this redbook there is not only a in depth description of IP, TCP and UDP, but there are also explanations how the most important Internet application protocols like DHCP, DNS, BOOTP, SMTP, HTTP and so on work. Although the book is from 2006 newer technologies like IPv6 or VoIP have their own chapters too. And the best is, that this book is absolute vendor neutral. You do not have to use IBM products to benefit from this redbook.

So if you are a network administrator or a developer who develop network applications you should read this book.

Wednesday, October 24, 2012

Probleme mit dem Zugriff auf den eigenen Host

Zur Eröffnung eines sockets für den Zugriff auf den Localhost habe ich bisher immer die Methode getLocalHost() der InetAddress Klasse verwendet.
          Socket socket=newSocket(InetAddress.getLocalHost(),5146);
          PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
          BufferedReader in = new BufferedReader(new inputStreamReader(socket.getInputStream()));
          out.println("Test");
          parameter=in.readLine();

Bisher hat das auch immer relativ gut funktioniert, bis der Code auf einem Client gelaufen ist der den Cisco VPN Client verwendet hat. Sobald ein Cryptotunnel aufgebaut wurde, wird die lokale Adresse des Clients auf eine Adresse aus dem VPN Pool umgestellt und bei Ausführung des oben genannten Codes kommt es zu keiner Verbindung mehr, sondern es kommt ein Timeout. Der Grund ist, dass getLocalHost() nicht etwa das loopback (127.0.0.1) Interface zurück gibt, sondern die IP Adresse der Netzwerkkarte. Diese wechselt nach VPN Einwahl und schon verbindet man sich mit der falschen Adresse. Eine einfache Möglichkeit das Problem zu lösen ist folgenden Code zu verwenden.
          Socket socket=new Socket(InetAddress.getByName("localhost"),5146);
          PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
          BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
          out.println("Test");
          parameter=in.readLine();
Das bietet aber noch immer die Gefahr das in der Hostsdatei localhost nicht richtig definiert ist und es dann wieder zu Problemen kommt. Nach einiger Recherche in der Dokumentation der Klasse Intnetadress habe ich dann den richtigen Weg gefunden. Die Methode getByName() darf man mit einem null Wert aufrufen und dann gibt sie automatisch und immer das loopback interface zurück.
          Socket socket=new Socket(InetAddress.getByName(null),5146);
          PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
          BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
          out.println("Test");
          parameter=in.readLine();
ad