乐云主机笔记

  • 首页
  • 学习记录
  • 资源下载
  • 新手教程
  • 其他
  • 脚本源码
  • 自用主机
  • 主机优惠
  • 域名优惠
  • 网赚项目

  1. 首页
  2. 学习记录
  3. 正文

cloudraft nat机开启IPV6并设置支持IPV6的yum源、epel与ius源

2020年 12月 20日 1982点热度 0人点赞 0条评论

一、开启IPV6


前言
本教程适用于云筏的NAT服务器,地址:https://my.cloudraft.cn/server/buy.html?lineid=1012

1.CentOS7系统


开启IPv6功能
有些镜像是禁用了IPv6功能的,因此需要开启。首先查看一下是否被禁用了:

sysctl -a | grep ipv6.*disable

显示:

sysctl: reading key "net.ipv6.conf.all.stable_secret"
net.ipv6.conf.all.disable_ipv6 = 1
sysctl: net.ipv6.conf.default.disable_ipv6 = 1
reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
net.ipv6.conf.eth0.disable_ipv6 = 1
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
net.ipv6.conf.lo.disable_ipv6 = 1

 

disable=1说明被禁用了,因此需要去修改,配置文件为/etc/sysctl.conf

vi /etc/sysctl.conf

 

#把ipv6 disable的参数都改为0,然后保存,重载服务后生效

[root@hSxavP1000044 ~]#

sysctl -p

结果:

vm.swappiness = 0
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0

 

设置网卡,启用DHCP
修改网卡配置文件:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

 

在原有配置后面增加输入以下信息:

Networking_IPV6=yes

DHCPV6C=yes

IPV6INIT=yes

 

然后重启网络:

service network restart

 

检查是否生效
[root@hSxavP1000044 network-scripts]#

ip addr

显示结果:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

link/ether 00:15:5d:1a:f7:05 brd ff:ff:ff:ff:ff:ff

inet 172.16.2.7/12 brd 172.31.255.255 scope global eth0

valid_lft forever preferred_lft forever

inet6 2a01:4f8:212:1234:215:5dff:fe1a:f705/64 scope global mngtmpaddr dynamic

valid_lft 2591920sec preferred_lft 604720sec

inet6 fe80::215:5dff:fe1a:f705/64 scope link

valid_lft forever preferred_lft forever

 

注意看eth0的网卡中ipv6地址是否被分配

[root@hSxavP1000044 network-scripts]#

ping6 ipv6.google.com

 

PING ipv6.google.com(yw-in-x66.1e100.net (2607:f8b0:4002:c05::66)) 56 data bytes

64 bytes from yw-in-x66.1e100.net (2607:f8b0:4002:c05::66): icmp_seq=1 ttl=103 time=107 ms

64 bytes from yw-in-x66.1e100.net (2607:f8b0:4002:c05::66): icmp_seq=2 ttl=103 time=107 ms

^C

--- ipv6.google.com ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1002ms

rtt min/avg/max/mdev = 107.212/107.398/107.584/0.186 ms

ping6测试google的ipv6站点是否能通

[root@hSxavP1000044 network-scripts]#

ip -6 route

 

2a01:4f8:212:1234::/64 dev eth0 proto kernel metric 256 expires 2591804sec pref medium

fe80::/64 dev eth0 proto kernel metric 256 pref medium

default via fe80::24b9:6e08:f5fd:b36f dev eth0 proto ra metric 1024 expires 1604sec pref medium

查看ipv6路由表

2.Debian / Ubuntu


开启IPv6功能
有些镜像是禁用了IPv6功能的,因此需要开启。首先查看一下是否被禁用了:

root@HIzcND1000044:~# sysctl -a | grep ipv6.*disable

sysctl: reading key "net.ipv6.conf.all.stable_secret"

net.ipv6.conf.all.disable_ipv6 = 1

sysctl: reading key "net.ipv6.conf.default.stable_secret"

net.ipv6.conf.default.disable_ipv6 = 1

sysctl: reading key "net.ipv6.conf.eth0.stable_secret"

net.ipv6.conf.eth0.disable_ipv6 = 1

sysctl: reading key "net.ipv6.conf.lo.stable_secret"

net.ipv6.conf.lo.disable_ipv6 = 1

disable=1说明被禁用了,因此需要去修改,配置文件为/etc/sysctl.conf

vi /etc/sysctl.conf

#把ipv6 disable的参数都改为0,然后保存,重载服务后生效

root@HIzcND1000044:~# sysctl -p

vm.swappiness = 0

net.ipv4.neigh.default.gc_stale_time = 120

net.ipv4.conf.all.rp_filter = 0

net.ipv4.conf.default.rp_filter = 0

net.ipv4.conf.default.arp_announce = 2

net.ipv4.conf.lo.arp_announce = 2

net.ipv4.conf.all.arp_announce = 2

net.ipv4.tcp_max_tw_buckets = 5000

net.ipv4.tcp_syncookies = 1

net.ipv4.tcp_max_syn_backlog = 1024

net.ipv4.tcp_synack_retries = 2

net.ipv6.conf.all.disable_ipv6 = 0

net.ipv6.conf.default.disable_ipv6 = 0

net.ipv6.conf.lo.disable_ipv6 = 0

设置网卡,启用DHCP
nano /etc/network/interfaces

添加一行iface eth0 inet6 dhcp,举例示意:

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

 

