0

I'm using iptables on my router to redirect all web traffic to my page.

But i don't know how to except my mac address list.

I did command like this:

iptables -t nat -A PREROUTING -m mac ! --mac-source xx-xx-xx-xx-xx-xx -p tcp --dport 80  -j DNAT --to 127.0.0.1:8080 (Host A)
iptables -t nat -A PREROUTING -m mac ! --mac-source xx-xx-xx-xx-xx-xx -p tcp --dport 80  -j DNAT --to 127.0.0.1:8080 (Host B)

But it just execute command for host A. It means Host A can access web normally but Host B still got redirect.

How can i got access normally for both mac address?

1 Answer 1

0

Use this:

iptables -t nat -A PREROUTING -m mac --mac-source xx-xx-xx-xx-xx-xx -j ACCEPT (Host A)
iptables -t nat -A PREROUTING -m mac --mac-source xx-xx-xx-xx-xx-xx -j ACCEPT (Host B)
iptables -t nat -A PREROUTING -p tcp --dport 80  -j DNAT --to 127.0.0.1:8080

The first two commands ACCEPT packets from A and B, so redirection only happen if the packet is from another host.

7
  • With your order all work perfectly. But what if i want add more mac address after the third commands? Thank you so much for your answer! Commented Feb 18, 2015 at 10:06
  • @TrầnMinhPhương You can insert a command in the middle with "iptables -I". Commented Feb 18, 2015 at 10:09
  • Sorry i don't understand. What is your mean? Commented Feb 18, 2015 at 10:12
  • @TrầnMinhPhương I assume you were asking how to add more addresses after executing my commands. Or were you asking what would the commands be if you want more addresses? Commented Feb 18, 2015 at 10:15
  • Yes, after execute your third command, all traffic will redirect. I want add more mac address like this: <pre>iptables -t nat -A PREROUTING -m mac --mac-source xx-xx-xx-xx-xx-xx -j ACCEPT</pre> after execute your third command. Commented Feb 18, 2015 at 10:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .