Am trying to perform an ftp connection to another server.
So currently i have done
$host="server_to_connet_ip"
ftp_connect ( $host [ 21 [, int $timeout = 90 ]] )
This works totally fine when the the server to connect to doesnt limit the ip address.
Currently there is a limit on the ip address that can connect to the server and my vps ip address has already been whitelisted
How can i still perform the ftp connection with the origin ip address as my server ip address(where application is hosted) as currently each and every request i make happen to appear to be from my local computer outgoing ip address not the servers(where application is hosted) ip address
I have also checked on using curl as an alternative but i cannot figure out how.
SO in curl this would be something like
curl ftp://serverip --user myname:mypassword
But how can this be achieved in such away that when performing the ftp connection request the request will originate from my server ip address(when i host my application) not my local computer ip address.
You can't, it's not possible to spoof an IP and receive a response because the response will go to the IP that you spoofed and you aren't actually calling from there.
You need to add the IP that you will be connecting from to the whitelist on the server you are connecting to.
Related
I'm trying to see what my server's request IP is. For example.
<?php
$contents = file_get_contents("https://example.com");
?>
I want to know what IP my server is using to connect to example.com. I cannot use tools like IPLookUp because that just gets the IP of the response and if I have cloudflare on my domain, then it will keep showing cloudflares proxy IP's.
If I use $_SERVER['SERVER_ADDR'] it just shows me the local IP 127.0.0.7
Use gethostbyname
gethostbyname ( string $hostname )
I have recently bought a NodeMcu Lua (Lolin) and I am making some tests with it.
What I have tried to do is send a TCP packet to a php script I have on my server, If I try to send the packet using port and hostname it works, but if I try with IP it doesn't, is this a bug or what?
This is just a test because what I actually need to do is use this board to send TCP packets to a php script I have on my pc (so in the same network) running with XAMPP.
Why the board doesn't send any packet using IP but does typing the hostname?
Also what addresses I need to use to send packets from the board to my computer (both in the php script that acts as a server and the board which acts as a client)?
This is the LUA code I am using for the board:
wifi.setmode(wifi.STATION)
wifi.sta.config("Alice-49289348", "mypassword")
wifi.sta.connect()
Disp = "D1"
Port = 9863
HostIP = "81.139.206.12"
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, c) print(c) end )
conn:on("connection", function(conn, c)
print("Connected")
conn:send(Disp)
end )
conn:on("sent", function(conn, c)
print("Sent: " .. Disp)
conn:close()
end )
conn:connect(Port,HostIP)
print("Done")
I have changed some values like IP address, wifi, password etc for privacy.
It seems that you can obtain feedback using "reconnection", "disconnection" events.
https://nodemcu.readthedocs.io/en/master/en/modules/net/#netsocketon
Also, this function may help to verify the correctness of ip.
https://nodemcu.readthedocs.io/en/master/en/modules/net/#netsocketdns
Hi I need to know the IP address of my website to give to my payment gateway. I know I can find an IP address by going to any of the websites which come up on google, but my understanding is that they give the domain's IP address which may be different from the IP address of the server the site is hosted on.
So how to I find out what the IP address of my server is?
Thanks :)
Run this from the command line to get your server's outgoing IP:
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
The server's IP address can be found with the $_SERVER variable:
<?php
echo $_SERVER['SERVER_ADDR'];
you can also do a quick PHP output of
<?php
phpinfo();
?>
it will contain all the values you need for your host details (just don't leave this file public after you use it).
What do you mean by the domain IP? The IP returned from a DNS lookup when querying your domain? This is most likely equal to the IP of your (shared) server, otherwise your website would be unreachable.
An exception to that is when the IP your DNS record represents belongs to a proxy server, which forwards the request to the real server.
You could always get the public IP address of the server by visiting www.whatismyip.com from the server.
I'm quite a novice at PHP.
I would like the IP address that I (myself, only. I modified my hosts file for the HotSpot shield webpage) have been given when using HotSpot shield to show up on my webpage, but unfortunately, it's echoed as 127.0.0.1. The main objective is that when I connect, the IP address that I've been set is echoed on the page. This is what code I've used:
<?php $rmt = $_SERVER["REMOTE_ADDR"]; echo "$rmt \n" ?>
The only problem is is that $rmt is 127.0.0.1. Do any of you know how to get it to display the public IP address to be displayed?
This can happen with local proxy servers; you could check out the other headers that are sent with your request by var_dump($_SERVER); and search for stuff like X-Forwarded-For or X-Real-IP
$_SERVER['REMOTE_ADDR'] is referring to the IP adress from which you connected. If you're running the server on your local machine and connecting from your local machine, it uses your local ip (127.0.0.1 is always "localhost").
In order to show a different ip you need to run it on another server (a public web hotel server preferably), or connect to your server from another machine.
I had just the same issue.
As it turns out, I was getting the proxy IP address instead of my own IP.
So I ran:
var_dump($_SERVER)
//you could also use print_r($_SERVER);
And then looked for something like this:
["HTTP_X_REAL_IP"]
Then captured it into a var like this:
$ip = getenv('HTTP_X_REAL_IP')
Ok simple enough
<?PHP
echo $_SERVER[REMOTE_ADDR];
?>
Ok maybe not, I my IP is currently 72.184.212.85 however the code above which I am using on an IP blocking system for a script shows my IP as my home server IP of 127.0.0.1
So when I go to my script my IP is shown as 127.0.0.1 but when I go to other websites it is shown as 72.184.212.85
How can I get the first value to show on my test server?
$_SERVER['REMOTE_ADDR'] will always show the IP address from which the request came. If you access your own script on your own computer within your own network, your external IP address never comes into play. The request would have to leave your local network and then come back in for the external address to show up, but if it's all local, that'll never happen.
You'll have to make your server publicly accessible and then access it from the public address. I'm guessing you're currently using localhost to access your server?
run your server say port 8080 and then forward the port in your router so it's public to the internet. Then visit your webpage/phpscript from http://72.184.212.85:8080 instead of http://localhost:8080.
Here is a ridiculous solution that I wouldn't recommend:
Register your home IP with a domain name, then see where the request came from via URL:
$url = $_SERVER["SERVER_NAME"];
or
$url = $_SERVER["HTTP_HOST"];
and then do a dns lookup of that result, which should return the IP it's registered to, ie your external IP.
$ext_ip = gethostbyaddr($url);
The only reason this wouldn't work (so sorry if I'm wrong), is if SERVER_NAME uses the same method as "REMOTE_HOST", which is a reverse DNS lookup, which won't resolve, as your internal IP won't be registered to that domain name. An easy way to check is to do either:
phpinfo();
and see what the environmental variables are.