Проблема с gethostbyname

Discussion in 'PHP' started by kraken, 21 Sep 2010.

  1. kraken

    kraken Member

    Joined:
    2 Jan 2009
    Messages:
    74
    Likes Received:
    75
    Reputations:
    5
    Код
    PHP:
    <?php
    echo gethostbyname('ya.ru');
    ?>
    Выдает мне
    Code:
    ya.ru
     
    как исправить проблему и заставить gethostbyname корректно работать?
     
  2. barnaki

    barnaki Elder - Старейшина

    Joined:
    2 Nov 2008
    Messages:
    676
    Likes Received:
    140
    Reputations:
    4
    в мануале написано
    <?php
    $ip = gethostbyname('www.example.com');

    echo $ip;
    ?>
     
  3. kraken

    kraken Member

    Joined:
    2 Jan 2009
    Messages:
    74
    Likes Received:
    75
    Reputations:
    5
    и что ты этим хочешь сказать?
     
  4. barnaki

    barnaki Elder - Старейшина

    Joined:
    2 Nov 2008
    Messages:
    676
    Likes Received:
    140
    Reputations:
    4
    попробуй сделать по образцу . мало ли
     
  5. kraken

    kraken Member

    Joined:
    2 Jan 2009
    Messages:
    74
    Likes Received:
    75
    Reputations:
    5
    хватит уже говорить глупостей.
    проблема все еще не решена (( жду вашей помощи
     
  6. OSW

    OSW Elder - Старейшина

    Joined:
    12 Jul 2007
    Messages:
    325
    Likes Received:
    56
    Reputations:
    7
    хм, а у меня работает все.
    код:

    <form method="post">
    <input type="text" name="text">
    <input type="submit" name="button" value="CheckIT">
    </form>

    <?php
    if (isset($_POST['button'])) {
    $i = $_POST['text'];
    echo gethostbyname($i);
    }
    ?>
     
    #6 OSW, 21 Sep 2010
    Last edited: 21 Sep 2010
  7. kraken

    kraken Member

    Joined:
    2 Jan 2009
    Messages:
    74
    Likes Received:
    75
    Reputations:
    5
    да емае. понятно что у вас он работает. вот у меня на ноуте работает на компе нет. Стоит Linux
    Code:
    ping yandex.ru
    PING yandex.ru (87.250.251.11) 56(84) bytes of data.
    64 bytes from yandex.ru (87.250.251.11): icmp_seq=1 ttl=57 time=26.5 ms
    64 bytes from yandex.ru (87.250.251.11): icmp_seq=2 ttl=57 time=28.3 ms
    
    ...значит с ДНС все норм
    
    route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.8.0.1        10.162.17.1     255.255.255.255 UGH   0      0        0 eth0
    92.50.189.162   0.0.0.0         255.255.255.255 UH    0      0        0 ppp5
    10.162.17.0     0.0.0.0         255.255.255.128 U     202    0        0 eth0
    192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
    10.0.0.0        10.162.17.1     255.0.0.0       UG    202    0        0 eth0
    0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp5
    
    вроде нормально
     
    но код на пхп
    echo gethostbyname('ya.ru');
    выдает ya.ru
     
  8. OSW

    OSW Elder - Старейшина

    Joined:
    12 Jul 2007
    Messages:
    325
    Likes Received:
    56
    Reputations:
    7
    у тебя safe mode случаем не on?
    и какой линь стоит на компе?
     
    #8 OSW, 21 Sep 2010
    Last edited: 21 Sep 2010
  9. kraken

    kraken Member

    Joined:
    2 Jan 2009
    Messages:
    74
    Likes Received:
    75
    Reputations:
    5
    Code:
     
    [root@localhost ~]# cat /etc/php/php.ini | grep safe_mode
    safe_mode = Off
    ; then turn on safe_mode_gid.
    safe_mode_gid = Off
    ; When safe_mode is on, UID/GID checks are bypassed when
    safe_mode_include_dir =
    ; When safe_mode is on, only executables located in the safe_mode_exec_dir
    safe_mode_exec_dir =
    safe_mode_allowed_env_vars = PHP_
    ; protected even if safe_mode_allowed_env_vars is set to allow to change them.
    safe_mode_protected_env_vars = LD_LIBRARY_PATH
    sql.safe_mode = Off
    [root@localhost ~]# 
    
    
    дистрибутив archlinux
     
  10. OSW

    OSW Elder - Старейшина

    Joined:
    12 Jul 2007
    Messages:
    325
    Likes Received:
    56
    Reputations:
    7
    блин, странно. Мб исходящие с 80 порта закрыты?
     
  11. kraken

    kraken Member

    Joined:
    2 Jan 2009
    Messages:
    74
    Likes Received:
    75
    Reputations:
    5
    Code:
    [root@localhost ~]#[root@localhost ~]# iptables -L
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination         
       
    что еще может закрыть 80 порт?