How to setup EC2 internal IP forwarding to External DNS using macos X? - macos

Here the problem, I have two servers on EC2, which have internal/private IPs (10.148.73.230, 10.148.73.231), unfortunately I do not have Elastic IPs available and connect to these servers using External DNS like: ec2-50-132-69-161.us-west-2.compute.amazonaws.com (IP:50.132.69.161) and ec2-50-132-69-162.us-west-2.compute.amazonaws.com (IP:50.132.69.162).
I have macbook and now I need to simulate access to these EC2 servers using their internal IPs.
The first idea was to setup IP forwarding on mac using: ipfw and natd... but after several hours it still not working for some reason. Im fine to make quick and dirty, or using any GUI, but didn't find any...
Desperate for help, here my current script:
sysctl -w net.inet.ip.forwarding=1
ipfw add 1000 forward 10.148.73.230,80 log ip from me 80 to 50.132.69.162) dst-port 80
/usr/sbin/natd -alias_address 10.148.73.230 -interface en1 -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss -enable_natportmap -natportmap_interface en0 -redirect_port tcp 50.132.69.162:1-10000 1-10000 -l
Or is there any better solution to make the forwarding?

Just taking a shot in the dark here as as windows/linux guy. I do understand your problem with EC2 and use it myself, generally with elastic ip's however.
Is it possible to just setup the hosts file like you could on windows/linux??
http://support.apple.com/kb/TA27291?viewlocale=en_US

Related

No access to web or mysql on vagrant after upgrading to macos monterey

