[Openstack] Problems accessing metadata service due to nova-network generated iptables rules

Lars Kellogg-Stedman lars at seas.harvard.edu
Wed Jun 20 21:15:21 UTC 2012


> Is the DNAT rule expected to work?  Does linux_net.py need a special
> case for when the metadata address is on the local host?

For now, I've modified linux_net.py so that it conditionally creates a REDIRECT
rule if FLAGS.metadata_host is 127.0.0.1:

  def metadata_forward():
      """Create forwarding rule for metadata."""
      if FLAGS.metadata_host == '127.0.0.1':
          iptables_manager.ipv4['nat'].add_rule('PREROUTING',
                                                '-s 0.0.0.0/0 -d 169.254.169.254/32 '
                                                '-p tcp -m tcp --dport 80 -j REDIRECT '
                                                '--to-ports %s' %
                                                (FLAGS.metadata_port))
      else:
          iptables_manager.ipv4['nat'].add_rule('PREROUTING',
                                                '-s 0.0.0.0/0 -d 169.254.169.254/32 '
                                                '-p tcp -m tcp --dport 80 -j DNAT '
                                                '--to-destination %s:%s' %
                                                (FLAGS.metadata_host, FLAGS.metadata_port))
      iptables_manager.apply()


-- 
Lars Kellogg-Stedman <lars at seas.harvard.edu>       |
Senior Technologist                                | http://ac.seas.harvard.edu/
Academic Computing                                 | http://code.seas.harvard.edu/
Harvard School of Engineering and Applied Sciences |




More information about the Openstack mailing list