source /etc/network/interfaces.d/*

 

# The loopback network interface

auto lo

iface lo inet loopback

 

# The primary network interface

auto eth0

iface eth0 inet static

address 172.16.2.X

netmask 255.240.0.0

gateway 172.16.2.1

 

iface eth0 inet6 dhcp

重启网络,检查是否正常

service networking restart

二、设置支持IPv6的源


因为 epel 与 ius 源可以提供很多实用的软件,所以我们可以在 CentOS 7 系统中采用清华源 IPv6 来安装 epel、ius,只需要简单的配置就行了,以下是配置的方法,要在 root 权限中进行操作。

CentOS 7 系统使用 yum 包管理器,yum 的软件源配置文件存放于 /etc/yum.repos.d/ 目录下。

1.备份并删除所有的 CentOS-*.repo条目,创建 centos.repo 文件:

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras

baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

注意:这里使用了 RPM-GPG-KEY-CENTOS-7 来验证软件源。该文件已默认下载,否则可以从清华源根目录下获取。

执行 yum update 命令更新。

执行 yum install epel-release,这会自动设置新的软件源,也会安装 RPM-GPG-KEY-EPEL-7。

2.备份并移除所有的 epel*.repo 条目,创建 epel.repo文件:

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/epel/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

执行 yum update 命令更新。

3.ius 源需要从 ius 网站下载 rpm 包,直接链接为 https://centos7.iuscommunity.org/ius-release.rpm。要提醒的是,这一步没办法使用 IPv6 免流量。

下载完成后 yum install ius-release.rpm 安装,然后类似于上面的 epel 安装过程,备份移除 ius*.repo 后,创建 ius.repo 文件:

[ius]
name=IUS Community Packages for Enterprise Linux 7 - $basearch
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/ius/stable/CentOS/7/$basearch
#mirrorlist=https://mirrors.iuscommunity.org/mirrorlist?repo=ius-centos7&arch=$basearch&protocol=http
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
[ius-debuginfo]
name=IUS Community Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/ius/stable/CentOS/7/$basearch/debuginfo
#mirrorlist=https://mirrors.iuscommunity.org/mirrorlist?repo=ius-centos7-debuginfo&arch=$basearch&protocol=http
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
[ius-source]
name=IUS Community Packages for Enterprise Linux 7 - $basearch - Source
baseurl=https://mirrors6.tuna.tsinghua.edu.cn/ius/stable/CentOS/7/SRPMS
#mirrorlist=https://mirrors.iuscommunity.org/mirrorlist?repo=ius-centos7-source&arch=source&protocol=http
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY

执行 yum update 命令更新。

至此,安装 epel 与 ius 源就完成了。

标签: 暂无
最后更新:2020年 12月 20日

wangzhe12588

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

归档

  • 2025 年 5 月
  • 2025 年 4 月
  • 2025 年 3 月
  • 2025 年 2 月
  • 2025 年 1 月
  • 2024 年 12 月
  • 2024 年 11 月
  • 2024 年 10 月
  • 2024 年 9 月
  • 2024 年 7 月
  • 2024 年 3 月
  • 2024 年 2 月
  • 2024 年 1 月
  • 2023 年 12 月
  • 2023 年 11 月
  • 2023 年 10 月
  • 2023 年 9 月
  • 2023 年 8 月
  • 2023 年 7 月
  • 2023 年 6 月
  • 2023 年 5 月
  • 2023 年 4 月
  • 2023 年 3 月
  • 2023 年 2 月
  • 2023 年 1 月
  • 2022 年 12 月
  • 2022 年 11 月
  • 2022 年 10 月
  • 2022 年 9 月
  • 2022 年 8 月
  • 2022 年 7 月
  • 2022 年 6 月
  • 2022 年 5 月
  • 2022 年 4 月
  • 2022 年 3 月
  • 2022 年 2 月
  • 2022 年 1 月
  • 2021 年 12 月
  • 2021 年 11 月
  • 2021 年 10 月
  • 2021 年 9 月
  • 2021 年 8 月
  • 2021 年 7 月
  • 2021 年 6 月
  • 2021 年 5 月
  • 2021 年 4 月
  • 2021 年 3 月
  • 2021 年 2 月
  • 2021 年 1 月
  • 2020 年 12 月
  • 2020 年 11 月
  • 2020 年 10 月
  • 2020 年 9 月
  • 2020 年 8 月
  • 2020 年 7 月
  • 2020 年 6 月
  • 2020 年 5 月
  • 2020 年 4 月
  • 2020 年 3 月
  • 2020 年 2 月
  • 2020 年 1 月
  • 2019 年 12 月
  • 2019 年 11 月
  • 2019 年 10 月
  • 2019 年 9 月
  • 2019 年 8 月
  • 2019 年 7 月
  • 2019 年 6 月
  • 2019 年 5 月
  • 2019 年 4 月
  • 2019 年 3 月
  • 2019 年 2 月
  • 2019 年 1 月
  • 2018 年 12 月
  • 2018 年 11 月
  • 2018 年 10 月
  • 2018 年 9 月
  • 2018 年 8 月
  • 2018 年 7 月
  • 2018 年 6 月
  • 2018 年 5 月
  • 2018 年 4 月
  • 2018 年 3 月
  • 2018 年 2 月
  • 2017 年 12 月
  • 2017 年 11 月
  • 2017 年 10 月
  • 2017 年 9 月
  • 2017 年 8 月
  • 2017 年 7 月

分类

  • 主机优惠
  • 其他
  • 域名优惠
  • 学习记录
  • 新手教程
  • 网赚项目
  • 脚本源码
  • 自用主机
  • 资源下载

COPYRIGHT © 2021 Letcloud.cn. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

粤ICP备15031609号-3