title: How to restart a Java service without disruption using firewall/iptables?
body: <p>If enable this rule</p>
  
  <pre><code>iptables -t nat -A PREROUTING -p tcp --dport 80  -j REDIRECT --to 8080
  </code></pre>
  
  <p>Then connections coming to the server port 80 are redirected to localhost:8080. If I want to restart the service, can I just start the service on another port? Say port 8081 and re route the firewalling to</p>
  
  <pre><code>iptables -t nat -A PREROUTING -p tcp --dport 80  -j REDIRECT --to 8081 # Apparently -A won't work. I have to replace the rule, not add it. But I don't know how to do it yet
  </code></pre>
  
  <p>However, what about the established TCP socket connections on the NAT-ed port 8080? 
  Will they be dropped immediately after firewall changes? Alternatively, will they keep working until a normal TCP socket close?</p>
  
  <p>If so, then this works a restart of the application with no disruption by having the old instance on port 8080 on a graceful shutdown and the new one on port 8081 with the new features.</p>
  
  <p>Is this reasoning correct?</p>