Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add route from single ip to localhost. OSX Mavericks

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

like image 527
maxgallo Avatar asked Sep 14 '25 09:09

maxgallo


1 Answers

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/

like image 142
Jonyx4 Avatar answered Sep 16 '25 16:09

Jonyx4