Showing posts with label ethernet. Show all posts
Showing posts with label ethernet. Show all posts

OSX Wi-fi and Ethernet network simultaneously connected and static routing

So recently I had a situation where I had my Ethernet and Wifi connected to 2 different networks in my MAC OS X, and I had a very specific use case for this

I needed to use the Ethernet connection to access 1 specific host (an internal web service), the connection through the ethernet cable allowed this but did not allow internet access, the Wifi connection allowed internet access but will not allow access to the internal web service, so basically what I needed was :

  • Have both connections active
  • Access the internal web service through the Ethernet connection
  • Access all the other hosts through the Wi-fi connection

Just connecting both interfaces does not work I was either getting access to the internet or either access to the internal WebService; if you check this article over at apple OS X network interfaces priority you can see that you can change the priority used by the system to route the requests; so if you change the priority of the Wi-fi to be on top you get internet access but not access to the internal network, and vice-versa

Sure you can make it work this way but it's really painful to have to manually change the interfaces priority to accommodate what you are trying to do at that moment

The solution that I found is to add a static route to that host; this can be easily done in a few steps (you will need for this the IP of the internal host you are trying to access)

  1. Give your Wi-fi interface the highest priority (put it on top), for this you can refer to the apple link cited above
  2. Identify the interface names, for that execute the following command on the terminal netstat -nr (in my case en0 is the ethernet interface whereas the Wi-fi is the en1)
Add a static route for the specific host (10.120.136.57) telling it to use the gateway of the Ethernet interface by running the following command in the terminal
sudo route add -host 10.120.136.57 10.247.131.1

And that should be it, please note that restarting the PC will probably remove the static route from the routing table so you will have to re-add it

OS X ethernet self-assigned ip

Recently I had a problem with my mac, my wifi connection was working properly but my ethernet connection was not it was getting a self-assigned IP. After checking the obvious culprits (cable, router, switch) it turns out that the problem was elsewhere.

After searching the internet I realized that I wasn't the only one having this problem, and there are a lot of fixes such as :

  • Deleting the "/Machintosh HD/Library/Preferences/com.apple.alf.plist" and rebooting
  • Resetting the PRAM
  • Recreating a network configuration

By chance I decided to try and disable IPv6 on the network interfaces like so :

networksetup -setv6off Wi-Fi
networksetup -setv6off Ethernet

And after rebooting it worked !!

So there you go; I hope this works for you too!!

On a final note: Another thing I was about to try was uninstalling the virtual interfaces of my VMWARE but it didn't get to that

OSX show used ports or listening applications with their PID

On OSX you can display applications listening on a given port using the lsof the commands described below will show listening application...