mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
translated
This commit is contained in:
parent
f155e6d8fa
commit
0aac3e8daf
@ -1,97 +0,0 @@
|
||||
Translating----geekpi
|
||||
|
||||
How To Disable IPv6 In CentOS 7
|
||||
================================================================================
|
||||
Recently, one of my friend asked me how to disable IPv6. After searching a bit, I found the following solution. Here is the steps that I followed to disable IPv6 in my CentOS 7 minimal server.
|
||||
|
||||
You can do it in two methods.
|
||||
|
||||
### Method 1 ###
|
||||
|
||||
Edit file **/etc/sysctl.conf**,
|
||||
|
||||
vi /etc/sysctl.conf
|
||||
|
||||
Add the following lines:
|
||||
|
||||
net.ipv6.conf.all.disable_ipv6 = 1
|
||||
net.ipv6.conf.default.disable_ipv6 = 1
|
||||
|
||||
If you want to disable IPV6 for particular network card, for example enp0s3, add the following entry.
|
||||
|
||||
net.ipv6.conf.enp0s3.disable_ipv6 = 1
|
||||
|
||||
Save and exit the file.
|
||||
|
||||
Execute the following command to reflect the changes.
|
||||
|
||||
sysctl -p
|
||||
|
||||
### Method 2: ###
|
||||
|
||||
To IPv6 disable in the running system, enter the following commands one by one:
|
||||
|
||||
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
|
||||
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
|
||||
|
||||
or,
|
||||
|
||||
sysctl -w net.ipv6.conf.all.disable_ipv6=1
|
||||
sysctl -w net.ipv6.conf.default.disable_ipv6=1
|
||||
|
||||
That’s it. Now IPv6 has been disabled.
|
||||
|
||||
### What If I get issues after disabling IPv6? ###
|
||||
|
||||
You may get problems after disabling IPv6.
|
||||
|
||||
#### Issue 1: ####
|
||||
|
||||
if you get issues with SSH after disabling IPv6, do the following.
|
||||
|
||||
Edit **/etc/ssh/sshd_config** file,
|
||||
|
||||
vi /etc/ssh/sshd_config
|
||||
|
||||
Find the line;
|
||||
|
||||
#AddressFamily any
|
||||
|
||||
And. change it to:
|
||||
|
||||
AddressFamily inet
|
||||
|
||||
or,
|
||||
|
||||
Remove the hash mark **(#)** in front of the line:
|
||||
|
||||
#ListenAddress 0.0.0.0
|
||||
|
||||
Then, restart ssh to reflect the changes.
|
||||
|
||||
systemctl restart sshd
|
||||
|
||||
#### Issue 2: ####
|
||||
|
||||
If you get problems with starting postfix after disabling IPv6, edit **/etc/postfix/main.cf** file;
|
||||
|
||||
vi /etc/postfix/main.cf
|
||||
|
||||
and comment out the localhost part of the config and use ipv4 loopback.
|
||||
|
||||
#inet_interfaces = localhost
|
||||
inet_interfaces = 127.0.0.1
|
||||
|
||||
That’s it. Cheers!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.unixmen.com/disable-ipv6-centos-7/
|
||||
|
||||
作者:[SK][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.unixmen.com/author/sk/
|
96
translated/tech/20150119 How To Disable IPv6 In CentOS 7.md
Normal file
96
translated/tech/20150119 How To Disable IPv6 In CentOS 7.md
Normal file
@ -0,0 +1,96 @@
|
||||
如何在CentOS 7中禁止IPv6
|
||||
================================================================================
|
||||
最近,我的一位朋友问我该如何禁止IPv6。在搜索了一番之后,我找到了下面的方案。下面就是我在CentOS 7迷你版中禁止IPv6的方法。
|
||||
|
||||
你可以用两个方法做到这个。
|
||||
|
||||
### 方法 1 ###
|
||||
|
||||
编辑文件**/etc/sysctl.conf**,
|
||||
|
||||
vi /etc/sysctl.conf
|
||||
|
||||
添加下面的行:
|
||||
|
||||
net.ipv6.conf.all.disable_ipv6 = 1
|
||||
net.ipv6.conf.default.disable_ipv6 = 1
|
||||
|
||||
如果你想要为特定的网卡禁止IPv6,比如,对于enp0s3,添加下面的行。
|
||||
|
||||
net.ipv6.conf.enp0s3.disable_ipv6 = 1
|
||||
|
||||
保存并退出文件。
|
||||
|
||||
执行下面的命令来使设置生效。
|
||||
|
||||
sysctl -p
|
||||
|
||||
### 方法 2 ###
|
||||
|
||||
要在运行的系统中禁止IPv6,依次输入下面的命令:
|
||||
|
||||
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
|
||||
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
|
||||
|
||||
或者,
|
||||
|
||||
sysctl -w net.ipv6.conf.all.disable_ipv6=1
|
||||
sysctl -w net.ipv6.conf.default.disable_ipv6=1
|
||||
|
||||
就是这样。现在IPv6已经禁止了。
|
||||
|
||||
### 我在禁止IPv6后遇到问题怎么办 ###
|
||||
|
||||
You may get problems after disabling IPv6.
|
||||
你可能在禁止IPv6后遇到一些问题
|
||||
|
||||
#### 问题1: ####
|
||||
|
||||
如果你在禁止IPv6后SSH遇到问题,按照下面的做。
|
||||
|
||||
编辑 **/etc/ssh/sshd_config** 文件
|
||||
|
||||
vi /etc/ssh/sshd_config
|
||||
|
||||
找到下面的行:
|
||||
|
||||
#AddressFamily any
|
||||
|
||||
把它改成:
|
||||
|
||||
AddressFamily inet
|
||||
|
||||
或者,
|
||||
|
||||
在这行的前面去掉注释**(#)**:
|
||||
|
||||
#ListenAddress 0.0.0.0
|
||||
|
||||
接着重启ssh来使改变生效。
|
||||
|
||||
systemctl restart sshd
|
||||
|
||||
#### 问题2: ####
|
||||
|
||||
如果你在禁止Ipv6后启动postfix遇到问题,编辑**/etc/postfix/main.cf**:
|
||||
|
||||
vi /etc/postfix/main.cf
|
||||
|
||||
注释掉配置中的localhost部分,并且使用ipv4回环。
|
||||
|
||||
#inet_interfaces = localhost
|
||||
inet_interfaces = 127.0.0.1
|
||||
|
||||
就是这样,干杯!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.unixmen.com/disable-ipv6-centos-7/
|
||||
|
||||
作者:[SK][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.unixmen.com/author/sk/
|
Loading…
Reference in New Issue
Block a user