Last week I decided to upgrade the mac to the latest version Monterey. Well. Most things works, except for Vagrant. Well.. it works, except there is almost no connection to the server.
vagrant ssh works.
I have been able to launch virtualbox, but access to http or mysql is not happening.
I know the mysql-server is running. The same goes with the apache server.
Logs have been checked and I cannot see that any traffic going to the server.
Ping is not working.
I have updated virtualbox. I have destroyed the box and upgraded vagrant / homestead. still no luck.
MORE INFO:
When I run traceroute I see that the first hit is the correct IP I have set in hosts file. Then it goes to 192.168.0.1 which isn't going anywhere.
I guess the 192.168.0.1 comes from the mac virtualbox / vagrant is running on.
Any pointers on what to do next are welcome.
Probably the same problem as mine (I couldn't use any longer IP 192.168.10.10). VirtualBox did some changes lately (from VirtualBox 6.1.28 I think) and a new configuration is needed to use your preferred (192.168.0.1) IP address:
On Linux, macOS and Solaris Oracle VM VirtualBox will only allow IP
addresses in 192.168.56.0/21 range to be assigned to host-only
adapters. For IPv6 only link-local addresses are allowed. If other
ranges are desired, they can be enabled by creating
/etc/vbox/networks.conf and specifying allowed ranges there. For
example, to allow 10.0.0.0/8 and 192.168.0.0/16 IPv4 ranges as well as
2001::/64 range put the following lines into /etc/vbox/networks.conf:
* 10.0.0.0/8 192.168.0.0/16
* 2001::/64
You can check the whole information here.
Alternatively (skipping the networks.conf configuration) you can use any IP from the initially supported range like for instance: 192.168.56.10

Web App on LAN VM: curl -L works from other vms, browser/curl on host doesn't

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?

Mac OS X 10.10.1 AMP stack offline use

before the update to Yosemite (on Mavericks) i was able to access my locally hosted sites via apache even when the wifi was completely turned off. i set up my AMP stack according to this tutorial: http://wizardmode.com/2012/06/apache-php-mysql-dev-on-os-x-lion-with-a-minimum-of-pain/
FROM THE TUTORIAL
One more thing. OS X will refuse to do DNS lookups if you’re not connected to a network (under some circumstances). There’s a simple way around that, in two steps:
First, install VirtualBox. Create a new virtual machine, and give it a Host-only network adapter. (You can use the FreeDos image, if you don’t actually need a virtual machine for anything. It’s small.) Start the virtual machine at least once.
You can do this from the commandline with this snippet (after VirtualBox is installed):
(ifconfig | grep -s vboxnet) || VBoxManage hostonlyif create ipconfig vboxnet0 --ip 192.168.56.1 --netmask 255.255.255.0
This prevents OS X from disabling normal DNS resolution when you’re not connected to a network.
Second, create a ‘dev’ domain resolver entry:
sudo mkdir -p /etc/resolver
sudo tee /etc/resolver/dev <<EOT
nameserver 127.0.0.1
domain dev
search_order 1
EOT
This tells OS X that it can always ask localhost (your dnsmasq server) for domain resolution for .dev domains when it doesn’t have other DNS servers.
Now if you type ifconfig in a terminal, one of the lines should start with vboxnet0: – if it does, great! OS X will happily do DNS lookups even if you’re on an airplane, so you can keep using your .dev domains wherever you are.
END TUTORIAL SECTION
after the update i went through hell to get all my local sites running and now they only work if i have an internet connection
I am running dnsmasq according to the tutorial and I did the whole VirtualBox trick. here is the relevant output of ifconfig:
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00
inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255
vboxnet1: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:01
I'm not really sure what's going wrong. Here is a screenshot of my wifi network settings:
you can see the opendns servers and then localhost for dns resolution purposes.
furthermore, here is scutil --dns output:
DNS configuration
resolver #1
nameserver[0] : 208.67.222.222
nameserver[1] : 208.67.220.220
nameserver[2] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : Reachable
resolver #2
domain : dev
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : Reachable,Local Address
order : 1
DNS configuration (for scoped queries)
resolver #1
nameserver[0] : 208.67.222.222
nameserver[1] : 208.67.220.220
nameserver[2] : 127.0.0.1
if_index : 4 (en0)
flags : Scoped, Request A records, Request AAAA records
reach : Reachable
I'm really at a loss here for what's happening and going wrong. I've tried debugging some of the shell scripts from the tutorial to see if they are causing problems but I can't figure it out. This should be simple as pie IMO. Why is this such a nightmare?
Any help would be greatly, greatly appreciated as I'm wasting valuable time that could be used for building useful things on this mess. THANK YOU!!!!
As of 10.10 and discoveryd no DNS resolution can take place when you are disconnected from all networks.
you can confirm this by running scutil --dns once when connected, and again when disconnected.
Here is a video that shows the difference in behavior between 10.9 and 10.10 https://www.youtube.com/watch?v=3m9OI_AjCx8
I've tried to escalate this with Apple, the response was that it's expected behavior.
The only workaround I know of is to re-add mDNSResponder as per http://arstechnica.com/apple/2015/01/why-dns-in-os-x-10-10-is-broken-and-what-you-can-do-to-fix-it/

Using gitlab-vagrant-vm from OSX host

I followed the instructions here and was able to succesfully (I think) install the gitlab vagrant virtual machine on OSX 10.8 using virtualbox.
I can do vagrant up to get the VM running, and everything seems to work fine. After that I can do vagrant ssh without a problem. Also, after sshing into the VM I was able to do bundle exec rake gitlab:test, which completed with results being 1584 examples, 0 failures.
I would like to see the gitlab web interface from my OSX host machine. I thought I could just direct my browser to the IP indicated in the VagrantFile (http://192.168.3.14), but that didn't work.
Any ideas?
Also any other usage tips for this setup would be appriciated (things like where the repositories are stored on my host machine so I can back them up, if anyone set the gitlab-vagrant-vm up for external access from either another computer on the network or a remote source, ect.)
You have to connect a second interface for vagrant. To do this you've to edit the VagrantFile.
For example if you want to conenct to the host wifi add the following line after 192.168.3.14
config.vm.network :bridged, bridge: "en0: Wi-Fi (AirPort)"
You also can bridge to the ethernet interface. Use ifconfig on the host machine to determine the right interface. After that the dyndns-server of the host network will assign an IP to the Vagrant-Box. Then you can access GitLab on that IP.
Did you actually start the server? You can do that with
bundle exec foreman start -p 3000
This will start the server on port 3000, you would then access it from the host with
http://192.168.3.14:3000/
Hope this helps,
Chris

Using dnsmasq on a Windows VM in VirtualBox on a Mac (+ MAMP)

I'm using dnsmasq on the Mac (OS X 10.7) to facilitate local development (along with MAMP), with just this pretty simple config:
[dnsmasq.conf]
address=/dev/127.0.0.1
.. pretty darn simple. All my *.dev domains resolve to 127.0.0.1 (localhost). Together with:
[DNS Servers]
127.0.0.1
8.8.8.8
8.8.8.4
..as my Mac's DNS settings, this works a treat.
But then I also have a pretty stock Windows 7 SP 1 VM running in VirtualBox (latest). It uses 10.0.2.* as its IP subnet within Windows. At the moment I have to use a service like http://xip.io + another hostname alias to use my *.dev sites in Windows, e.g:
[ if Mac's local IP is 192.168.1.50 ]
something.dev.192.168.1.50.xip.io
..and I need to have this extra ServerAlias manually set up in my Apache config, and keep it updated each time my local IP address changes.
Is there any way I can set up either dnsmasq, VirtualBox, or my Windows IP settings (or a combination of these) so that I can use my .dev hostnames (e.g. http://something.dev/) directly from Windows?
Try this:
https://github.com/stackia/DNSAgent
It has functions similar to Dnsmasq server= and address=
and a rule converter: https://stackia.github.io/masq2agent/
If you mean that you want to run something like dnsmasq on your windows vm then I share your pain. I have been trying to get something setup on a windows host to do wildcard localhost sites without doing something like xip.io but I am having problems getting it to work. Dnsmasq on the osx machine I have was a breeze, but trying to get Acrylic DNS to work on windows the same way hasn't worked. I do have it running as a local caching DNS, and it should be doing the wildcard part, but having problems getting over the final steps.
Check it out. Looks neat, free, and a dnsmasq alternative on windows. And if you get it working post your results! I'll do the same if I can get it going.

Resources