防火墙高级应用 聚合链路 ipv6配置

Top

NSD ENGINEER DAY04

  1. 案例1:配置IPv6地址
  2. 案例2:配置聚合连接

1 案例1:配置IPv6地址

1.1 问题

本例要求为两个虚拟机 server0、desktop0的接口 eth0 配置下列 IPv6 地址:

  1. server0 上的地址应该是 2003:ac18::305/64
  2. desktop0 上的地址应该是 2003:ac18::306/64
  3. 两个系统必须能与网络 2003:ac18/64 内的系统通信
  4. 地址必须在重启后依旧生效
  5. 两个系统必须保持当前的IPv4地址并能通信

1.2 方案

如何表示一个IP地址:

  • IPv4地址(32位) —— 点 分隔 十进制,比如172.25.0.11
  • IPv6地址(128位)—— 冒号 分隔 十六进制,比如fe80::5054:ff:fe00:b 。前置0可以省略,多个连续的冒号分隔可简写成两个(::)。

针对IPv6目标地址的连通性测试应使用ping6命令工具。

1.3 步骤

实现此案例需要按照如下步骤进行。

步骤一:修改主机server0的网卡eth0的配置

1)确认网卡eth0所属的网络连接名(NAME)

  1. [root@server0 ~]# nmcli connection show
  2. NAME UUID TYPE DEVICE
  3. System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0

2)修改此连接的IPv6地址配置

使用方法一(命令行):

  1. [root@server0 ~]# nmcli connection modify "System eth0" ipv6.method manual ipv6.addresses "2003:ac18::305/64"

或者,使用方法二(图形工具),运行nm-connection-editor,在打开的图形程序界面中双击连接名称System eth0,选择“IPv6 Settings”选项卡(如图-1所示)。

图-1

然后在“Method”处下拉选择“Manual”,再单击中间栏右侧的“Add”按钮添加指定的IPv6地址2003:ac18::305、掩码长度64,勾选底部的“Require IPv6 addressing for this connection to complete”(如图-2所示),最后单击右下角的“Save”保存,并关闭配置窗口。

图-2

3)激活新配置

  1. [root@server0 ~]# nmcli connection up "System eth0"
  2. Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)

4)确认地址已成功设置

执行ifconfig命令可以看到新增加的IPv6地址:

  1. [root@server0 ~]# ifconfig eth0 | grep inet6
  2. eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  3. inet 172.25.0.11 netmask 255.255.255.0 broadcast 172.25.0.255
  4. inet6 2003:ac18::305 prefixlen 64 scopeid 0x0<global>         //确认地址
  5. inet6 fe80::5054:ff:fe00:b prefixlen 64 scopeid 0x20<link>
  6. ether 52:54:00:00:00:0b txqueuelen 1000 (Ethernet)
  7. RX packets 8697 bytes 5617496 (5.3 MiB)
  8. RX errors 0 dropped 0 overruns 0 frame 0
  9. TX packets 6681 bytes 5803117 (5.5 MiB)
  10. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

步骤二:修改主机desktop0的网卡eth0的配置

除了IPv6地址应使用2003:ac18::306以外,其他操作与步骤一相同。

步骤三:测试主机server0、desktop0之间的IPv6地址互连

在server0上,使用ping6命令测试desktop0的IPv6地址,可以正常连通:

  1. [root@server0 ~]# ping6 2003:ac18::306
  2. PING 2003:ac18::306(2003:ac18::306) 56 data bytes
  3. 64 bytes from 2003:ac18::306: icmp_seq=1 ttl=64 time=0.656 ms
  4. 64 bytes from 2003:ac18::306: icmp_seq=2 ttl=64 time=1.33 ms
  5. 64 bytes from 2003:ac18::306: icmp_seq=3 ttl=64 time=1.29 ms
  6. 64 bytes from 2003:ac18::306: icmp_seq=4 ttl=64 time=1.48 ms
  7. .. ..

步骤四:确保配置有正确的静态主机名

避免重启后无法确定本机的主机名,容易引起混淆。

对于主机server0:

  1. [root@server0 ~]# hostnamectl set-hostname server0.example.com
  2. [root@server0 ~]# hostnamectl
  3. Static hostname: server0.example.com
  4. Icon name: computer
  5. .. ..

对于主机desktop0:

  1. [root@desktop0 ~]# hostnamectl set-hostname desktop0.example.com
  2. [root@desktop0 ~]# hostnamectl
  3. Static hostname: desktop0.example.com
  4. Icon name: computer
  5. .. ..

2 案例2:配置聚合连接

2.1 问题

本例要求在两个虚拟机 server0、desktop0之间配置一个链路,要求如下:

  1. 此链路使用接口 eth1 和 eth2
  2. 此链路在其中一个接口失效时仍然能工作
  3. 此链路在 server0 上使用下面的地址 172.16.3.20/255.255.255.0
  4. 此链路在 desktop0 上使用下面的地址 172.16.3.25/255.255.255.0
  5. 此链路在系统重启之后依然保持正常状态

2.2 方案

聚合连接(team):指的是网络连接的捆绑/组队,通过将多个实际网卡(team-slave)整个为逻辑上的单个连接,实现负载均衡、热备份等单块网卡难以完成的特殊功能。

聚合连接的类型:热备份activebackup、轮询负载均衡roundrobin。

定义聚合连接的类型配置时,采用JSON语法标记,主要特点如下:

  • 标记一个对象 —— { 对象 }
  • 每一个对象 —— 名称:值
  • 每一个字符串 —— "字符串"

热备份-聚合连接(activebackup):

  1. { "runner":{ "name":"activebackup" } }

负载均衡-聚合连接(roundrobin):

  1. { "runner":{ "name":"roundrobin" } }

2.3 步骤

除了所配置的IP地址不一样以外,在server0、desktop0主机上的其他操作相同。此处仅列出在server0上的配置过程。

实现此案例需要按照如下步骤进行。

步骤一:准备练习用网卡环境

新建的聚合连接将组合新增加的两块网卡eth1、eth2。

  1. [root@server0 ~]# ifconfig
  2. eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  3. inet 172.25.0.11 netmask 255.255.255.0 broadcast 172.25.0.255
  4. inet6 2003:ac18::305 prefixlen 64 scopeid 0x0<global>
  5. inet6 fe80::5054:ff:fe00:b prefixlen 64 scopeid 0x20<link>
  6. ether 52:54:00:00:00:0b txqueuelen 1000 (Ethernet)
  7. RX packets 172995 bytes 23870389 (22.7 MiB)
  8. RX errors 0 dropped 0 overruns 0 frame 0
  9. TX packets 54053 bytes 34274222 (32.6 MiB)
  10. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  11. eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  12. ether 52:54:00:f8:86:c1 txqueuelen 1000 (Ethernet)
  13. RX packets 104217 bytes 5437855 (5.1 MiB)
  14. RX errors 0 dropped 0 overruns 0 frame 0
  15. TX packets 171 bytes 17171 (16.7 KiB)
  16. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  17. eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  18. ether 52:54:00:38:79:d9 txqueuelen 1000 (Ethernet)
  19. RX packets 104118 bytes 5428927 (5.1 MiB)
  20. RX errors 0 dropped 2060 overruns 0 frame 0
  21. TX packets 0 bytes 0 (0.0 B)
  22. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  23. .. ..

步骤二:创建聚合连接配置

1)新建聚合连接

  1. [root@server0 ~]# nmcli con add con-name team0 type team ifname team0 config '{ "runner":{ "name":"activebackup" } }'
  2. Connection 'team0' (8e61d730-50ff-4a7b-8ca0-fcf5955f6ea7) successfully added.

2)配置IPv4地址

  1. [root@server0 ~]# nmcli con modify team0 ipv4.method manual ipv4.addresses '172.16.3.20/24' connection.autoconnect yes

3)新建聚合成员连接

  1. [root@server0 ~]# nmcli con add con-name team0-p1 type team-slave ifname eth1 master team0
  2. Connection 'team0-p1' (a62d23a2-9a2a-4855-8fbc-60ce1fd43f0b) successfully added.
  3. [root@server0 ~]# nmcli con add con-name team0-p2 type team-slave ifname eth2 master team0
  4. Connection 'team0-p2' (f4d4980e-8123-4840-89ac-1af148cc2eea) successfully added.

步骤三:激活聚合连接

1)激活聚合连接

  1. [root@server0 ~]# nmcli connection up team0
  2. Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

2)激活聚合成员连接

  1. [root@server0 ~]# nmcli connection up team0-p1
  2. Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)
  3. [root@server0 ~]# nmcli connection up team0-p2
  4. Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/10)

步骤四:确认聚合连接状态

1)查看聚合连接地址

  1. [root@server0 ~]# ifconfig team0
  2. team0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  3. inet 172.16.3.20 netmask 255.255.255.0 broadcast 172.16.3.255
  4. inet6 fe80::c80d:efff:fe08:ca57 prefixlen 64 scopeid 0x20<link>
  5. ether ca:0d:ef:08:ca:57 txqueuelen 0 (Ethernet)
  6. RX packets 0 bytes 0 (0.0 B)
  7. RX errors 0 dropped 36 overruns 0 frame 0
  8. TX packets 68 bytes 8695 (8.4 KiB)
  9. TX errors 0 dropped 1 overruns 0 carrier 0 collisions 0

2)查看聚合连接运行状态

  1. [root@server0 ~]# teamdctl team0 state
  2. setup:
  3. runner: activebackup                             //运行模式/类型
  4. ports:
  5. eth1                                             //成员网卡1
  6. link watches:
  7. link summary: up
  8. instance[link_watch_0]:
  9. name: ethtool
  10. link: up
  11. eth2                                             //成员网卡2
  12. link watches:
  13. link summary: up
  14. instance[link_watch_0]:
  15. name: ethtool
  16. link: up
  17. runner:
  18. active port: eth1                                 //当前活动的成员网卡

猜你喜欢

转载自www.cnblogs.com/tiki/p/10783169.html