|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.esf.net.firewall.service.NATRule
Creates an iptables command for a NAT Rule. CONFIGURATION Configuration will be accepted in the form of key/value pairs. The key/value pairs are strictly defined here: CONFIG_ENTRY -> KEY + "=" + VALUE KEY -> TYPE + INDEX + "_" + PARAM TYPE -> "NATRule" INDEX -> "0" | "1" | "2" | ... | "N" PARAM (required) -> "natSourceNetwork" | "sourceInterface" | "destinationInterface" PARAM (optional) -> "masquerade" VALUE -> (value of the specified parameter) EXAMPLE: NATRule0_natSourceNetwork=192.168.1.1 NATRule0_sourceInterface=eth0 NATRule0_destinationInterface=wlan0 NATRule0_masquerade=true
Constructor Summary | |
NATRule()
Constructor of NATRule object. |
|
NATRule(java.lang.String natSourceNetwork,
java.lang.String sourceInterface,
java.lang.String destinationInterface,
boolean masquerade)
Constructor of NATRule object. |
Method Summary | |
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 .
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
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.
Method Detail |
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
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()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |