def chain(cmd, chain, p = {})
      cmds = {
        new: '-N', rename: '-E', delete: '-X', flush: '-F',
        list_rules: '-S', list: '-L', zero: '-Z', policy: '-P'
      }

      @buffer << [
        'iptables',
        option('-t', @table), cmds[cmd], option('-n', p[:numeric]), chain,
        option(false, p[:rulenum]), option(false, p[:to])
      ].compact.join(' ') << "\n"

      self
    end
def chain(cmd, chain, p = {})
      cmds = {
        new: '-N', rename: '-E', delete: '-X', flush: '-F',
        list_rules: '-S', list: '-L', zero: '-Z', policy: '-P'
      }

      @buffer << [
        'iptables',
        option('-t', @table), cmds[cmd], option('-n', p[:numeric]), chain,
        option(false, p[:rulenum]), option(false, p[:to])
      ].compact.join(' ') << "\n"

      self
    end
Create, flush and delete chains and other iptable chain operations.
 @param [Symbol] cmd the operation to perform (:new, :delete, :flush)
 @param [String] chain name of the chain (e.g. INPUT, CATFLAP-DENY, etc.)
 @param [Hash] p parameters for specific iptables features.
 @return self
 @example
   Rules.new('nat').chain(:list, 'MY-CHAIN', numeric: true).flush
   => "iptables -t nat -n -L MY-CHAIN"