Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm working on a mac with OS 10.13.6.
I want to redirect all requests to 10.20.154.24:1111 made from my computer go to localhost:8080.
I read about pf and pfctl, but could not make this work.
I thought to run this, but it didn't work...
echo "
rdr pass inet proto tcp from 127.0.0.1 to 10.20.154.24 port 1111 -> 127.0.0.1 port 8080
" | sudo pfctl -ef -
Found a solution. I had to make an alias out of the IP before setting the redirecting command
sudo ifconfig lo0 10.20.154.24 alias
Edit the hosts file using the command sudo nano /etc/hosts
. You will need to enter your password.
Add you IP address that you want to redirect (10.20.154.24:1111) to the end of the line that starts with 127.0.0.1
(it should be the first line that isn’t commented out with a #). Anything added to that line will redirect to localhost. Make sure that every entry on that line is separated by a space.
To exit, save it with crtl+o and then exit the editor with crtl+x.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.