Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On OS X 10.6 you do not have iptables, so what is the full solution for this permanently redirect all request sent to port 80 to another port, like 8080?

It has to be persistent.

share|improve this question
    
I wanted to suggest rinetd because it is so simple I thought it would compile anywhere, but there does not seem to be a port to OS X, unfortunately... –  Nicolas Raoul Sep 22 '10 at 11:55
    
I can't post this as an answer because this question is protected, but I've had great success using the built in Apache server to redirect to another port. Add the following to the end of /etc/apache2/httpd.conf: <Location />\nProxyPass http://localhost:8080/\n</Location> (where \n is a newline), and then enable "Internet Sharing" in System Preferences. –  Tobias Jul 3 '12 at 1:44
add comment

2 Answers

up vote 10 down vote accepted

Use ipfw as in @bindbn's answer. That's the general idea.

Persistence:

put your rules into a file :

/etc/ipfw.conf

add at the very top of your file

flush

Ensure that there are not leading or trailing whitespaces in any line.

add to /Library/LaunchDaemons/com.yourdomain.ipfw.plist :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.yourdomain.ipfw</string>
    <key>Program</key>
    <string>/sbin/ipfw</string>
    <key>ProgramArguments</key>
    <array>
      <string>/sbin/ipfw</string>
      <string>-q</string>
      <string>/etc/ipfw.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

Either reboot, or

launchctl load -w /Library/LaunchDaemons/com.yourdomain.ipfw.plist

the first time.

After that it is

launchctl load com.yourdomain.ipfw
share|improve this answer
1  
Chinggsy, I tried your method and everything runs but once it does I get an error in the console. 3/30/11 4:07:01 PM com.apple.ipfw[342] Line 1: socket: Operation not permitted The permissions on both files are set to root as the owner and the issue persists. What am I missing? peace –  concertman Mar 30 '11 at 21:15
    
This article fixed that for me: apple.stackexchange.com/questions/3250/… –  Mattijs Jul 31 '13 at 10:55
1  
Actually, this answer didn't work for some reason. This article did however: blog.scottlowe.org/2012/04/05/setting-up-ipfw-on-mac-os-x –  Mattijs Jul 31 '13 at 11:22
add comment

Use ipfw(read http://discussions.info.apple.com/message.jspa?messageID=10945451 http://discussions.apple.com/thread.jspa?messageID=10996939�)

ipfw add NUMBER fwd 127.0.0.1,8080 tcp from any to me 80

or http://www.hanynet.com/waterroof/

share|improve this answer
    
Thank but is missing something, this change is not persistent. –  sorin Sep 22 '10 at 14:29
    
okay ,... place your plist in Launch agents not launch Daemon. amazing it worked for me. –  user105558 Dec 31 '11 at 1:23
1  
'NUMBER' is some sort of position in ipfw and should be replaced with an actual number –  Drew Feb 16 '12 at 17:10
add comment

protected by Mark Henderson Dec 31 '11 at 1:25

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.