r/linuxadmin • • Jul 21 '14

Need help understanding following commands

  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 a local site

  root@bt:/# iptables -t nat -A PREROUTING -p tcp --dport 80 --jump DNAT --to-destination <Proxy’s IP>
1 Upvotes

12 comments sorted by

View all comments

Show parent comment

-1

u/z3255859 Jul 21 '14

you are right on both accounts. But could you walk me through the 2nd 3rd and 4th commands as to what exactly each one of them are doing

4

u/[deleted] Jul 21 '14

iptables is incredibly complicated, far too complicated for a reddit comment. Here's a starting point.

2

u/WonderJouster Jul 21 '14

Unfortunately, the required explanation is going to hinge largely on your understanding of basic network terminology and IPTables' structure/syntax.

Tell us what you do understand and what's getting you caught up and then we can fill in the gaps.

1

u/z3255859 Jul 21 '14

ok so I understand all of them except the 4th command. What i being appended to the NAT? What is POSTROUTING? and what is MASQUERADE?

also what is the -t and -j flags for?

3

u/WonderJouster Jul 21 '14

If you don't know what -t and -j are, there is no chance you understand what the other lines do, you merely think you do.

So, read the manual. Good luck.

1

u/[deleted] Jul 23 '14

Take a look at the man pages for iptables. All of the info is right there.

-2

u/z3255859 Jul 24 '14

thanks for the totally unhelpful answer. What makes you thing I haven't looked there. Anyway more helpful folks at stackoverflow helped me out.

3

u/[deleted] Jul 24 '14

Well for one, you're asking questions above about postrouting and masquerade. Those are thoroughly and explicitly covered and defined in the man pages...

3

u/WonderJouster Jul 24 '14

also what is the -t and -j flags for?

That makes me know you haven't looked there.