Allow Incoming Responses Apache. On Ubuntu 11.10 - Curl

0

I'm trying to get a Curl Response from an outside server, however I noticed I cant neither PING the server in question nor connect to it.

I tried disabling the iptables firewall but I had no success. My server is running behind a Cisco Linksys WRTN310N Router with the DD-wrt firmware Installed. In which I already disabled the firewall.

Here are my network settings: Ifconfig

eth0      Link encap:Ethernet  HWaddr 00:26:b9:76:73:6b
          inet addr:192.168.1.120  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::226:b9ff:fe76:736b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:49713 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30987 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:52829022 (52.8 MB)  TX bytes:5438223 (5.4 MB)
          Interrupt:16

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:341 errors:0 dropped:0 overruns:0 frame:0
          TX packets:341 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:27604 (27.6 KB)  TX bytes:27604 (27.6 KB)

/etc/resolv.conf

nameserver 192.168.1.1

/etc/nsswitch.com

passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

/etc/host.conf

order hosts,bind
multi on

/etc/hosts

127.0.0.1       localhost
127.0.0.1       callcenter

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

/etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.1.120
        netmask 255.255.255.0
        network 192.168.1.1
        broadcast 192.168.1.255
        gateway 192.168.1.1

The Url to which im trying to get a connection to is https://www.veripayment.com/integration/index.php When I ping it on terminal heres what I get

daniel@callcenter:~$ ping https://www.veripayment.com/integration/index.php
ping: unknown host https://www.veripayment.com/integration/index.php


daniel@callcenter:~$ ping www.veripayment.com
PING www.veripayment.com (69.172.200.5) 56(84) bytes of data.

--- www.veripayment.com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1007ms

PHP Function in codeigniter

public function authorizePayment(){
    //---------------------------------------------------
    // Authorize a payment
    //---------------------------------------------------


        // Get variables from POST array
        $post_str = "action=payment&business="      .urlencode($this->input->post('business'))
                    ."&vericode="                   .urlencode($this->input->post('vericode'))
                    ."&item_name="                  .urlencode($this->input->post('item_name'))
                    ."&item_code="                  .urlencode($this->input->post('item_code'))
                    ."&quantity="                   .urlencode($this->input->post('quantity'))
                    ."&amount="                     .urlencode($this->input->post('amount'))
                    ."&cc_type="                    .urlencode($this->input->post('cc_type'))
                    ."&cc_number="                  .urlencode($this->input->post('cc_number'))
                    ."&cc_expdate="                 .urlencode($this->input->post('cc_expdate_year')).urlencode($this->input->post('cc_expdate_month'))
                    ."&cc_security_code="           .urlencode($this->input->post('cc_security_code'))
                    ."&shipment="                   .urlencode($this->input->post('shipment'))
                    ."&first_name="                 .urlencode($this->input->post('first_name'))
                    ."&last_name="                  .urlencode($this->input->post('last_name'))
                    ."&address="                    .urlencode($this->input->post('address'))
                    ."&city="                       .urlencode($this->input->post('city'))
                    ."&state_or_province="          .urlencode($this->input->post('state_or_province'))
                    ."&zip_or_postal_code="         .urlencode($this->input->post('zip_or_postal_code'))
                    ."&country="                    .urlencode($this->input->post('country'))
                    ."&shipping_address="           .urlencode($this->input->post('shipping_address'))
                    ."&shipping_city="              .urlencode($this->input->post('shipping_city'))
                    ."&shipping_state_or_province=" .urlencode($this->input->post('shipping_state_or_province'))
                    ."&shipping_zip_or_postal_code=".urlencode($this->input->post('shipping_zip_or_postal_code'))
                    ."&shipping_country="           .urlencode($this->input->post('shipping_country'))
                    ."&phone="                      .urlencode($this->input->post('phone'))
                    ."&email="                      .urlencode($this->input->post('email'))
                    ."&ip_address="                 .urlencode($this->input->post('ip_address'))
                    ."&website_unique_id="          .urlencode($this->input->post('website_unique_id'));

                    // Send URL string via CURL
                    $backendUrl = "https://www.veripayment.com/integration/index.php";
                    $this->curl->create($backendUrl);
                    $this->curl->post($post_str);
                    $return = $this->curl->execute();

                    $result = array();
                    // Explode array where blanks are found
                    $resparray = explode(' ', $return);

                    if ($resparray)
                    {
                      // save results into an array
                      foreach ($resparray as $resp) {
                        $keyvalue = explode('=', $resp);
                        if(isset($keyvalue[1])){
                        $result[$keyvalue[0]] =  str_replace('"', '', $keyvalue[1]);
                        }
                      }
                    }
                    return $result;

}

This gets an empty result array. This function however works well in the previous server where the script was hosted before. No modifications where made whatsoever

Thanks in Advance

Daniel Adarve

Posted 2012-03-25T21:13:05.973

Reputation: 1

Answers

0

The server at www.veripayment.com (or their firewall in front of it) is configured to discard ping requests.

C:\Users\RGB> ping www.veripayment.com

Pinging veripayment.com [69.172.200.5] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 69.172.200.5:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

It responds to HTTP requests:

C:\Users\RGB> wget http://www.veripayment.com
--22:34:37--  http://www.veripayment.com/
           => `index.html.1'
Resolving www.veripayment.com... done.
Connecting to www.veripayment.com[69.172.200.5]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

    [ <=>                                 ] 922          900.39K/s

22:34:37 (900.39 KB/s) - `index.html.1' saved [922]


C:\Users\RGB>

For an outbound HTTP request you shouldn't need to disable any firewall in your router.


Update:

You are using lib_curl from PHP, but in a way I don't recognise.

Other PHP examples of curl use functions like curl_init() and curl_exec()

I suspect you need to dump out what you are sending (the post data), compare PHP versions and amend the code to check for error responses.

I don't know how you'd do that with the library you are using, with other PHP curl libs you do something like this:

if (curl_errno($ch)) {
 print curl_error($ch);
} else {
 curl_close($ch);
}

I'd update the PHP script with something equivalent.

My guess is your PHP version and environment is not the same as it was on your old server.

RedGrittyBrick

Posted 2012-03-25T21:13:05.973

Reputation: 70 632

so does this mean its an issue with Curl? – Daniel Adarve – 2012-03-25T21:39:03.960

@Daniel: I doubt there's anything wrong with curl. Can you edit your question and cut and paste your curl command and it's output at the end? – RedGrittyBrick – 2012-03-25T21:41:19.213

I was working on a paid server on 1and1.com, basically we want to have this script in a local server so I bought a Dell Server and installed Ubuntu on it. It must be something with the Ubuntu configuration. – Daniel Adarve – 2012-03-25T21:47:57.087