LoginSignup
9
8

More than 5 years have passed since last update.

Linuxで物理NICを使わずに仮想ブリッジを作る方法

Last updated at Posted at 2014-01-15

dummy net driverを使うとLinuxで物理NICを消費せずに仮想ブリッジを作れます。
NICが1つしかない物理マシンでOpenVPNやLXCを使うとき便利♪
続きを書きました!:Linuxでdummy net driverを使った仮想ブリッジを複数作る方法


dummy net driverを使ってdummy0というダミーNICを作ります。
Gentoo Linuxなら /etc/conf.d/net にこんな感じで書いて、 /etc/init.d/ の下にNIC名でsymlinkを張ります。

# cat /etc/conf.d/net
config_dummy0=(null)
bridge_br0="dummy0"
config_br0="null"
# ls -al /etc/init.d/net.*
lrwxrwxrwx 1 root root     6 Jan 14 05:10 /etc/init.d/net.br0 -> net.lo*
lrwxrwxrwx 1 root root     6 Jan 14 05:13 /etc/init.d/net.dummy0 -> net.lo*
-rwxr-xr-x 1 root root 17412 Dec  5 06:05 /etc/init.d/net.lo*

物理NICを消費せずに仮想ブリッジを起動できました♪

# /etc/init.d/net.br0 start
 * Bringing up interface br0
 *   Creating bridge br0 ...
 *   Adding ports to br0
 *     dummy0 ...                                                         [ ok ]
 *   Waiting for IPv6 addresses ...                                       [ ok ]

ifconfig はこんな感じ。

# ifconfig br0
br0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500
        inet6 fe80::d472:abff:febb:536b  prefixlen 64  scopeid 0x20<link>
        ether d6:72:ab:bb:53:6b  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19  bytes 4308 (4.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# ifconfig dummy0
dummy0: flags=195<UP,BROADCAST,RUNNING,NOARP>  mtu 1500
        inet6 fe80::d472:abff:febb:536b  prefixlen 64  scopeid 0x20<link>
        ether d6:72:ab:bb:53:6b  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 137  bytes 30835 (30.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

9
8
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
9
8