|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.eurotech.framework.linux.net.iptables.NATRule
public class 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) -> "sourceInterface" | "destinationInterface" PARAM (optional) -> "masquerade" VALUE -> (value of the specified parameter) EXAMPLE: NATRule0_sourceInterface=eth0 NATRule0_destinationInterface=wlan0 NATRule0_masquerade=true
Constructor Summary | |
---|---|
NATRule()
Constructor of NATRule object. |
|
NATRule(String sourceInterface,
String destinationInterface,
boolean masquerade)
Constructor of NATRule object. |
Method Summary | |
---|---|
boolean |
equals(Object o)
|
String |
getDestinationInterface()
Getter for the destinationInterface. |
String |
getSourceInterface()
Getter for the sourceInterface. |
int |
hashCode()
|
boolean |
isComplete()
Returns true if the NATRule parameters have all been set. |
boolean |
isMasquerade()
Getter for the masquerade. |
void |
setDestinationInterface(String destinationInterface)
Setter for the destinationInterface. |
void |
setMasquerade(boolean masquerade)
Setter for the masquerade. |
void |
setSourceInterface(String sourceInterface)
Setter for the sourceInterface. |
String |
toString()
Converts the NATRule to a String . |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NATRule(String sourceInterface, String destinationInterface, boolean masquerade)
NATRule
object.
sourceInterface
- interface name of source network (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 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} -j MASQUERADE;
iptables -A FORWARD -i {sourceInterface} -o {destinationInterface} -j ACCEPT;
iptables -A FORWARD -i {destinationInterface} -o {sourceInterface} -j ACCEPT
toString
in class Object
NATRule
.public void setSourceInterface(String sourceInterface)
sourceInterface
- A String representing the sourceInterface.public void setDestinationInterface(String destinationInterface)
destinationInterface
- A String representing the destinationInterface.public void setMasquerade(boolean masquerade)
masquerade
- A boolean representing the masquerade.public String getSourceInterface()
public String getDestinationInterface()
public boolean isMasquerade()
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |