仮想マシンに NIC を追加する
概要
仮想マシンに NIC を追加したくなった状況に遭遇したのでやってみる
事前情報
物理マシン環境
- OS
# cat /etc/redhat-release
CentOS release 6.4 (Final)
仮想マシン環境
- OS
# cat /etc/redhat-release
CentOS release 6.4 (Final)
- 追加前 I/F
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:6e:64:cd brd ff:ff:ff:ff:ff:ff
inet 10.29.8.1/20 brd 10.29.15.255 scope global eth0
inet6 fe80::5054:ff:fe6e:64cd/64 scope link
valid_lft forever preferred_lft forever
作業内容
# cat /etc/redhat-release
CentOS release 6.4 (Final)
# cat /etc/redhat-release
CentOS release 6.4 (Final)
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:6e:64:cd brd ff:ff:ff:ff:ff:ff
inet 10.29.8.1/20 brd 10.29.15.255 scope global eth0
inet6 fe80::5054:ff:fe6e:64cd/64 scope link
valid_lft forever preferred_lft forever
1.仮想マシンのシャットダウン
# shutdown -h now
2.物理マシン(kvmホスト) で仮想マシンの xml を編集
* 追加するI/F設定は、紐付けたい br I/F と model type のみ記載。mac, address type については自動で付与されるため不要。
# virsh list --all
Id 名前 状態
----------------------------------------------------
- hogehoge シャットオフ
# virsh edit hogehoge
+ <interface type='bridge'>
+ <source bridge='br1'/>
+ <model type='virtio'/>
+ </interface>
+ <interface type='bridge'>
+ <source bridge='br2'/>
+ <model type='virtio'/>
+ </interface>
3.設定を反映
# virsh define /etc/libvirt/qemu/hogehoge.xml
ドメイン hogehoge が /etc/libvirt/qemu/hogehoge.xml から定義されました
4.仮想マシンを起動
# virsh start hogehoge
ドメイン hogehoge が起動されました
5.I/F が追加されていることを確認
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:6e:64:cd brd ff:ff:ff:ff:ff:ff
inet 10.29.8.1/20 brd 10.29.15.255 scope global eth0
inet6 fe80::5054:ff:fe6e:64cd/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 52:54:00:3d:3f:e1 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 52:54:00:27:c2:4b brd ff:ff:ff:ff:ff:ff
Author And Source
この問題について(仮想マシンに NIC を追加する), 我々は、より多くの情報をここで見つけました https://qiita.com/masahixixi/items/4eb014eff723d39552ec著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .