Add route from single ip to localhost. OSX Mavericks - macos

on my MacbookPro 15'' Retina, with OSX 10.9.4, I want to be able to:
route all single ip traffic to localhost.
My Goal is this:
I type http://192.168.1.54/test.html in the browser and I get what I normally get from
http://localhost/test.html
This is what I tried (en4 is the one I get internet connection from):
______$ sudo route add 192.168.1.54 localhost -ifp en4
checking the list
______$ sudo route add 192.168.1.54 localhost -ifp en4
add host 192.168.1.54: gateway localhost
______$ netstat -rn
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.168.1.1 UGSc 42 4 en4
127 127.0.0.1 UCS 0 3 lo0
127.0.0.1 127.0.0.1 UH 50 15380 lo0
...
192.168.1.54 127.0.0.1 UGHS 0 0 en4
...
But the ping of 192.168.1.54 isn't working
I tried also the loopback interface with
______$ sudo route add 192.168.1.54 localhost -ifp lo0
getting the same result: nothing.
I'm kind of a newbie in this stuff, so any help will be great

Fire up your Terminal and type the following:
sudo ifconfig lo0 alias 192.168.66.66
After entering your password, that will redirect requests for 192.168.66.66 to the localhost/loopback adapter.
And if you need to remove this redirect, try
sudo ifconfig lo0 -alias 192.168.66.66
Source: http://www.vincecutting.co.uk/web-development/redirect-ip-address-back-to-localhost-on-mac-osx/

You'll need to create a mac virtual interface pointing to 192.168.1.54. Otherwise there is no one to reach at 192.168.1.54 and hence why your ping is failing.
In linux it's pretty straight forward to create additional virtual interfaces.
On my mac osx machine I was able to go into Systems Preferences --> Network
then hit the + sign to add an additional interfaces.
I picked Ethernet as my interface type and assigned the address of 192.168.1.54, 255.255.255.0 subnet mask and 192.168.1.1 as the default router.
Now both my primary 192.168.1.10 and my virtual 192.168.1.54 interfaces are up and pingable.
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 0c:4d:e9:9a:1c:a3
inet6 fe80::e4d:e9ff:e936:1ca3%en0 prefixlen 64 scopeid 0x4
inet 192.168.1.10 netmask 0xffffff00 broadcast 192.168.1.255
inet 192.168.1.54 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=1<PERFORMNUD>
media: autoselect (100baseTX <full-duplex>)
status: active
My-Book-Pro:~ root# ping 192.168.1.10
PING 192.168.1.10 (192.168.1.10): 56 data bytes
64 bytes from 192.168.1.10: icmp_seq=0 ttl=64 time=0.095 ms
64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.101 ms
My-MacBook-Pro:~ root# ping 192.168.1.54
PING 192.168.1.54 (192.168.1.54): 56 data bytes
64 bytes from 192.168.1.54: icmp_seq=0 ttl=64 time=0.085 ms
64 bytes from 192.168.1.54: icmp_seq=1 ttl=64 time=0.091 ms

Related

how to network to and from local VM (fusion) with fixed IP on mac os host

I am running a VM (Debian) on MacOs using VMware Fusion. The VM has fixed IP address (required) and the networking is bridged. It all works very well in my local network under 192.168.1.XXX ip range. The problem is when I leave home and connect to internet via 4G or some public wifi etc. In this situation my Host OS (Mac) obviously gets a different ip address and the VM (Debian) becomes inaccessible from the host mac os. I would really like to be able to keep the VM on the fixed 192.168.1.XXX address even outside of my home network. That is to be able to connect to the guest from the host and also to connect from the guest to the outside internet (as I am able to do when on the home network). Could you please advise on ways how to achieve that. Thank you.
EDIT1:
More googling gained this link .. I followed the steps and created adapter as per the screenshot attached. I am now able to ssh to the VM from the MacOs host (progress!), however the connectivity from the Debian VM to the internet still does not work. Ping 8.8.8.8 fails. My network setup on the Debian VM is:
/etc/network/interfaces:
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.177
netmask 255.255.255.0
gateway 192.168.1.1
/etc/resolv.conf:
nameserver 192.168.1.1
nameserver 8.8.4.4
EDIT2:
netstat -nr on the host:
Destination Gateway Flags Refs Use Netif Expire
default 172.20.10.1 UGSc 141 64 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 5 420 lo0
169.254 link#10 UCS 0 0 en0 !
172.16.37/24 link#19 UC 2 0 vmnet1 !
172.16.37.255 ff:ff:ff:ff:ff:ff UHLWbI 0 9 vmnet1 !
172.20.10/28 link#10 UCS 1 0 en0 !
172.20.10.1/32 link#10 UCS 1 0 en0 !
172.20.10.1 XXXXXXXXXXXXXXXXX UHLWIir 56 440 en0 1192
172.20.10.6/32 link#10 UCS 0 0 en0 !
172.20.10.15 ff:ff:ff:ff:ff:ff UHLWbI 0 9 en0 !
192.168.1 link#20 UC 2 0 vmnet3 !
192.168.1.177 0:50:56:35:35:b UHLWIi 2 756 vmnet3 1180
192.168.1.255 ff:ff:ff:ff:ff:ff UHLWbI 0 9 vmnet3 !
192.168.114 link#21 UC 2 0 vmnet8 !
192.168.114.255 ff:ff:ff:ff:ff:ff UHLWbI 0 9 vmnet8 !
224.0.0/4 link#10 UmCS 2 0 en0 !
224.0.0.251 1:0:5e:0:0:fb UHmLWI 0 0 en0
239.255.255.250 1:0:5e:7f:ff:fa UHmLWI 0 54 en0
255.255.255.255/32 link#10 UCS 1 0 en0 !
255.255.255.255 ff:ff:ff:ff:ff:ff UHLWbI 0 128 en0 !
According to the VMware docs here, the ping from the guest to the outside should "just work" in this setup, but it does not.
Try using a host-only or NAT network setup instead of bridged. A bridged adaptor will always give your VM an IP address from whatever wireless/ethernet network your host machine resides in at a given time. Using a host-only or NAT setup should allow you to create a private network between your host and VM in which you can get a static IP for your VM. The link I posted is for VMware Workstation, but the network options should be relevant to Fusion as well.
Talking to VMware support gained a solution that is acceptable. They recommended setup with 2 adapters. This way both ssh into (via one adapter that keeps the same fixed internal IP address) and connections to the internet (second adapter with dhcp) work fine.

Why docker allow me to run container on 192.168.8.101:8082 and localhost but not on other IPs

Hello I have following dockerfile on my macOS Sierr High (as example):
FROM richarvey/nginx-php-fpm:1.3.7
EXPOSE 80
And I'm able to build and run it on 192.168.8.101:8082 by
docker build -t myproject
docker run -d -p 192.168.8.101:8082:80 --name myproject myproject
and it works on http://192.168.8.101:8082 my local computer and devices (iPhone) connected to the same wifi network (I also have no problem to run container on localhost).
However when I try tu run this container on other IP like for example 192.168.8.102:8082 I get following error:
Mac-mini-Kamil:myproject Kamil$ docker run -d -p 192.168.8.102:8082:80 --name myproject myproject
f939d38243f420f812c859f5fe275faf49dc6e123d807583ec240fbdf0619a17
docker: Error response from daemon: driver failed programming external connectivity on endpoint myproject (0b546e63887e3ddeb4d2b21a8d6d15a94e33f1ff67c2765174a808bf6b13e120): Error starting userland proxy: listen tcp 192.168.8.102:8082: bind: cannot assign requested address.
I try also other addresses like 172.17.1.2 but with no success and I don't have idea why. Do someone cane give me advice (and/or instruction about what more information I should provide to this question to solve it) ? I would like to know: why I cannot use other IPs and what I can do to use other IPs?
UPDATE - additional informations:
After execute ifconfig I selected two interesting results :
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether a8:8e:24:a3:d3:91
inet6 fe80::18fe:1146:6389:b630%en1 prefixlen 64 secured scopeid 0xa
inet 192.168.8.101 netmask 0xffffff00 broadcast 192.168.8.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 32:00:11:fc:70:40
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 9 priority 0 path cost 0
nd6 options=201<PERFORMNUD,DAD>
media: <unknown type>
status: inactive
The output of ifconfig (linux, OSX) or ipconfig (Windows) will probably tell you that your IP4 is 192.168.8.101.
That's reason why 192.168.8.101:8082:80 works. Docker can access the endpoint and can map port 80 of its container on port 8082 of 192.169.8.101.
When you use another IP this error will pop up:
Error response from daemon: driver failed programming external connectivity on endpoint
This means your Docker daemon can not access the endpoint 192.168.8.102 which is logical because it isn't the IPV4 address of your machine.
The bridge0 network is the default Docker network. If you don't specify a network your Docker container will be deployed inside this network.
You can do: docker inspect network bridge
The output of this command will return a subnet like "Subnet": "172.17.0.0/16". Every container will have an IP between this private range.
What you are actually doing is mapping 172.17.X.X:80 on 192.168.8.101:8082 which works when 192.168.8.101 is accessible from you machine.
i suspect that your previous container still using port 8082 try using another port. . i dont know how to check used port in mac but if its in linux you can check your open port with netstat -ntlp

UDP packet sent to a multicast destination is sent via the loopback interface

I'm running Windows 10.
I had recently diagnosed an issue with my computer where any packet sent to a multicast destination is sent through the loopback interface rather than the 'default' one (see my adventures here).
Example code:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(b"herpyderp", ('224.0.0.251', 5353))
The packet is seen on the loopback interface only (used Microsoft Message Analyzer to sniff).
I tried inspecting the routing table via route print, and got the following output:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.0.10.138 10.0.10.30 35
10.0.10.0 255.255.255.0 On-link 10.0.10.30 291
10.0.10.30 255.255.255.255 On-link 10.0.10.30 291
10.0.10.255 255.255.255.255 On-link 10.0.10.30 291
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 10.0.10.30 291
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 10.0.10.30 291
===========================================================================
You'll note the metric indicates the packet should be sent through my 'default' interface.
I then tried inspecting the interface metric via the PowerShell Get-NetIPInterface cmdlet (as implied here), and got the following output:
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
2 Ethernet 3 IPv6 1500 35 Enabled Connected ActiveStore
7 Ethernet IPv6 1500 5 Enabled Disconnected ActiveStore
1 Loopback Pseudo-Interface 1 IPv6 4294967295 75 Disabled Connected ActiveStore
3 isatap.home IPv6 1280 75 Disabled Disconnected ActiveStore
17 Teredo Tunneling Pseudo-Inte... IPv6 1280 75 Enabled Connected ActiveStore
2 Ethernet 3 IPv4 1500 35 Enabled Connected ActiveStore
7 Ethernet IPv4 1500 5 Enabled Disconnected ActiveStore
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore
You'll note the InterfaceMetric field also seems to indicate my packet should be sent through the 'default' interface rather than through the loopback interface.
Forcing the socket to send the packet through a different interface via s.setsockopt(socket.IP_MULTICAST_IF, ...) works, but I shouldn't need to do that.
You'll note that there are two Ethernet interfaces corresponding to two network cards on my motherboard. When I connected the cable to Ethernet instead of Ethernet 3, the code above started behaving as I expected and the packet was sent through that interface rather than through the loopback interface.
What is going on?
On my Win10 PC there is a rule in the firewall: UDP port 5353 (mDNS) is allowed to be used by svchost.exe only. This basically means only some Windows services can use mDNS. You may want to check your own firewall and modify that rule - if you have it.
I'm using C++ rather than python, but this helped:
flag = 0;
setsockopt(this->socket, IPPROTO_IP, IP_MULTICAST_LOOP, (char*) & flag,sizeof(flag))
Disableing IP_MULTICAST_LOOP helped!

Creating a virtual switch for Hyper-v stops host from receiving udp multicast

Basically my issue is that I am unable to receive multicast udp packets (streaming video) once I have created an external virtual switch via the Hyper-V manager which is required to provide the guest OS full networking.
If I use VLC and play an RTSP url on my host without a virtual switch then it plays without any issues, once I add the virtual switch I am no longer able to play the multicast RTSP url.
Back Story
I have created a couple docker services to run in an Ubuntu 16.04 VM environment on my Windows 10 Pro host via Hyper-v. My docker service needs to be able to receive multicast udp packets which I have successfully done using VirtualBox... but I want to use Hyper-v. Once I solve why my host isn't able to receive multicast then I'll move along and test to make sure my container is able to as well.
Info
When executing this show joins command while attempting to stream the multicast RTSP url then the 239.168.1.75 address on the virtual switch increases its reference count properly, then after VLC is closed, the reference count goes back down, so it looks like it's joining/leaving the group correctly.
netsh interface ip show joins
Interface 1: Loopback Pseudo-Interface 1
Scope References Last Address
---------- ---------- ---- ---------------------------------
0 0 Yes 224.0.0.251
0 4 Yes 239.255.255.250
Interface 28: vEthernet (New Virtual Switch)
Scope References Last Address
---------- ---------- ---- ---------------------------------
0 0 Yes 224.0.0.1
0 3 Yes 224.0.0.251
0 1 Yes 224.0.0.252
0 0 Yes 239.168.1.75
0 4 Yes 239.255.255.250
Interface 15: Local Area Connection* 5
Scope References Last Address
---------- ---------- ---- ---------------------------------
0 0 Yes 224.0.0.1
route print
===========================================================================
Interface List
15...00 ff 10 60 55 c4 ......Juniper Network Connect Virtual Adapter
28...9c eb e8 35 1a 1e ......Hyper-V Virtual Ethernet Adapter
1...........................Software Loopback Interface 1
===========================================================================
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.138 25
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
192.168.1.0 255.255.255.0 On-link 192.168.1.138 281
192.168.1.138 255.255.255.255 On-link 192.168.1.138 281
192.168.1.255 255.255.255.255 On-link 192.168.1.138 281
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 192.168.1.138 281
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 192.168.1.138 281
===========================================================================
Persistent Routes:
None
Igmpquery (https://code.google.com/archive/p/igmpquery)
When using this tool I am able to query the network and get responses when the virtual switch is removed, but once it's added again, it fails.
With Virtual Switch
IGMP query generator V1.4
Project web site: http://code.google.com/p/igmpquery/
Requires WinPcap
\Device\NPF_{807EAC56-4C04-424D-9DDE-4411FB900E3C}
Description: Juniper Network Connect Virtual Adapter
Address Family Name: AF_INET
Address: 0.0.0.0
Netmask: 255.0.0.0
Broadcast Address: 0.0.0.0
IGMPv2 general query 0.0.0.0 -> 224.0.0.1
listening for responses ...
\Device\NPF_{27895664-EDF7-44E0-9753-E549EDCAD6E7}
Description: Realtek USB NIC
No Virtual Switch
IGMP query generator V1.4
Project web site: http://code.google.com/p/igmpquery/
Requires WinPcap
\Device\NPF_{807EAC56-4C04-424D-9DDE-4411FB900E3C}
Description: Juniper Network Connect Virtual Adapter
Address Family Name: AF_INET
Address: 0.0.0.0
Netmask: 255.0.0.0
Broadcast Address: 0.0.0.0
IGMPv2 general query 0.0.0.0 -> 224.0.0.1
listening for responses ...
\Device\NPF_{27895664-EDF7-44E0-9753-E549EDCAD6E7}
Description: Realtek USB NIC
Address Family Name: AF_INET
Address: 192.168.1.138
Netmask: 255.255.255.0
Broadcast Address: 0.0.0.0
IGMPv2 general query 192.168.1.138 -> 224.0.0.1
listening for responses ...
15:44:06.551 192.168.1.85 -> 224.0.0.252 IGMP Rpt 224.0.0.252
15:44:06.593 192.168.1.71 -> 224.0.0.251 IGMP Rpt 224.0.0.251
15:44:06.624 192.168.1.79 -> 224.0.0.252 IGMP Rpt 224.0.0.252
15:44:06.828 192.168.1.89 ->239.255.255.250 IGMP Rpt 239.255.255.250
I'm not 100% sure what the magic bullet was although it's now working.
Remove the virtual switch
Reset network settings
netsh winsock reset
netsh int ip reset
ipconfig /release
ipconfig /renew
ipconfig /flushdns
netsh advfirewall set allprofiles state off
Reboot
Add virtual switch
Reboot
Now when running the igmp tool I was getting responses from my own PC from within the virtual switch but no other devices on my main network
Uninstalled VirtualBox
Seemingly no help
Get frustrated, go to sleep
Once I woke up the next day and ran the igmp tool I started receiving replies from devices on my main network outside the virtual switch
Tested streaming multicast and everything worked great

Oracle on mac using VirtualBox with Windows 10 not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I've been researching everywhere and couldn't solve the problem. I'm receiving the error:
"Status: Failure-Test failed: IO Error: Got minus one from a read call." when trying to connect to the Oracle server running on the VirtualBox in my Macbook.
What I did so far:
Installed Windows 10 x64 with default configuration on VirtualBox
Installed Oracle 11 XE 112 Win 64 on the Windows installed in the step #1
Installed SQL Developer 4.0.2.15 on my Macbook (OS X El Captain)
On VirtualBox, went to Network (Attached to NAT) and added port forwarding with:
host IP: 127.0.0.1
host port: 1521
guest ip: tried empty and after tried using my mac ip (192.168.2.68)
guest port: 1521
I also tried adding a Bridged second adapter. No luck.
Tested the Oracle local connection on Windows with the sql command line utility ("connect hr/hr") and could connect successfully.
Tested the Oracle listener on Windows using the lsnrctl utility ("status") and could see the "xe" listener active.
On my Mac, tried to connect using SQL Developer with every possible combination that I could imagine:
username/password: hr/hr
hostname: 127.0.0.1 / localhost / 10.0.2.15 (that's the virtual Windows ip)
service name: xe / xexdb / orcl
tried the same for SID.
Every time that I click in test, I receive the error mentioned before.
Disabled the firewall on the virtual Windows
Please, I researched everywhere here, google, oracle community, VirtualBox community and nothing. Thank you so much in advance.
ifconfig on my mac:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.94.0.2 netmask 0xff000000
inet 127.94.0.1 netmask 0xff000000
nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 54:26:96:e0:e7:57
inet6 fe80::5626:96ff:fee0:e757%en0 prefixlen 64 scopeid 0x4
inet 192.168.2.68 netmask 0xffffff00 broadcast 192.168.2.255
nd6 options=1<PERFORMNUD>
media: autoselect
status: active
en1: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:1b:a0:70:e0
media: autoselect <full-duplex>
status: inactive
en2: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:1b:a0:70:e1
media: autoselect <full-duplex>
status: inactive
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 06:26:96:e0:e7:57
media: autoselect
status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
ether 6a:0e:9b:1d:78:7b
inet6 fe80::680e:9bff:fe1d:787b%awdl0 prefixlen 64 scopeid 0x8
nd6 options=1<PERFORMNUD>
media: autoselect
status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether 56:26:96:0e:29:00
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en1 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 5 priority 0 path cost 0
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 6 priority 0 path cost 0
nd6 options=1<PERFORMNUD>
media: <unknown type>
status: inactive
vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00
inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255
ipconfig on the virtual Windows box:
Your VirtualBox port forwarding configuration is incorrect, guest IP should be 10.0.2.15, not your host IP address. After that, you should be able to connect through 127.0.0.1:1521 on your host OS.
I couldn't find a solution installing Windows 10, but it worked super fine following the instructions of this post

Resources