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