11
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

仮想マシンに NIC を追加する

Last updated at Posted at 2014-08-04

概要

仮想マシンに 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

作業内容

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
11
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?