What i have:
Server with virtualbox, where via vagrant I setup a virtual machines. this VMs behind NAT virtualbox
In logs of web server I got this IP address 10.0.2.2
10.0.2.2 - - [19/Apr/2016:17:11:03 +0300] "GET /place/find-by-text?term= HTTP/1.1" 302 5 "********board" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"
But for some reason I need to get a real IP address in my VMs webservers
I found that topics https://serverfault.com/questions/290116/how-to-get-virtualbox-nat-working-with-actual-client-ips where suggest use
VBoxManage modifyvm <your-vm name> --nataliasmode1 proxyonly
But it doesn't help, maybe I don't understood correctly, and I still see NAT virtualbox address 10.0.2.2
How to resolve this problem?
UDP: In access log of webserver(nginx for me) I want to see the real IP of client(like this 15.15.15.120) not address 10.0.2.2
UDP: My server have only one public IP and I don't have able to put VM into internet directly.
You can make a request out to the network to get the information:
curl http://ipinfo.io/ip
This has the added advantage of also getting the IP address of the internet facing host (in the case when your guest is double or triple NAT'd)
Related
I have been searched many resources, but I can't solve this problem.
Firstly, I want to clarify that, my windows 10 all firewall options are turned off (also turned off ubuntu server 16.04)
Windows firewall settings
this is my host machine ip configuration (windows 10)
Host machine IP
this is my NatNetwork configuration in Virtualbox
NatNetwork configuration in Virtualbox
this is my port forwarding configuration in NatNetwork
Port Forwarding configuration
I want to mention that when I use 127.0.0.1 Ip address as a port forwarding HOST IP address. this is not working also, but I can ping from my host to 127.0.0.1 IP address.
this is my ubuntu_server 16.04 ip configuration
Ubuntu_server 16.04 IP configuration
When I ping from ubuntu_server to my HOST (from 172.31.0.4 to 192.168.0.110), I can ping
from VM to HOST ping
But I can't ping from HOST to VM (from 192.168.0.110 to 172.31.0.4), I get the request timed out.
enter image description here
So, I can't ping from HOST to VM, please help me solving this problem
I have a problem VM and HOST connection.
I created new beanstalk environment PHP 7.3 running on 64bit Amazon Linux/2.9.6, Apache - with default PHP sample app. It's a classic load balancer type. But for now I have made it listening only to http at port 80. No https.
After deployment default PHP sample app runs fine on beanstalk environment url(cname) provided. Sample PHP app opens and because my environment is listening to just http so in browser I get "not secure" warning as normal behaviour but my Beanstalk URL is working so far and I see PHP sample app on browser.
Now I created fresh Laravel 7.x projects on my local machine. I tested and default "/" route points to welcome Laravel page. I deployed this sample Laravel project to my environment using EB on my Mac terminal.
Deploy is successful. I change the document root to "/public" in configuration because Laravel's index in inside public folder. Environment is in green health. Now I open Beanstalk URL and I see it's just taking a minute or so then it fails to load page saying "server where this page is located isn't responding" in Safari browser.
I checked my security group and it is listening to both http and ssh.
Final note: I have been doing this for long time. This is my first time experiencing this issue. Am I missing something?
Edit
I went inside Ec2 dashboard. I copied both Public DNS (IPv4) and IPv4 Public IP, tried accessing them in browser. It just takes time to connect and finish with "page not responding error".
My inbound rules for my security group:
HTTP TCP 80 0.0.0.0/0 -
SSH TCP 22 0.0.0.0/0 -
HTTPS TCP 443 0.0.0.0/0 -
Edit 2
Here is my access log from environment logs:
172.31.21.84 (103.86.57.43) - - [24/May/2020:18:34:31 +0000] "GET / HTTP/1.1" 301 278 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15"
103.86.57.58 (-) - - [24/May/2020:18:37:45 +0000] "GET / HTTP/1.1" 301 230 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15"
172.31.10.171 (195.154.94.244) - - [24/May/2020:18:45:10 +0000] "GET / HTTP/1.1" 301 228 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0"
I see that GET is called on / and http 301 is returned. It moved permanently. What does this mean?
I solved my issue by creating new fresh environment from eb cli in terminal using
eb create
Not sure why this worked but gave issue when creating environment from console dashboard.
I've updated docker on my os x 10.10, so it's now using os x native virtualization. However, I've found it tricky to connect to my host machine from within my nginx container. I tried this:
/sbin/ip route|awk '/default/ { print $3 }'
And got the answer:
172.17.0.1
Then I used this ip in docker-compose.yml:
extra_hosts:
- "master:172.17.0.1"
But nonetheless I keep getting errors:
172.17.0.1 - - [21/Jul/2016:09:33:46 +0000] "GET /api HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/07/21 09:33:46 [error] 7#7: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: soc-credit.ru, request: "GET /api HTTP/1.1", upstream: "http://172.17.0.5:8080/api", host: "localhost"
Please note this part: client: 172.17.0.1. Since I've made request from host machine, it proves that ip I got in first step was correct. But connection wasn't established anyway.
I want to stress out that I have a problem connecting FROM WITHIN container TO host and not vice versa.
What am I doing wrong? Thank you!
Had the same problem and being inexperienced in Docker and network configurations I struggled to get the various proposed solutions working. However since this update to Docker for Mac:
Docker Community Edition 17.06.0-ce-mac18, 2017-06-28 (stable)
I've found using the 'experimental' hostname docker.for.mac.localhost
allows me to contact services running on the Mac host from within a container. Very useful for dev!
I am having the same problem and I've found this
https://docs.docker.com/docker-for-mac/networking/#/known-limitations-use-cases-and-workarounds
Notice paragraph 'I want to connect from a container to a service on the host'
I haven't yet tried it because I am looking for a more concrete solution (anyway other than adding alias to my lo address)...
If somebody has something on it please inform!
From docker 18.03 onwards official recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host, this is for development purpose, refer to https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds
latest:DNS name host.docker.internal should be used for host resolution from containers. Older aliases (still valid) are deprecated in favor of this one. (See https://datatracker.ietf.org/doc/html/draft-west-let-localhost-be-localhost-06).
docker.for.mac.host.internal should be used instead of docker.for.mac.localhost from Docker Community Edition 17.12.0-ce-mac46 2018-01-09.
this allows you to connect to service running on your on mac from within a docker container.please refer below links
understanding the docker.for.mac.localhost behavior
release notes
I am in the process of setting up a Hadoop cluster of virtual machines on my LAN and a process on one of the vms (the ResourceManager) provides a Web UI which is exhibiting strange behavior. All vms run from my desktop and have been assigned ips.
The URL I am targeting is resourcemanager:8088 and here is the behavior.
From other vms running on my desktop:
curl -v resourcemanager:8088
returns an HTTP 302 Found response with Location: http://resourcemanager:8088/cluster. Looking this up I saw this is a redirect, and curl -L resourcemanager:8088 successfully retrieves the HTML.
From the desktop running the vms:
Trying to reach the URL from (Chrome) browser gives net::ERR_CONNECTION_REFUSED. Also
curl resourcemanager:8088
returns curl: (7) Failed to connect to resourcemanager port 8088: Connection refused.
Each vm has the same /etc/hosts:
::1 localhost
127.0.0.1 localhost
10.0.0.3 namenode
10.0.0.4 resourcemanager
10.0.0.5 datanode1
and the .../drivers/etc/hosts file on my (Windows) desktop looks the same minus the localhost lines.
To make matters more complicated, a second process (the NameNode) also provides a web ui, call it namenode:50070, and I am able to curl it from both the desktop and vms, and I can get to it via browser from my desktop.
Any ideas?
EDIT
Specs:
Desktop OS: Windows 10
VMs OS: Arch Linux latest (Linux kernel 4.5.4)
An initial Arch+hadoop VM was created with Hyper-V, then cloned to create the three "cluster" vms listed above. After cloning, each vm was given a unique hostname (listed above) and assigned a reserved IP address from my router (also listed above). All VMs use an "external vm switch".
I cannot comment, because I do not have 50 reputation yet, but that might have to do with the configuration of the service behind port 8088: The VM probably got a 'small' netmask from the virtual dhcp server, which presumably covered the IP range of all other VMs, not including the host machine. If that had happened and the service was configured like many others -to listen on all interfaces- it would not react on requests and your connection would reach a closed port, causing a 'connection refused' error. How is that?
As you know I use vagrant to manage one vm, when I login to the vm using vagrant ssh, the output shown that I was login from 10.0.2.2. So this IP was my host's IP . But why can not I see it with running ifconfig in my host? That confused me. (But I can found a record about 10.0.2.2 in the host route table)
Any clue will be appreciated!
10.0.2.2 always points to the local host when you are running emulator or vm. So in virtual machine , it refers to the local host (127.0.0.1) as 10.0.2.2. That is the reason you can't see it in ifconfig in your host.
You can find more info in this thread.