Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Need help with iptables routing


    Hello guys,

    i am facing some difficulties creating some iptables rules. I would appreciate some help

    network.JPG

    So this is the diagram. I have 2 servers and one VM. On server 1 i have 2 public ips. I use the main for the server itself but the second one is free. On server 2 i have just one ip. I want the VM to have public IP so basically I want to route all traffic from 1.1.1.2 to vm machine(4.4.4.5) on server2. So for example if i open putty and give address 1.1.1.2 port 22 i am logging directly to 4.4.4.5 port 22. On the other side i want 4.4.4.5 to route to 1.1.1.2 and then to internet. The idea being VM1 to operate with 1.1.1.2 as if it is its own IP. I would appreciate some help with the iptables rules. Thanks

  2. #2
    Quote Originally Posted by me4ka86 View Post
    Hello guys,
    So this is the diagram. I have 2 servers and one VM. On server 1 i have 2 public ips. I use the main for the server itself but the second one is free. On server 2 i have just one ip. I want the VM to have public IP so basically I want to route all traffic from 1.1.1.2 to vm machine(4.4.4.5) on server2. So for example if i open putty and give address 1.1.1.2 port 22 i am logging directly to 4.4.4.5 port 22. On the other side i want 4.4.4.5 to route to 1.1.1.2 and then to internet. The idea being VM1 to operate with 1.1.1.2 as if it is its own IP. I would appreciate some help with the iptables rules. Thanks
    Hey
    Try this way:
    Code:
    iptables -I forward -s 1.1.1.2 -a dstnat 4.4.4.5
    It should create a full-cone NAT rule which will redirect all incoming traffic to the VM 4.4.4.5

    Few notes:
    1. The server1 should be able to access your VM 4.4.4.5
    2. Same applies for the your VM 4.4.4.5

    Take a look here for more examples of using iptables, it can help you too.

  3. #3
    Just Joined!
    Join Date
    Jul 2016
    Location
    Greater Charlotte NC Metro Area
    Posts
    23
    -->
    LNXFRMscenario.PNGI was given the impression by your diagram that you are dealing with 2 srvrs the first had a free public ip that you want to 1:1 nat across to the vm on the second server. All the while server a and b are only reachable via their public ip's? Am I mistaken? Is this what you describe here in the attached graphic?
    Last edited by calbo79; 07-25-2016 at 01:22 PM.

$spacer_open
$spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •