Home linux port forward and traffic redirection via iptables

port forward and traffic redirection via iptables




There is a router , the Internet comes to it.

On the router, the 6666 port is tried on the server with ubuntu ( , the eth0 interface). There is also a second interface ETH1 , which is connected to the server (IP server address in this network , the main gateway is 10/10/10.1 ). Through this locator, a computer is available in the 3rd network .

Task: Configure IPTables Ubuntu so that users via the Internet by port 6666 could reach .
Forwarding included.

I can’t understand how to properly register the following logic (if it is generally correct):

  1. Redirect packages from one Eth0 on another eth1 if they answer .
  2. Redirect packets with ETH1 on the IP address available through this locomotive .

Answer 1, Authority 100%

(on the ubuntu server) specify the route to :

ip Route Add Via 10/10/10.1

Change the destination in the packages on :

iptables --table nat --insert prerouting \
  --Proto TCP --DPORT 6666 --JUMP DNAT --TO-Destination
IPTABLES --Table Nat --insert Prerouting \
  --Proto UDP --Dport 6666 --Jump Dnat --to-Destination

If the router> does not have masquerade, then:

iptables --table nat --insert postruting --jump Masquerade

must, in theory, earn.

Previous articleNUMPY and PYTHON
Next articlewhere to store music?

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions