Index: trunk/cgi-bin/main.cgi
===================================================================
--- trunk/cgi-bin/main.cgi	(revision 943)
+++ trunk/cgi-bin/main.cgi	(revision 944)
@@ -1357,6 +1357,12 @@
   # collect per-IP rDNS fields.  only copy over the ones that actually have something in them.
   my %iprev;
-  foreach (keys %webvar) {
-    $iprev{$_} = $webvar{$_} if /host_[\d.a-fA-F:]+/ && $webvar{$_};
+  foreach (sort keys %webvar) {
+    # skip all but the host_* fields
+    next unless /^host_[\d.a-fA-F:]+/;
+    # propagate the per-IP rDNS if present
+    $iprev{$_} = $webvar{$_} if $webvar{$_};
+    # set the rDNS to be cleared if there was a value before (was_host_* field),
+    # but there's no value in the matching visible form field now (host_*)
+    $iprev{$_} = '' if $webvar{"was_$_"} && !$webvar{$_};
   }
 
Index: trunk/templates/edit.tmpl
===================================================================
--- trunk/templates/edit.tmpl	(revision 943)
+++ trunk/templates/edit.tmpl	(revision 944)
@@ -82,5 +82,6 @@
 <tr>
 <td><TMPL_VAR NAME=r_ip></td>
-<td><input class="host" name="host_<TMPL_VAR NAME=r_ip>" value="<TMPL_VAR NAME=iphost>"></td>
+<td><input class="host" name="host_<TMPL_VAR NAME=r_ip>" value="<TMPL_VAR NAME=iphost>">
+<TMPL_IF iphost><input type="hidden" name="was_host_<TMPL_VAR NAME=r_ip>" value="1"></TMPL_IF></td>
 </tr>
 </TMPL_LOOP>
