|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.esf.net.firewall.service.PortForwardRule
public class PortForwardRule
Creates an iptables command for a Port Forward Rule, allowing an incoming port to be forwarded to destinationIP/port. 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 -> "LocalRule" INDEX -> "0" | "1" | "2" | ... | "N" PARAM (required) -> "address" | "iface" | "protocol" | "inPort" | "outPort" PARAM (optional) -> "permittedNetwork" | "permittedMAC" | "sourcePortRange" VALUE -> (value of the specified parameter) EXAMPLE: PortForwardRule0_address=192.168.1.1 PortForwardRule0_iface=eth0 PortForwardRule0_protocol=tcp PortForwardRule0_inPort=1234 PortForwardRule0_outPort=1234 PortForwardRule0_permittedNetwork=192.168.1.1 PortForwardRule0_permittedMAC=AA:BB:CC:DD:EE:FF PortForwardRule0_sourcePortRange=3333:4444
Constructor Summary | |
---|---|
PortForwardRule()
Constructor of PortForwardRule object. |
|
PortForwardRule(java.lang.String iface,
java.lang.String address,
java.lang.String protocol,
int inPort,
int outPort,
java.lang.String permittedNetwork,
int permittedNetworkMask,
java.lang.String permittedMAC,
java.lang.String sourcePortRange)
Constructor of PortForwardRule object. |
Method Summary | |
---|---|
java.lang.String |
getAddress()
Getter for address |
java.lang.String |
getIface()
Getter for iface |
int |
getInPort()
Getter for inPort |
int |
getOutPort()
Getter for outPort |
java.lang.String |
getPermittedMAC()
Getter for permittedMAC |
java.lang.String |
getPermittedNetwork()
Getter for permittedNetwork |
int |
getPermittedNetworkMask()
Getter for permittedNetworkMask |
java.lang.String |
getProtocol()
Getter for protocol |
java.lang.String |
getSourcePortRange()
Getter for sourcePortRange |
boolean |
isComplete()
Returns true if the required LocalRule parameters have all been set. |
void |
setAddress(java.lang.String address)
Setter for address |
void |
setIface(java.lang.String iface)
Setter for iface |
void |
setInPort(int inPort)
Setter for inPort |
void |
setOutPort(int outPort)
Setter for outPort |
void |
setPermittedMAC(java.lang.String permittedMAC)
Setter for permittedMAC |
void |
setPermittedNetwork(java.lang.String permittedNetwork)
Setter for permittedNetwork |
void |
setPermittedNetworkMask(int permittedNetworkMask)
Setter for permittedNetworkMask |
void |
setProtocol(java.lang.String protocol)
Setter for protocol |
void |
setSourcePortRange(java.lang.String sourcePortRange)
Setter for sourcePortRange |
java.lang.String |
toString()
Converts the PortForwardRule to a String . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PortForwardRule(java.lang.String iface, java.lang.String address, java.lang.String protocol, int inPort, int outPort, java.lang.String permittedNetwork, int permittedNetworkMask, java.lang.String permittedMAC, java.lang.String sourcePortRange)
PortForwardRule
object.
iface
- interface name on which inbound connection is allowed (such as ppp0)inPort
- inbound port on which to listen for port forwardprotocol
- protocol of port connection (tcp, udp)address
- destination IP address to forward IP trafficoutPort
- destination port to forward IP trafficpermittedNetwork
- source network or ip address from which connection is allowed (such as 192.168.1.0)permittedNetworkMask
- source network mask from which connection is allowed (such as 255.255.255.0)permittedMAC
- MAC address from which connection is allowed (such as AA:BB:CC:DD:EE:FF)sourcePortRange
- range of source ports allowed on IP connection (sourcePort1:sourcePort2)public PortForwardRule()
PortForwardRule
object.
Method Detail |
---|
public boolean isComplete()
LocalRule
parameters have all been set. Returns false otherwise.
public java.lang.String toString()
PortForwardRule
to a String
.
Returns one of the following iptables strings depending on the PortForwardRule
format:
iptables -t nat -A PREROUTING -i {iface} -p {protocol} --dport {inPort} -j DNAT --to {address}:{outPort}
iptables -t nat -A PREROUTING -i {iface} -p {protocol} --sport {sourcePortRange} --dport {inPort} -j DNAT --to {address}:{outPort}
iptables -t nat -A PREROUTING -i {iface} -p {protocol} -m mac --mac-source {permittedMAC} --dport {inPort} -j DNAT --to {address}:{outPort}
iptables -t nat -A PREROUTING -i {iface} -p {protocol} -m mac --mac-source {permittedMAC} --sport {sourcePortRange} --dport {inPort} -j DNAT --to {address}:{outPort}
iptables -t nat -A PREROUTING -i {iface} -p {protocol} -s {permittedNetwork} --dport {inPort} -j DNAT --to {address}:{outPort}
iptables -t nat -A PREROUTING -i {iface} -p {protocol} -s {permittedNetwork} --sport {sourcePortRange} --dport {inPort} -j DNAT --to {address}:{outPort}
iptables -t nat -A PREROUTING -i {iface} -p {protocol} -s {permittedNetwork} -m mac --mac-source {permittedMAC} --dport {inPort} -j DNAT --to {address}:{outPort}
iptables -t nat -A PREROUTING -i {iface} -p {protocol} -s {permittedNetwork} -m mac --mac-source {permittedMAC} --sport {sourcePortRange} --dport {inPort} -j DNAT --to {address}:{outPort}
toString
in class java.lang.Object
PortForwardRule
public java.lang.String getIface()
public void setIface(java.lang.String iface)
iface
- the iface to setpublic java.lang.String getAddress()
public void setAddress(java.lang.String address)
address
- the address to setpublic java.lang.String getProtocol()
public void setProtocol(java.lang.String protocol)
protocol
- the protocol to setpublic int getInPort()
public void setInPort(int inPort)
inPort
- the inPort to setpublic int getOutPort()
public void setOutPort(int outPort)
outPort
- the outPort to setpublic java.lang.String getPermittedNetwork()
public void setPermittedNetwork(java.lang.String permittedNetwork)
permittedNetwork
- the permittedNetwork to setpublic int getPermittedNetworkMask()
public void setPermittedNetworkMask(int permittedNetworkMask)
permittedNetworkMask
- of the permittedNetwork to setpublic java.lang.String getPermittedMAC()
public void setPermittedMAC(java.lang.String permittedMAC)
permittedMAC
- the permittedMAC to setpublic java.lang.String getSourcePortRange()
public void setSourcePortRange(java.lang.String sourcePortRange)
sourcePortRange
- the sourcePortRange to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |