{"id":149,"date":"2013-08-05T13:59:41","date_gmt":"2013-08-05T04:59:41","guid":{"rendered":"http:\/\/blog.ymyzk.com\/?p=149"},"modified":"2015-05-14T04:20:53","modified_gmt":"2015-05-13T19:20:53","slug":"debian-7-wheezy-kvm","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2013\/08\/debian-7-wheezy-kvm\/","title":{"rendered":"Debian 7 Wheezy\u306bKVM\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b (iptables\u5bfe\u5fdc)"},"content":{"rendered":"

Debian 7 Wheezy\u306bKVM\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u969b\u306e\u624b\u9806\u3092\u307e\u3068\u3081\u307e\u3059.<\/p>\n

\u307e\u305a, qemu-kvm\u3068libvirt-bin\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059. \u3053\u308c\u3089\u306fKVM\u3092\u5229\u7528\u3059\u308b\u306b\u3042\u305f\u3063\u3066\u5fc5\u305a\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059.<\/p>\n

\r\n$ sudo aptitude install qemu-kvm libvirt-bin\r\n<\/pre>\n

GUI\u3092\u7528\u3044\u305f\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u7ba1\u7406\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306f, virt-manager\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059.<\/p>\n

\r\n$ sudo aptitude install virt-manager\r\n<\/pre>\n

<\/p>\n

\u4e00\u822c\u30e6\u30fc\u30b6\u30fc\u304b\u3089\u3082\u4eee\u60f3\u30de\u30b7\u30f3\u3092\u7ba1\u7406\u3067\u304d\u308b\u3088\u3046\u306blibvirt\u30b0\u30eb\u30fc\u30d7\u306b\u30e6\u30fc\u30b6\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u304a\u304d\u307e\u3059. root\u304b\u3089\u306e\u307f\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u5fc5\u8981\u306a\u3044\u3067\u3059\u304c, X\u4e0a\u3067GUI\u3092\u7528\u3044\u3066\u7ba1\u7406\u3059\u308b\u5834\u5408\u306f\u8ffd\u52a0\u3057\u3066\u304a\u3044\u305f\u65b9\u304c\u826f\u3044\u3067\u3059.<\/p>\n

\r\n$ sudo adduser <user> libvirt\r\n<\/pre>\n

\u6b21\u306b, VM\u3092\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u30d6\u30ea\u30c3\u30b8\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059. VM\u3092\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306bNAT\u3092\u7528\u3044\u308b\u5834\u5408\u306f\u3053\u306e\u624b\u9806\u306f\u4e0d\u8981\u3067\u3059. \u30d6\u30ea\u30c3\u30b8\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059.<\/p>\n

\r\n$ sudo aptitude install bridge-utils\r\n<\/pre>\n

\u30d6\u30ea\u30c3\u30b8\u306e\u8a2d\u5b9a\u3092\/etc\/network\/interfaces\u306b\u8a18\u5165\u3057\u307e\u3059. NetworkManager\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3046\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u3067, \u4e8b\u524d\u306b\u7121\u52b9\u5316\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059. \u3053\u3053\u3067\u306feth0\u3067\u63a5\u7d9a\u3057\u3066\u3044\u305f\u3082\u306e\u3092, br0\u306b\u30d6\u30ea\u30c3\u30b8\u3059\u308b\u3068\u4eee\u5b9a\u3057\u3066\u8a2d\u5b9a\u3057\u307e\u3059.<\/p>\n

\u5143\u306e\u8a2d\u5b9a<\/p>\n

\r\nauto eth0\r\niface eth0 inet static\r\n    address 192.168.1.10\r\n    network 192.168.1.0\r\n    netmask 255.255.255.0\r\n    broadcast 192.168.1.255\r\n    gateway 192.168.1.1\r\n<\/pre>\n

\u30d6\u30ea\u30c3\u30b8\u8ffd\u52a0\u5f8c\u306e\u8a2d\u5b9a<\/p>\n

\r\nauto eth0\r\niface eth0 inet manual\r\n\r\nauto br0\r\niface br0 inet static\r\n    address 192.168.1.10\r\n    network 192.168.1.0\r\n    netmask 255.255.255.0\r\n    broadcast 192.168.1.255\r\n    gateway 192.168.1.1\r\n    bridge_ports eth0\r\n<\/pre>\n

\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u305f\u3089, \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059.<\/p>\n

\r\n$ sudo service networking stop\r\n$ sudo service networking start\r\n<\/pre>\n

\u3053\u308c\u3067, \u30d6\u30ea\u30c3\u30b8\u306e\u4f5c\u6210\u306f\u51fa\u6765\u307e\u3057\u305f\u304c, iptables\u3092\u4f7f\u3063\u3066\u30d1\u30b1\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3092\u884c\u3063\u3066\u3044\u308b\u5834\u5408, \u8a2d\u5b9a\u306b\u3088\u3063\u3066\u306f\u30d6\u30ea\u30c3\u30b8\u3078\u30d1\u30b1\u30c3\u30c8\u304c\u901a\u3089\u306a\u304f\u306a\u308a\u307e\u3059. \u30d6\u30ea\u30c3\u30b8\u4e0a\u3067\u3055\u308c\u305f\u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306f iptables \u3092\u901a\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081, \/etc\/sysctl.conf<\/code> \u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u3066\u304a\u304d\u307e\u3059.<\/p>\n

\r\nnet.bridge.bridge-nf-call-ip6tables=0\r\nnet.bridge.bridge-nf-call-iptables=0\r\nnet.bridge.bridge-nf-call-arptables=0\r\n<\/pre>\n

\u4ee5\u4e0b\u3092\u5b9f\u884c\u3057\u3066, \u8a2d\u5b9a\u5909\u66f4\u3092\u53cd\u6620\u3055\u305b\u307e\u3059.<\/p>\n

\r\nsudo sysctl -p \/etc\/sysctl.conf\r\n<\/pre>\n

\u8d77\u52d5\u6642\u306b\u78ba\u5b9f\u306b sysctl.conf \u306e\u8a2d\u5b9a\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081 \/etc\/rc.local \u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059.<\/p>\n

\r\n# \u301c\u301c\u301c \u7701\u7565 \u301c\u301c\u301c\r\n\r\n# \u4ee5\u4e0b\u306e\u884c\u3092\u8ffd\u8a18\r\n\/sbin\/sysctl -p \/etc\/sysctl.conf\r\n\r\nexit 0\r\n<\/pre>\n

\u4ee5\u4e0a\u3067, Debian 7 Wheezy\u4e0a\u3067KVM\u3092\u4f7f\u3063\u305fVM\u3092\u4f5c\u6210\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059. VM\u306e\u4f5c\u6210\u65b9\u6cd5\u306a\u3069\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u3092\u53c2\u8003\u306b\u3057\u3066\u4e0b\u3055\u3044.<\/p>\n

\u53c2\u8003<\/p>\n