Need help converting some linux commands to OSX

0

I want to convert some linux commands into OSX. (Mavericks 10.9.4)

root@bt:/# /etc/init.d/apache2 start (will "sudo apachectl start" do the same?)
root@bt:/# echo “some Site Goes Here!” > /var/www/index.html

Now I have a site that I host on my macbook local host (8080). So would echo localhost:8080 > /var/www/index.html do the same as above in OSX ?


Next set of cammands I have no idea how to replace in OSX. Please help

root@bt:/# iptables -t nat --flush
root@bt:/# iptables --zero
root@bt:/# iptables -A FORWARD --in-interface eth0 -j ACCEPT
root@bt:/# iptables -t nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
# Forward to our site
root@bt:/# iptables -t nat -A PREROUTING -p tcp --dport 80 --jump DNAT --to-destination <Proxy’s IP>

sukhvir

Posted 2014-07-21T00:02:37.070

Reputation: 113

Answers

2

Apache

Service

Manual start/stop: sudo apachectl start and sudo apachectl stop

System autostart: sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Root directory

The default directory used by Apache is set to /Library/WebServer/Documents

So you can run echo "some Site Goes Here!" > /Library/WebServer/Documents/index.html

I would recommend you to change the default settings to suit your needs, the default config is in /etc/apache2/httpd.conf.

Firewall

You want to force NAT and redirection of port TCP/80. Mavericks use Packet Filter (PF) firewall from OpenBSD, ported from FreeBSD.

echo "nat from !(en0) -> en0 rdr on en0 from !(en0) inet proto tcp to port 80 -> PROXY-IP" | pfctl -f -

Disable NAT e redirections: pfctl -F nat

denisvm

Posted 2014-07-21T00:02:37.070

Reputation: 604

thanks a lot for clearing up the Apache stuff. I am still a bit confused with the iptable stuff. Would you mind walking me though the commands i posted in the question and tell me exactly what they are doing? And what is your command doing ? – sukhvir – 2014-07-21T01:08:26.947

The command that I've stated simply redirects all HTTP connections to localhost, nothing else, but I don't know if that's exactly what are you looking for. If possible, describe what you need with those iptables commands. – denisvm – 2014-07-21T01:13:06.383

ok so I am following this tutorial here http://www.arppoisoning.com/demonstrating-an-arp-poisoning-attack/ . I have managed to get everything working uptill step 5 in that tutorial.

PS - how do i reverse your redirection command later on ?

– sukhvir – 2014-07-21T01:16:51.550

I see, in this case you will really need the redirection. I'll update it there. – denisvm – 2014-07-21T01:26:53.960

would this redirection be different from the one you posted? – sukhvir – 2014-07-21T01:28:21.293

1Just updated the firewall rules. – denisvm – 2014-07-21T01:32:24.987

You are a legend dude. Just a few follow up questions: 1> should i disable the NAT redirections first and then run the firewall commands? 2> should the PROXY-IP in the second command be replaced with 192.168.0.18:8080 (ip of my macbook hosting the site) ? – sukhvir – 2014-07-21T01:37:34.653

If it's running in the same box you can change "PROXY-IP" to "127.0.0.1 port 8080", if another box, "192.168.0.18 port 8080". The command "-F nat" will flush all NAT and redirections rules. There are few apps to manage Mavericks native firewall: IceFloor and Little Snitch. You can get more info on http://www.hanynet.com/icefloor/ http://blog.scottlowe.org/2013/05/15/using-pf-on-os-x-mountain-lion/

– denisvm – 2014-07-21T01:46:37.957

could you please check the quotation marks in thr Firewall part of your answer. Seems like you are missing some. Also echo "nat from !(en1) -> en1 gives me the error : -bash: !: event not found – sukhvir – 2014-07-21T04:02:17.267

1Change the double quotes to single quotes or escape exclamation sign with backslash (\!) – denisvm – 2014-07-21T04:08:25.137