Applying more than NAT on one node

39 views
Skip to first unread message

tuba.ce...@gmail.com

unread,
Nov 8, 2016, 11:22:09 AM11/8/16
to ns-3-users
Hi All,
 I have a scenario where I have to apply more than one NAT(Do not ask. A part of my playing around :D).
I am using static NAT like below
Ptr<Ipv4Nat> nat = natHelper.Install (pgw1);
        nat->SetInside (1);
        nat->SetOutside (2);
        Ipv4StaticNatRule rule0 (Ipv4Address ("7.0.0.3"), 49153, Ipv4Address ("1.0.0.1"), 3005, 0);
        nat->AddStaticRule (rule0);


I am using this is a loop. After completion of this one iteration, I need to reset or delete  whatever I did in above part. This is needed to make sure that in the next iteration, another NAT is applied on the same node. The reason I am trying this way is it does not allow more than one NAT on one particular node

Cheers!

Tommaso Pecorella

unread,
Nov 8, 2016, 5:24:56 PM11/8/16
to ns-3-users
Hi,

we don't have your code, we don't have the module you're using, and honestly i can't understand the question (if there's a question).
Mind reading the posting guidelines ?

Thanks,

T.

tuba.ce...@gmail.com

unread,
Nov 10, 2016, 11:26:32 AM11/10/16
to ns-3-users
Sorry Tommasso about the less details about the questions


Topology:
   RH---------------Node1-----------------------{ Network1}
                               |
                               |
                               |
                    {Network2}

I need to apply NAT on Node1, for IPs coming from Network1. This is followed by applying a NAT on Node1 again, but for IPs comings from Network2 this time. I can apply NAT on Node1 either for Network1 or Network2. Not both at same time. If I try to apply to both Network on same Node1, I get below error
"Object::AggregateObject(): Multiple aggregation of objects of type ns3::Ipv4Nat".
The error happens as NAT is applied on same node 2 times.


Below is the code for NAT on Node1 from Network1
Ptr<Ipv4Nat> nat = natHelper.Install (Node1);

        nat->SetInside (1);
        nat->SetOutside (2);
        Ipv4StaticNatRule rule0 (Ipv4Address ("7.0.0.3"), 49153, Ipv4Address ("1.0.0.1"), 3005, 0);
        nat->AddStaticRule (rule0);

For Network2
Below is the code for NAT on Node1 from Network2
Ptr<Ipv4Nat> nat1 = natHelper.Install (Node1);
        nat1->SetInside (1);
        nat1->SetOutside (2);
        Ipv4StaticNatRule rule1 (Ipv4Address ("8.0.0.3"), 49153, Ipv4Address ("1.0.0.1"), 3006, 0);
        nat->AddStaticRule (rule1);


My question: Is there any way to reset or delete, the operation performed on Node1 for Network1, before I do it for network2.? I mean remove Nat, so that Nat1 will be the only on Node1 with NAT while applying.

Cheers,
T

tuba.ce...@gmail.com

unread,
Nov 10, 2016, 2:11:18 PM11/10/16
to ns-3-users
I understand that the  object(NAT object) can be aggregated  to Node1 only once . I am just wondering if there is any way of reversing the aggregation?

Craig Dowell

unread,
Nov 10, 2016, 2:59:00 PM11/10/16
to ns-3-...@googlegroups.com
Use two nodes each with one NAT (seems to be closer to what would really happen with multiple NAT) or aggregate an object to one node that forwards to multiple NAT objects?

On Nov 10, 2016, at 11:11 AM, tuba.ce...@gmail.com wrote:

I understand that the  object(NAT object) can be aggregated  to Node1 only once . I am just wondering if there is any way of reversing the aggregation?

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Konstantinos

unread,
Nov 11, 2016, 4:26:39 AM11/11/16
to ns-3-users
Hi Tuba,

I haven't used NAT and I do not have access to that code to verify it either.
However, your approach looks a bit bizzar to me. 

Wouldn't it be easier to simple add another rule to your NAT? 
There should be only one instance of the NAT. 
If there is no RemoveStaticRule available, then you can create it. Perhaps the developer did not foreseen such process.

Regards
K.

tuba.ce...@gmail.com

unread,
Nov 11, 2016, 9:01:24 AM11/11/16
to ns-3-users
Hello Konstantios,
      It works fine with RemoveStaticRule. Adding a new rule did not serve my purpose, as static NAT takes the last added rule(ie rule with 0 index)
Thanks a lot.
Reply all
Reply to author
Forward
0 new messages