张小烦 发表于 2017-3-1 00:51:58

SuSE配置IPv6

YaSTw目前不支持正确配置IPv6,SLES < = 10.2 需要手动配置这些。   
如果你不是非常精通在SuSE改变网络配置文件,那么这可能有点复杂。
1.首先,我们将确定正确的网卡的配置文件:
sles10.2:~ # yast2 lan show id=1 2>&1 | sed -n '/^Device/{ s/.*: //p; }'
eth-id-00:30:48:9d:35:f9
sles10.2:~ #
As we can see, this name is just "eth-id-$mac-address".
sles10.2:~ # echo eth-id-`ip link show dev eth1 | awk '/link/{ print $2 }'`
eth-id-00:30:48:9d:35:f9
sles10.2:~ #
这个配置文件位于/etc/sysconfig/network路径。我们将只需要备份这个文件然后编辑它。
2.编辑公共网络配置文件
(这是不推荐。通过YaST编辑这些文件应该被执行。当YaST完全支持IPv6然后这些指令将被更新)
NETCONFDIR=/etc/sysconfig/network
IFCFG=${NETCONFDIR}/eth-id-`ip link show dev eth1 | awk '/link/{ print $2 }'`
ROUTECFG=${NETCONFDIR}/routes
BACKUPDIR=/root/.backups/
mkdir -p "${BACKUPDIR}"
cp -vp ${IFCFG} ${BACKUPDIR}
vi ${IFCFG}
现在,我们将看到一个配置类似如下:
BOOTPROTO='static'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR='REDACTED'
MTU=''
NAME=''
NETMASK='255.255.255.224'
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
UNIQUE='JNkJ.s7B47FFEkd0'
USERCONTROL='no'
_nm_name='bus-pci-0000:0e:00.0'
我们需要简单的三行附加到这个配置文件,使用IPv6的信息。
如果你不习惯VI,那么这两个命令之后会让你在文件的末尾插入模式。
Shift+G
如果你已经有一个然后LABEL_0相应地增加。eg: LABEL_1='1', LABEL_2='2', LABEL_23='23', et al.
----- SNIP -----
LABEL_0='0'
IPADDR_0='2001:0db8:0000:0000:0000:0000:0000:0002'
PREFIXLEN_0='64'
--- END SNIP ---
3.现在我们需要添加默认的ipv6路由。
cp -vp ${ROUTECFG} ${BACKUPDIR}
C=`set +o | grep noclobber`
set -o noclobber
echo "default 2001:0db8:0000:0000:0000:0000:0000:0001 - -" >> ${ROUTECFG}
eval $C
1)启用 IPv6
After configuring your IP and Route you should be able to simply restart networking in order to enable IPv6 on your server. Please note that you may see errors appear, but for the most part they can be ignored. If you choose not to completely restart networking then you will need to insure that IPv6 is enabled from yast2 lan, entering into the public network configuration, going to Advanced, then IPv6, and insuring that Enable IPv6 is selected.sles10.2:~ # service network restart
Shutting down network interfaces:
eth0      device: Intel Corporation 82573E Gigabit Ethernet Controller (Copper) (rev 03)
eth0      configuration: eth-id-00:30:48:9d:35:f8               done
eth1      device: Intel Corporation 82573L Gigabit Ethernet Controller
eth1      configuration: eth-id-00:30:48:9d:35:f9               done
Shutting down service network.............done
Hint: you may set mandatory devices in /etc/sysconfig/network/config
Setting up network interfaces:
lo
lo      IP address: 127.0.0.1/8
Checking for network time protocol daemon (NTPD):                     done
eth0      device: Intel Corporation 82573E Gigabit Ethernet Controller (Copper) (rev 03)
eth0      configuration: eth-id-00:30:48:9d:35:f8
eth0      IP address: REDACTED
Warning: Could not set up default route via interface
Command ip route replace to default via redacted returned:
. RTNETLINK answers: Network is unreachable
Configuration line: default REDACTED - -
This needs NOT to be AN ERROR if you set up multiple interfaces.
See man 5 routes how to avoid this warning.
Error while executing:
Command 'ip route replace to default via 2001:0db8:0000:0000:0000:0000:0000:0001' returned:
RTNETLINK answers: No route to host   Configuration line: default REDACTED - -Checking for network time protocol daemon (NTPD):                     done
eth1      device: Intel Corporation 82573L Gigabit Ethernet Controller
eth1      configuration: eth-id-00:30:48:9d:35:f9
eth1      IP address: REDACTED/27
eth1:0    IP address: 2001:db8::2/64
Checking for network time protocol daemon (NTPD):                     done
Setting up service network..............done
sles10.2:~ #
2)测试
现在,我们可以检查我们的IP和IPv6路由配置:
sles10.2:~ # ip -6 address show dev eth1
3: eth1:mtu 1500 qlen 1000
inet6 2001:0db8::2/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::230:48ff:fe9d:35f9/64 scope link
valid_lft forever preferred_lft forever
sles10.2:~ #
sles10.2:~ # ip -6 route show dev eth1
2001:0db8::/64metric 256expires 21334149sec mtu 1500 advmss 1440 fragtimeout 4294967295
fe80::/64metric 256expires 21334149sec mtu 1500 advmss 1440 fragtimeout 4294967295
ff00::/8metric 256expires 21334149sec mtu 1500 advmss 1440 fragtimeout 4294967295
default via 2001:0db8::1metric 1024expires 21334149sec mtu 1500 advmss 1440 fragtimeout 4294967295
sles10.2:~ #
sles10.2:~ # ping6 -n -c2 softlayer.com
PING softlayer.com(2607:f0d0:1000:11:1::2) 56 data bytes
64 bytes from 2607:f0d0:1000:11:1::2: icmp_seq=1 ttl=58 time=0.626 ms
64 bytes from 2607:f0d0:1000:11:1::2: icmp_seq=2 ttl=58 time=0.862 ms
--- softlayer.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.626/0.744/0.862/0.118 ms
sles10.2:~ #
sles10.2:~ # traceroute -6 softlayer.com
traceroute to softlayer.com (2607:f0d0:1000:11:1::2), 30 hops max, 40 byte packets
12001:0db8::1 (2001:0db8::1)0.497 ms   0.253 ms   0.342 ms
22607.f0d0.1000.0001.0000.0000.0000.0075-static.v6reverse.softlayer.com (2607:f0d0:1000:1::75)0.377 ms   0.441 ms   0.270 ms
32607.f0d0.1000.0001.0000.0000.0007.0036-static.v6reverse.softlayer.com (2607:f0d0:1000:1::7:36)0.423 ms   0.490 ms   0.326 ms
4softlayer.com (2607:f0d0:1000:11:1::2)0.712 ms   0.623 ms   0.785 ms
sles10.2:~ #
sles10.2:~ # traceroute -6 www.kame.net
traceroute to www.kame.net (2001:200:0:8002:203:47ff:fea5:3085), 30 hops max, 40 byte packets
12001:0db8::1 (2001:0db8::1)0.410 ms   0.277 ms   0.345 ms
22607.f0d0.1000.0001.0000.0000.0000.0081-static.v6reverse.softlayer.com (2607:f0d0:1000:1::81)0.406 ms   0.367 ms   0.268 ms
32607.f0d0.1000.0001.0000.0000.0000.0005-static.v6reverse.softlayer.com (2607:f0d0:1000:1::5)0.578 ms   0.370 ms   0.425 ms
4xe-4-3.r03.dllstx09.us.bb.gin.ntt.net (2001:418:0:5000::59)34.328 ms   34.422 ms   34.260 ms
5ae-1.r20.dllstx09.us.bb.gin.ntt.net (2001:418:0:2000::201)39.744 ms   39.741 ms   39.735 ms
6as-2.r20.lsanca03.us.bb.gin.ntt.net (2001:418:0:2000::295)85.509 ms   85.551 ms   85.594 ms
7as-2.r20.osakjp01.jp.bb.gin.ntt.net (2001:218:0:2000::ae)177.650 ms   195.987 ms   214.793 ms
8ae-4.r20.tokyjp01.jp.bb.gin.ntt.net (2001:218:0:2000::d9)219.288 ms   214.430 ms   214.424 ms
9xe-3-2.a15.tokyjp01.jp.ra.gin.ntt.net (2001:218:0:6000::10e)236.665 ms   222.689 ms   217.890 ms
10ge-8-2.a15.tokyjp01.jp.ra.gin.ntt.net (2001:218:2000:5000::82)199.872 ms   218.588 ms   204.553 ms
11ve44.foundry6.otemachi.wide.ad.jp (2001:200:0:10::141)204.546 ms   200.098 ms   201.040 ms
12ve42.foundry4.nezu.wide.ad.jp (2001:200:0:11::66)200.316 ms   182.311 ms   200.278 ms
13ve45.nec2.yagami.wide.ad.jp (2001:200:0:12::74)221.333 ms   203.220 ms   184.544 ms
142001:200:0:8400::10:1 (2001:200:0:8400::10:1)200.916 ms * *
15orange.kame.net (2001:200:0:8002:203:47ff:fea5:3085)186.721 ms   182.198 ms   219.335 ms
sles10.2:~ #
3)添加额外的IPv6 IP
你只需要做上面一样的步骤,不用路由配置和递增的别名。
eg:
LABEL_1='1'
IPADDR_1='2001:0db8:0000:0000:0000:0000:0000:0003'
PREFIXLEN_1='64'
LABEL_2='2'
IPADDR_2='2001:0db8:0000:0000:0000:0000:0000:0004'
PREFIXLEN_2='64'
LABEL_3='3'
IPADDR_3='2001:0db8:0000:0000:0000:0000:0000:0005'
PREFIXLEN_3='64'
4.高级设置
These are the actual commands to setup ipv6 without a configuration. These changes will not stick across reboots unless the configuration files are updated accordingly.
1)添加1个IP
sles10.2:~ # ip -6 address add 2001:0db8:0000:0000:0000:0000:0000:0005/64 dev eth1
2)添加一个路由
MUST HAVE AN IP BEFORE A ROUTE CAN BE ADDED
sles10.2:~ # ip -6 route add default via 2001:0db8:0000:0000:0000:0000:0000:0001 dev eth1
3)检查你的缓存
similar to ipv4 arp
sles10.2:~ # ip -6 neighbor show
2001:0db8::1 dev eth1 lladdr 00:1f:27:40:4c:00 router REACHABLE
4)检查你的ipv6地址
sles10.2:~ # ip -6 address show dev eth1
3: eth1: mtu 1500 qlen 1000
inet6 2001:0db8::2/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::230:48ff:fe9d:35f9/64 scope link
valid_lft forever preferred_lft forever
5)检查你的IPv6路由表
sles10.2:~ # ip -6 route show
2001:0db8::/64 dev eth1 metric 256 expires 21334263sec mtu 1500 advmss 1440 fragtimeout 4294967295
fe80::/64 dev eth0 metric 256 expires 21332384sec mtu 1500 advmss 1440 fragtimeout 4294967295
fe80::/64 dev eth1 metric 256 expires 21334241sec mtu 1500 advmss 1440 fragtimeout 4294967295
ff00::/8 dev eth0 metric 256 expires 21332384sec mtu 1500 advmss 1440 fragtimeout 4294967295
ff00::/8 dev eth1 metric 256 expires 21334241sec mtu 1500 advmss 1440 fragtimeout 4294967295
default via 2001:0db8::1 dev eth1 metric 1024 expires 21334263sec mtu 1500 advmss 1440 fragtimeout 4294967295
6)刷新你的路由表
ip -6 route flush dev eth1
刷新的你ipv6的IP
Be warned: This will also remove your local ipv6 IP.
ip -6 address flush dev eth1
7)替换文本。
Attached is suse-ipv6control.sh which can be used to automate the addition of single IPv6 IP addresses.
Example Usage:
sles10.2:~ # ip -6 a show dev eth1
3: eth1:mtu 1500 qlen 1000
inet6 fe80::230:48ff:fe9d:35f9/64 scope link
valid_lft forever preferred_lft forever
sles10.2:~ # ip -6 r show dev eth1
fe80::/64metric 256expires 21334349sec mtu 1500 advmss 1440 fragtimeout 4294967295
ff00::/8metric 256expires 21334349sec mtu 1500 advmss 1440 fragtimeout 4294967295
sles10.2:~ # bash suse-ipv6control.sh 2001:0db8::2
sles10.2:~ # ip -6 a show dev eth1
3: eth1:mtu 1500 qlen 1000
inet6 2001:0db8::2/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::230:48ff:fe9d:35f9/64 scope link
valid_lft forever preferred_lft forever
sles10.2:~ # ip -6 r show dev eth1
2001:0db8::/64metric 256expires 21334363sec mtu 1500 advmss 1440 fragtimeout 4294967295
fe80::/64metric 256expires 21334302sec mtu 1500 advmss 1440 fragtimeout 4294967295
ff00::/8metric 256expires 21334302sec mtu 1500 advmss 1440 fragtimeout 4294967295
default via 2001:0db8::1metric 1024expires 21334363sec mtu 1500 advmss 1440 fragtimeout 4294967295
sles10.2:~ # grep _0 /etc/sysconfig/network/ifcfg-eth-id-00\:30\:48\:9d\:35\:f9
LABEL_0='0'
IPADDR_0='2001:0db8::2'
PREFIXLEN_0='64'
sles10.2:~ # tail -n1 /etc/sysconfig/network/routes
default 2001:0db8::1 - -
sles10.2:~ #
页: [1]
查看完整版本: SuSE配置IPv6