Squeezeでvmnet1のホストオンリー接続のみ、IPv6を無効にする。

■vmnet1のホストオンリー接続のみ、IPv6を無効にする。
 以下の通り、NIC、default、all以外で指定できる項目は以下のようになる。
 ※debian Squeezeでの場合(kernel操作なのでバージョン、ディストリビューションにより若干異なる)

$ sudo sysctl -a 2>&1 | \
  grep ipv6 | \
  grep -v "permission denied\|lo\.\|eth\|bond\|vmnet\|default\|all" | \
  sed s/"\.* = .*"//
net.ipv6.xfrm6_gc_thresh
net.ipv6.ip6frag_high_thresh
net.ipv6.ip6frag_low_thresh
net.ipv6.ip6frag_time
net.ipv6.route.gc_thresh
net.ipv6.route.max_size
net.ipv6.route.gc_min_interval
net.ipv6.route.gc_timeout
net.ipv6.route.gc_interval
net.ipv6.route.gc_elasticity
net.ipv6.route.mtu_expires
net.ipv6.route.min_adv_mss
net.ipv6.route.gc_min_interval_ms
net.ipv6.icmp.ratelimit
net.ipv6.bindv6only
net.ipv6.ip6frag_secret_interval
net.ipv6.mld_max_msf

■例えば、「/etc/sysctl.d/ipv6_disable.conf」や
  「/etc/sysctl.d/local.conf」を作成し書いても良い。
  文章中にあるようにファイル名は重要では無いが、分かるようにする。

$ cat /etc/sysctl.d/README.sysctl
Kernel system variables configuration files

Files found under the /etc/sysctl.d directory that end with .conf are
parsed within sysctl(8) at boot time.  If you want to set kernel variables
you can either edit /etc/sysctl.conf or make a new file.

The filename isn't important, but don't make it a package name as it may clash
with something the package builder needs later. It must end with .conf though.

My personal preference would be for local system settings to go into
/etc/sysctl.d/local.conf but as long as you follow the rules for the names
of the file, anything will work. See sysctl.conf(8) man page for details
of the format.

■私の場合は「sysctl.conf」で一元管理している。
 ※kernel操作なので、使用しているサービス(daemon)によってはシステムの再起動を行った方が良いかも知れない。

$ sudo sysctl -a 2>&1 | grep ipv6 | grep vmnet1 | grep disable
net.ipv6.conf.vmnet1.disable_ipv6 = 0

$ cat /proc/sys/net/ipv6/conf/vmnet1/disable_ipv6
0

$ echo "1" | sudo tee /proc/sys/net/ipv6/conf/vmnet1/disable_ipv6
1

$ sudo grep disable_ipv6 /etc/sysctl.conf
net.ipv6.conf.vmnet1.disable_ipv6 = 1

$ sudo sysctl -p
net.ipv4.ip_forward = 1
net.ipv6.conf.vmnet1.disable_ipv6 = 1
$ sudo /etc/init.d/networking restart

■確認方法1
 「lo」デバイスには「inet6」の項があり、「vmnet1」には無い。

$ env LANG=C /sbin/ifconfig lo | grep inet6
          inet6 addr: ::1/128 Scope:Host
$ env LANG=C /sbin/ifconfig vmnet1 | grep inet6

■確認方法2
 「netstat」にあるのは、「lo」のinet6か、他NICのinet6ポートである。

$ netstat -an | grep ^[tu][cd]p6
tcp6       0      0 ::1:80                  :::*                    LISTEN
udp6       0      0 ::1:123                 :::*
udp6       0      0 :::123                  :::*

■確認方法3

$ sudo tcpdump ip6 -i vmnet1
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on vmnet1, link-type EN10MB (Ethernet), capture size 65535 bytes

■他に無効に出来るのは以下の通り。
 「all」はすべて。1つでもIPv6の有効な設定項目がある場合は「default」は0のままにする。

$ sudo sysctl -a 2>&1 | grep "ipv6.*disable"
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.eth0.disable_ipv6 = 0
net.ipv6.conf.eth1.disable_ipv6 = 0
net.ipv6.conf.eth2.disable_ipv6 = 0
net.ipv6.conf.eth3.disable_ipv6 = 0
net.ipv6.conf.eth4.disable_ipv6 = 0
net.ipv6.conf.eth5.disable_ipv6 = 0
net.ipv6.conf.bond0.disable_ipv6 = 0
net.ipv6.conf.vmnet1.disable_ipv6 = 1
net.ipv6.conf.vmnet8.disable_ipv6 = 0

■ゲストOSのホストオンリー接続のみのSqueeze側ではすべてのIPv6を無効にする。

$ sudo grep disable_ipv6 /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

$ sudo sysctl -p
net.ipv4.ip_forward = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

$ sudo /etc/init.d/networking restart

$ sudo sysctl -a 2>/dev/null | grep disable_ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.eth1.disable_ipv6 = 1
net.ipv6.conf.eth2.disable_ipv6 = 1

$ env LANG=C /sbin/ifconfig | grep inet6
$ netstat -an | grep ^[tu][cd]p6
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::53                   :::*                    LISTEN
udp6       0      0 :::53                   :::*
udp6       0      0 :::123                  :::*

※サービス(daemon)ごとにIPv6無効の設定を行っていること。

$ sudo grep listen-on-v6 /etc/bind/named.conf.options 
        listen-on-v6 { none; };
$ sudo grep 4 /etc/default/ntp
NTPD_OPTS='-4 -g'
$ sudo grep 80 /etc/apache2/ports.conf
NameVirtualHost *:80
Listen 192.168.164.111:80

$ sudo /etc/init.d/apache2 restart
Restarting web server: apache2 ... waiting .
$ sudo /etc/init.d/bind9 restart
Stopping domain name service...: bind9 waiting for pid 1405 to die.
Starting domain name service...: bind9.
$ sudo /etc/init.d/ntp restart
Stopping NTP server: ntpd.
Starting NTP server: ntpd.
$ netstat -an | grep ^[tu][cd]p6