Simple one-to-one nat
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Age
    45
    Posts
    547
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple one-to-one nat

    ****Note the true scenario is much more complicated but if I can solve this scenario it fixes the other****

    I have 3 machines
    192.168.1.1
    192.168.1.2 (also has address 192.168.2.1)
    and
    192.168.2.3

    I want 192.168.1.2 to share 192.168.2.3 as 192.168.1.3

    I am trying to work out the iptables to do this scenario. Here is what I have so far

    on 192.168.1.2 I have the following
    Code:
    iptables -t nat -F
    iptables -t nat -X
    nat_from_to()
    {
     iptables -t nat -A OUTPUT -d $1 -j DNAT --to-destination $2
    }
    nat_from_to 192.168.1.3 192.168.2.3
    after running this I can ping 192.168.1.3 from 192.168.1.2 but not from 192.168.1.1

    I'm not sure I need a nat anything that would let me take all traffic to 192.168.1.3 and pass it to 192.168.2.3 would work
    I guess I could assign 192.168.1.3 as another address on 192.168.1.2 and do a port forward to 192.168.2.3

  2. #2
    Join Date
    Jun 2005
    Age
    45
    Posts
    547
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Simple one-to-one nat

    Got this working with
    Code:
    iptables -t nat -F
    iptables -t nat -X
    iptables -F
    iptables -X
    
    next=0
    nat_from_to()
    {
     ifconfig ens224:$next $1 netmask 255.255.255.192
     iptables -t nat -A PREROUTING -d $1 -j DNAT --to-destination $2
     iptables -t nat -A OUTPUT -d $1 -j DNAT --to-destination $2
     iptables -t nat -A POSTROUTING -s $2 -j SNAT --to-source $1
     iptables -A FORWARD -d $1 -j ACCEPT
     next=$(($next+1))
    }
    It works as I expect now to clean it up a bit.

  3. #3
    Join Date
    Jan 2010
    Posts
    7,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Simple one-to-one nat

    Thanks for sharing your solution.

Similar Threads

  1. Why are "simple" tasks not so simple?
    By daviator in forum Reviews, Rants & Things That Make You Scream
    Replies: 22
    Last Post: 4th April 2013, 01:04 AM
  2. simple help :)
    By loverdo in forum Programming & Packaging
    Replies: 3
    Last Post: 23rd January 2012, 07:09 PM
  3. Replies: 5
    Last Post: 4th October 2007, 05:24 PM
  4. Simple MB with PCI-X?
    By Dr.Diesel in forum Hardware & Laptops
    Replies: 9
    Last Post: 21st September 2006, 01:18 AM
  5. Simple C++
    By razored in forum Programming & Packaging
    Replies: 3
    Last Post: 7th May 2006, 02:23 AM

Posting Permissions

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