'Configure the NAT and iptables'

def config(self, **params):

    super(NAT, self).config(**params)
    if (not self.localIntf):
        self.localIntf = self.defaultIntf()
    if self.flush:
        self.cmd('sysctl    net.ipv4.ip_forward=0')
        self.cmd('iptables    -F')
        self.cmd('iptables    -t    nat    -F')
        self.cmd('iptables    -P    INPUT    ACCEPT')
        self.cmd('iptables    -P    OUTPUT    ACCEPT')
        self.cmd('iptables    -P    FORWARD    DROP')
    self.cmd('iptables    -I    FORWARD', '-i', self.localIntf, '-d', self.subnet, '-j    DROP')
    self.cmd('iptables    -A    FORWARD', '-i', self.localIntf, '-s', self.subnet, '-j    ACCEPT')
    self.cmd('iptables    -A    FORWARD', '-o', self.localIntf, '-d', self.subnet, '-j    ACCEPT')
    self.cmd('iptables    -t    nat    -A    POSTROUTING', '-s', self.subnet, "'!'", '-d', self.subnet, '-j    MASQUERADE')
    self.cmd('sysctl    net.ipv4.ip_forward=1')
    intf = self.localIntf
    cfile = '/etc/network/interfaces'
    line = ('\niface    %s    inet    manual\n' % intf)
    config = open(cfile).read()
    if (line not in config):
        info((((('***    Adding    "' + line.strip()) + '"    to    ') + cfile) + '\n'))
        with open(cfile, 'a') as f:
            f.write(line)
    self.cmd('service    network-manager    restart')
