linux关闭ip6,关闭linux中的IPV6的方法,及FATAL问题解决

在Linux下确认IPv6是否已经被启用,可以从三个方面确定。

1.使用ifconfig查看自己的IP地址是否含有IPv6地址。

eth0 Link encap:Ethernet HWaddr 00:13:D4:05:B2:ED

inet addr:119.119.xxx.xx Bcast:119.119.115.255 Mask:255.255.255.0

inet6 addr: fe80::213:d4ff:fe05:b2ed/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:1054562 errors:0 dropped:0 overruns:0 frame:0

TX packets:538136 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:346189738 (330.1 MiB) TX bytes:246935731 (235.4 MiB)

Interrupt:209 Base address:0xd800

2.查看服务监听的IP中是否有IPv6格式的地址。(netstat -tuln)

tcp 0 0 0.0.0.0:8100 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:843 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN

tcp 0 0 :::8080 :::* LISTEN

tcp 0 0 :::22 :::* LISTEN

tcp 0 0 :::443 :::* LISTENudp 0 0 0.0.0.0:68 0.0.0.0:*

udp 0 0 0.0.0.0:111 0.0.0.0:*

udp 0 0 0.0.0.0:631 0.0.0.0:*

3.使用lsmod查看ipv6的模块是否被加载。

[root@linux ~]# lsmod |grep ip

ipt_MASQUERADE 7617 3

iptable_nat 11077 1

ip_nat 21101 2 ipt_MASQUERADE,iptable_nat

ip_conntrack_netbios_ns 6977 0

ipt_REJECT 9665 3

ip_conntrack 53281 5 ipt_MASQUERADE,iptable_nat,ip_nat,ip_conntrack_netbios_ns,xt_state

nfnetlink 10713 2 ip_nat,ip_conntrack

iptable_filter 7105 1

ip_tables 17029 2 iptable_nat,iptable_filter

ip6t_REJECT 9409 1

ip6table_filter 6849 1

ip6_tables 18053 1 ip6table_filterx_tables 17349 8 ipt_MASQUERADE,iptable_nat,ipt_REJECT,xt_state,ip_tables,ip6t_REJECT,xt_tcpudp,ip6_tables

ipv6 270433 18 ip6t_REJECT,cnic

如果出现以上粗体显示的部分,代表您的机器上IPV6已经开启。

关闭IPV6

使用vi编辑器,打开/etc/modprobe.conf,在文档中加入如下的两条:

alias net-pf-10 off

alias ipv6 off

保存退出,并且重新启动系统。

以上这是网上关闭IPV6的常见方法。其他方法还有:

通过在sysctl.conf添加下面来禁用ipv6 ,不过并不能使得其它程序默认不开启对ipv6的技持

但在Centos 6 关闭ipv6使用在 /etc/modprobe.d/dist.conf增加如下内容

alias net-pf-10 off

alias ipv6 off

此步可以禁止ipv6,但重启网络会提示报错FATAL: Module off not found.

解决方法如下:

1. alias ipv6 off 替换成 options ipv6 disable=1

2. /etc/sysconfig/network 新增如下一行

NETWORKING_IPV6=off

3. 关闭iptables的ipv6

# chkconfig ip6tables off