<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:12pt;font-family:helvetic">
<p>Ok, </p>
<p></p>
<p>I have a challenge - get two services working over a single port. (!) Sometimes it's a web service, sometimes it's a VNC service. Here's what I had in mind: </p>
<p></p>
<p>1) Server is normally a webserver listening on port 80, and normally has the following rules active: </p>
<p># iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT</p>
<p># iptables -t nat -A POSTROUTING -j MASQUERADE </p>
<p></p>
<p></p>
<p>2) Server hosts a special PHP script, that when called correctly, sets rules like </p>
<p></p>
<p># iptables -I PREROUTING -p tcp -s $REMOTE --dport 80 -j DNAT --to-destination $FWIP:$FWPORT</p>
<p># iptables -I FORWARD -p tcp -s $REMOTE --dport 80 -j ACCEPT </p>
<p></p>
<p>The *next* tcp connection from their computer to the webserver will get NAT'd to service $FWIP:$FWPORT. </p>
<p></p>
<p>But I want this rule cleared out as soon as the connection is made with the latter altered rules. Is there a way to write a rule or set of rules that, when activated, then delete themselves? The "ESTABLISHED,RELATED" rule should keep the connection alive even after the latter rules are killed, right? </p>
<p></p>
<p>Is this possible? Am I just out in left field? </p>
</body></html>