ISPConfig 3 / Debian Wheezy / cURL / DNS issue with local hostnames

Discussion in 'General' started by orasis, Nov 2, 2013.

  1. orasis

    orasis Member

    ISPConfig 3 on debian goes really well but as I was testing things one by one I am stuck at something that the other computer running ISPCofig 3 on ubuntu does not do although I have done a very very similar setup.

    I got a problem when I use cURL in php scripts, it does not resolve the IP of a hostname and returns 'Couldn't resolve host'. It does fine on an online hostname but not on a local one that does not exist on the internet, which means that there is some DNS issue or misconfiguration or else. For example if I create a website with an address like http://testing.this/ using hostname 'testing.this' and creating a DNS entry for it, everything works except cURL requests.

    If I add it in the /etc/hosts in order to test, it works. This is not needed on my ubuntu setup which I also tested the same exactly thing.

    You may wonder why I care about local Ips, the reason is that I do web development and goes excellent so far, If I solve such problems I will switch all pcs to debian.

    I have tried almost everything. Basically on debian I also cannot use multiple server Ips (local Ips) if the 'Network Configuration' is not checked in System > Server Config. Is that efficient for debian ? If yes, it looks like it works fine when checked. I also noticed that in the /etc/network/interfaces it does not add an entry for dns-hostnames as it does on ubuntu. Why is it not needed ? It feels like whatever I set in System > Server Config > Nameservers has not difference.

    A very basic example of a test script I used on a blank php file from another fake website http://testing.net/ is the following (suPHP enabled and used):

    Code:
    $curl = curl_init(); 
    curl_setopt($curl, CURLOPT_HEADER, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPGET, 1);
    curl_setopt($curl, CURLOPT_URL, 'http://testing.this');
    curl_setopt($curl, CURLOPT_DNS_USE_GLOBAL_CACHE, false);
    curl_setopt($curl, CURLOPT_DNS_CACHE_TIMEOUT, 2 );
    
    echo '<pre>';
    var_dump(curl_exec($curl));
    var_dump(curl_getinfo($curl));
    var_dump(curl_error($curl));
    echo '</pre>';
    exit;
    which returns:
    Code:
    bool(false)
    array(26) {
      ["url"]=>
      string(15) "http://testing.this"
      ["content_type"]=>
      NULL
      ["http_code"]=>
      int(0)
      ["header_size"]=>
      int(0)
      ["request_size"]=>
      int(0)
      ["filetime"]=>
      int(-1)
      ["ssl_verify_result"]=>
      int(0)
      ["redirect_count"]=>
      int(0)
      ["total_time"]=>
      float(0)
      ["namelookup_time"]=>
      float(0)
      ["connect_time"]=>
      float(0)
      ["pretransfer_time"]=>
      float(0)
      ["size_upload"]=>
      float(0)
      ["size_download"]=>
      float(0)
      ["speed_download"]=>
      float(0)
      ["speed_upload"]=>
      float(0)
      ["download_content_length"]=>
      float(-1)
      ["upload_content_length"]=>
      float(-1)
      ["starttransfer_time"]=>
      float(0)
      ["redirect_time"]=>
      float(0)
      ["certinfo"]=>
      array(0) {
      }
      ["primary_ip"]=>
      string(0) ""
      ["primary_port"]=>
      int(0)
      ["local_ip"]=>
      string(0) ""
      ["local_port"]=>
      int(0)
      ["redirect_url"]=>
      string(0) ""
    }
    string(32) "Couldn't resolve host 'testing.this'"
    
    The same script on my laptop with ubuntu with same fake hostnames on the same lan returns 200 OK.

    From this PC which is on the same lan I get these:
    Code:
    [email protected]:~$ dig testing.this a
    
    ; <<>> DiG 9.8.1-P1 <<>> testing.this a
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59420
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
    
    ;; QUESTION SECTION:
    ;testing.this.            IN    A
    
    ;; ANSWER SECTION:
    testing.this.        3600    IN    A    192.168.1.160
    
    ;; AUTHORITY SECTION:
    testing.this.        3600    IN    NS    ns1.testing.this.
    testing.this.        3600    IN    NS    ns2.testing.this.
    
    ;; ADDITIONAL SECTION:
    ns1.testing.this.    86400    IN    A    192.168.1.160
    ns2.testing.this.    86400    IN    A    192.168.1.160
    
    ;; Query time: 1 msec
    ;; SERVER: 127.0.0.1#53(127.0.0.1)
    ;; WHEN: Sat Nov  2 02:49:33 2013
    ;; MSG SIZE  rcvd: 114
    
    Code:
    [email protected]:~$ dig testing.net a
    
    ; <<>> DiG 9.8.1-P1 <<>> testing.net a
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53457
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2
    
    ;; QUESTION SECTION:
    ;testing.net.            IN    A
    
    ;; ANSWER SECTION:
    testing.net.        3600    IN    A    192.168.1.150
    
    ;; AUTHORITY SECTION:
    testing.net.        3600    IN    NS    ns1.testing.net.
    testing.net.        3600    IN    NS    ns2.testing.net.
    
    ;; ADDITIONAL SECTION:
    ns1.testing.net.    86400    IN    A    192.168.1.150
    ns2.testing.net.    86400    IN    A    192.168.1.150
    
    ;; Query time: 1 msec
    ;; SERVER: 127.0.0.1#53(127.0.0.1)
    ;; WHEN: Sat Nov  2 02:52:37 2013
    ;; MSG SIZE  rcvd: 113
    
    I am looking forward to your help !
    thanks
     
  2. Quaxth

    Quaxth New Member

    Just an reminder if you don't know:
    • the Staff and most knowledgeable guy's on this matter are till and falko who're online only from Monday to Friday in time from after 8am to ~6pm (German time GMT +1h)

    Sorry but I could not help you.
     
  3. orasis

    orasis Member

    thanks for the reply my friend, and the info,
    doesn't matter I will find it before they come. The thing is I am trying to make it work 2 full days !

    Is yours working like it should as I describe ? cause I think we got similar system right now.
    Next week I will order the new equipment for the new server from Germany.
    I am getting the static IP in a month unfortunately, they are a little slow.
     
  4. Quaxth

    Quaxth New Member

    After a lot trouble the first 3 weeks now everything just works fine. Was an problem with the old Modem/Router from Thomson which triggered all problem I had. With new one from Cisco, all solved now.

    How come that your ISP/Service Provider needs a month for to assign an static IP? That's just ridiculous! Where did you living?! Must be even more in the boonies than Thailand!!
     
  5. orasis

    orasis Member

    I know, well another major company owns the lines (the actual underground lines) which will first create a new line for the static so that I don't get disconnected at all, which is good, but it takes them a month because they got a queue list of others waiting. It is the most ridiculous thing among many other ! Greece my friend.

    You said the Thomson, well that was not good for such jobs if I understand which one you mean, I am getting a Cisco one as well, I am not sure which one to choose though. I got many router modems here and I will get a new one for the new connection which will be totally useless I am 100% sure.

    I would really like you to help me out with some things you went through when the day comes to have the IP here.
     
  6. Quaxth

    Quaxth New Member

    Read a lot about the problems in Greece!! Not much differences to Thailand!

    The old Thomson were an TWC770TH Cable DOCSIS 3.0 Modem/Router and the new Cisco is an EPC3925 DOCSIS 3.0 which works excellent. I using Ultra(!) High Speed Internet 20Mbps/2Mbps provide by the 2. biggest ISP from Thailand TRUE. Work well for on inHouse Server.

    I didn't use that Server for really commercial use, I support and help some group of disabled humans for the get back on their feet's for to be able to handle all the daily hurdle's. Said this, I've have to very carefully that I keep the costing down as much as possible. Think about that the monthly income in Thailand is as low as below US$ 200 a month and even lower for disabled humans, if they've any income!

    Ok, let wait and see how it will go for you and I wish you good luck with that.

    Cheers.
     
  7. orasis

    orasis Member

    Its good to help. I release open source software. But I started this not so long ago. I sent you a private message cause we went off topic and they guys will ignore my problem with debian and hostnames ! :D
     
  8. orasis

    orasis Member

    Update:

    Although I have read around everywhere that one should not mess with the resolv.conf file anymore, it seems that this solves the issue. it contained my router's gateway ip 192.168.1.254 which was using the DNS entries set there for the internet.

    Not solved yet but almost.
     
  9. Quaxth

    Quaxth New Member

    And that seems to the problem!

    Normally the resolv.conf is holding the DNS servers address and NOT the Modem/Router Gateway address. if yopu use the Google DNS Server (which are NOT the Nameservers) your /etc/resolv.conf would look so:
    Code:
    8.8.8.8
    8.8.4.4
    The Gateway address would be in: /etc/network/interfaces and would look like:

    Code:
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    ##allow-hotplug eth0
    #iface eth0 inet dhcp
    auto eth0
    iface eth0 inet static
    	address 192.168.1.100
    	netmask 255.255.255.0
    	network 192.168.1.0
    	broadcast 192.168.1.255
    	gateway 192.168.1.254
    
    Seems to be that you really should start checking all settings again. You could do that using the Perfect Server Guide for Debian Wheezy and and follow up all steps and check all files which ar used for the settings. Some of those setting from guide you've to change to the actual settings you use in your network and others.
     
  10. orasis

    orasis Member

    I am telling you I haven't manually changed anything except that I installed mod_security and have total control over it. It is now disabled of course until I figure what is going on. this entry in resolv.conf is weird and must have been added since installation. Even ISPconfig (in gui) had the gateway set to 0.0.0.0 you must remember that you have changed this too.

    Now I am trying to set it back to not use the network interfaces and understand server IPs so that I can at least manually restart network, once when more than one eth0 are set there I cannot restart it using /etc/init.d/networking restart .. which I think is impossible and unaviodable if I want lan-ranges accessible within lan.

    edit:
    if you know a way to avoid that checkbox being checked I would be very happy to hear.
     
    Last edited: Nov 2, 2013
  11. orasis

    orasis Member

    ok done. fixed. solved.
    In a way removed all entries from /etc/resolv.conf
    Feels stable, faster and cURL is back to life.
     
  12. Quaxth

    Quaxth New Member

    That you removed the DNS from resolv.conf, will result in using the default primary and secondary DNS of your ISP which may could result in problems some time. You could freely use the Google DNS Servers with no problems and they will also works if the one from your ISP are changed or not available. you could also use any other freely available DNS Server like OpenDNS or others. OpenDNS would be the best to use in the USA and Canada because of their location. In Europe or Asia, Google DNS is just the best while OpenDNS would work but a bit more slow!

    It's up to you to run with the default of your ISP, but I wouldn't! I use the Google DNS Servers. The code I was send was the one from my server.

    You should also keep in mind that the ISPConfig Server quite sophisticated and have to handled with care. If you use your own imagination and start playing with the config and settings files, back them up first and/or copy them out of the server and save externally. And keep track of any step you're doing for not to lose the control, which would be very easy!
     
  13. orasis

    orasis Member

    Well anything related to technology has to be handled with care (+ some other things unrelated). I am on it since version 2 and unfortunately I do not only have to keep track of what I am doing inlcuding my own projects, but I also have to keep track of where all those txt files that I keep track of things are located. I got thousands of lines of TODOs. And weeeeellllllll ..usually developers do not have imagination. Imagination is a must and a dev without it is unsuccessful to my own personal view. And as I told you, having 2 dev servers I can mess with it as much as it takes. Production servers are those you should pay special attention.

    Regarding the nameservers, an OS can know only what is set. If I set nothing it knows nothing. opendns has a slow response. As you say, I can freely use google, but I don't like the idea of using google dns although it may be fast and a good fallback. But your ISPs should be faster than any other once located nearer your computers. If their servers go down often thats a problem.
     
  14. Quaxth

    Quaxth New Member

    Regardless of the settings you use, there some guidelines which need to be followed. Regarding Nameservers, those guideline is that you have to use 2 Nameservers for 1 Domain and each of the used Nameservers must have it's own separate public IP. And the Nameserver isn't a DNS Server.

    As you run your 3 Server at your Office or Home, how many Domains are you using on those Servers and how many public IP's do you have/own?

    Next, what kind of connection do you use: DSL/ADSL, ISDN, DOCSIS and on what Line: Shared or leased Line?

    Even if you use an leased line, the only Line/Connection which garants the speed and single use of the line between your location and the ISP Data Center, will be started sharing at the ISP's Datacenter even before it connects to the ISP's 1. and 2. DNS Servers! The speed which could be reached via those DNS Servers, is depend on the Ratio of using!

    In Thailand, the DNS Servers from all ISP's having an much higher Ratio than the Google DNS Servers and therefore lower speed. And I hardly believe that those will be the opposite in Greece!

    Any way, it's totally up to you how you like to use to get everything connected.
     
  15. orasis

    orasis Member

    I am not sure if you really understand what I am trying to do and what I have already done.
     
  16. Quaxth

    Quaxth New Member

    Fine for me and I'm out from now.

    Bye.
     
  17. orasis

    orasis Member

    thats ok, I just think you do not really understand what I am doing
     

Share This Page