def init_host(ip_range=None):
 if (not ip_range):
  ip_range = CONF.fixed_range
 add_snat_rule(ip_range)
 rules = []
 for snat_range in CONF.force_snat_range:
  rules.append(('PREROUTING -p ipv4 --ip-src %s --ip-dst %s -j redirect --redirect-target ACCEPT' % (ip_range, snat_range)))
 if rules:
  ensure_ebtables_rules(rules, 'nat')
 iptables_manager.ipv4['nat'].add_rule('POSTROUTING', ('-s %s -d %s/32 -j ACCEPT' % (ip_range, CONF.metadata_host)))
 for dmz in CONF.dmz_cidr:
  iptables_manager.ipv4['nat'].add_rule('POSTROUTING', ('-s %s -d %s -j ACCEPT' % (ip_range, dmz)))
 iptables_manager.ipv4['nat'].add_rule('POSTROUTING', ('-s %(range)s -d %(range)s -m conntrack ! --ctstate DNAT -j ACCEPT' % {'range': ip_range}))
 iptables_manager.apply()

def init_host ( ip_range = None ) : if ( not ip_range ) : ip_range = CONF . fixed_range add_snat_rule ( ip_range ) rules = [ ] for snat_range in CONF . force_snat_range : rules . append ( ( 'PREROUTING -p ipv4 --ip-src %s --ip-dst %s -j redirect --redirect-target ACCEPT' % ( ip_range , snat_range ) ) ) if rules : ensure_ebtables_rules ( rules , 'nat' ) iptables_manager . ipv4 [ 'nat' ] . add_rule ( 'POSTROUTING' , ( '-s %s -d %s/32 -j ACCEPT' % ( ip_range , CONF . metadata_host ) ) ) for dmz in CONF . dmz_cidr : iptables_manager . ipv4 [ 'nat' ] . add_rule ( 'POSTROUTING' , ( '-s %s -d %s -j ACCEPT' % ( ip_range , dmz ) ) ) iptables_manager . ipv4 [ 'nat' ] . add_rule ( 'POSTROUTING' , ( '-s %(range)s -d %(range)s -m conntrack ! --ctstate DNAT -j ACCEPT' % { 'range' : ip_range } ) ) iptables_manager . apply ( )
basic networking setup goes here .