First of all: iTunes will backup the rules, so if you restore from a backup they will be there again :)

 

To manually backup the rules shh to /var/mobile/Library/Preferences/ and save com.Yllier.FirewallRules.plist and com.Yllier.FirewallGlobalRules.plist . When you restore those files make sure they have 666 as permissions (rw-rw-rw-).