public class NATRule
extends java.lang.Object
Constructor and Description |
---|
NATRule()
Constructor of
NATRule object. |
NATRule(java.lang.String natSourceNetwork,
java.lang.String sourceInterface,
java.lang.String destinationInterface,
boolean masquerade)
Constructor of
NATRule object. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDestinationInterface()
Getter for the destinationInterface.
|
boolean |
getMasquerade()
Getter for the masquerade.
|
java.lang.String |
getNatSourceNetwork()
Getter for the natSourceNetwork.
|
java.lang.String |
getSourceInterface()
Getter for the sourceInterface.
|
boolean |
isComplete()
Returns true if the
NATRule parameters have all been set. |
void |
setDestinationInterface(java.lang.String destinationInterface)
Setter for the destinationInterface.
|
void |
setMasquerade(boolean masquerade)
Setter for the masquerade.
|
void |
setNatSourceNetwork(java.lang.String natSourceNetwork)
Setter for the natSourceNetwork.
|
void |
setSourceInterface(java.lang.String sourceInterface)
Setter for the sourceInterface.
|
java.lang.String |
toString()
Converts the
NATRule to a String . |
public NATRule(java.lang.String natSourceNetwork, java.lang.String sourceInterface, java.lang.String destinationInterface, boolean masquerade)
NATRule
object.natSourceNetwork
- source network or ip address from which NAT is allowed (such as 192.168.1.0)sourceInterface
- interface name of sourceNetwork (such as eth0)destinationInterface
- interface name of destination network to be reached via NAT (such as ppp0)masquerade
- add masquerade entrypublic NATRule()
NATRule
object.public boolean isComplete()
NATRule
parameters have all been set. Returns false otherwise.public java.lang.String toString()
NATRule
to a String
.
Returns single iptables string based on the NATRule
, which establishes the MASQUERADE and FORWARD rules:
iptables -t nat -A POSTROUTING -o {destinationInterface} -s {natSourceNetwork} -j MASQUERADE;
iptables -A FORWARD -i {sourceInterface} -o {destinationInterface} -j ACCEPT;
iptables -A FORWARD -i {destinationInterface} -o {sourceInterface} -j ACCEPT
toString
in class java.lang.Object
NATRule
.public void setNatSourceNetwork(java.lang.String natSourceNetwork)
natSourceNetwork
- A String representing the natSourceNetwork.public void setSourceInterface(java.lang.String sourceInterface)
sourceInterface
- A String representing the sourceInterface.public void setDestinationInterface(java.lang.String destinationInterface)
destinationInterface
- A String representing the destinationInterface.public void setMasquerade(boolean masquerade)
masquerade
- A boolean representing the masquerade.public java.lang.String getNatSourceNetwork()
public java.lang.String getSourceInterface()
public java.lang.String getDestinationInterface()
public boolean getMasquerade()
Copyright © 2009 Eurotech Inc. All rights reserved.