首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将IP地址传递给云init元数据。

将IP地址传递给云init元数据。
EN

Stack Overflow用户
提问于 2015-12-29 09:05:01
回答 1查看 11.1K关注 0票数 4

我正在寻找一种将ip地址传递给云init元数据的方法。因此,当我的qcow启动时,它不需要等待120-180秒才能启动。

目前,我通过向云init的用户数据部分添加IP地址信息来创建解决方案。缺点是,这确实需要一些时间,因为云init用户数据只有在启动VM之后才会执行。

代码语言:javascript
运行
复制
echo -e "
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
\taddress $address
\tnetmask $netmask
\tgateway $gateway
\tdns-nameservers $dnsnameservers
" > /etc/network/interfaces

ifdown eth0; ifup eth0

目前,为了在云init元数据中设置主机名,我已经获得了以下部分:

代码语言:javascript
运行
复制
cat > $config_dir/meta-data <<-EOF
instance-id: $uuid
hostname: $hostname
local-hostname: $hostname
EOF

但是我需要一些更坚实、更具体的东西,因为云init文档非常模糊。

编辑:--我看到这是可能的,因为Openstack可以做到这一点。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-29 11:40:26

使用以下格式是可能的:

代码语言:javascript
运行
复制
network-interfaces: |
  auto lo
  iface lo inet loopback

  iface eth0 inet static
    address xxx.xxx.xxx.xxx (static ip)
    netmask xxx.xxx.xxx.xxx
    gateway xxx.xxx.xxx.xxx (gateway ip, usually ip address of router)

基本上,只要您有‘网络接口:_’_

希望这能回答你的问题!

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34507807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档