配置一个2-D mesh格(4个节点)的IP和路由

来源:互联网 发布:淘宝网订单号查询 编辑:程序博客网 时间:2024/05/17 04:02

 实验室将要建一个mesh结构的并行计算集群,先用4个节点搭建一个mesh格进行测试。

1.目标网络图:

         A----------B
         |               |
         |               |
         D----------C

2.IP设置:
操作系统:RedHat Enterprise Server 4u4
A节点eth0 IP:192.168.4.2/24
A节点eth1 IP:192.168.1.1/24
B节点eth0 IP:192.168.1.2/24
B节点eth1 IP:192.168.2.1/24
C节点eth0 IP:192.168.2.2/24
C节点eth1 IP:192.168.3.1/24
D节点eth0 IP:192.168.3.2/24
D节点eth1 IP:192.168.4.1/24
关闭防火墙和SELinux服务

3.开启ip_forward功能:
# echo 1 > /proc/sys/net/ipv4/ip_forward
添加到/etc/rc.d/rc.local文件,实现每次开机即时启动ip_forward功能。

4.设置路由表(以A节点为例):
设置第一块网卡eth0的路由表:
# route add -net 192.168.3.0/24 gw 192.168.4.1 dev eth0
设置第二块网卡eth1的路由表:
# route add -net 192.168.2.0/24 gw 192.168.1.2 dev eth1
使用route命令来观察路由情况:
# route
Kernel IP routing table
Destination Gateway  Genmask  Flags Metric Ref Use Iface
192.168.4.0 *  255.255.255.0 U     0      0     0  eth0
192.168.3.0 192.168.4.1 255.255.255.0 UG    0      0     0  eth0
192.168.2.0 192.168.1.2 255.255.255.0 UG    0      0     0  eth1
192.168.1.0 *  255.255.255.0 U     0      0     0  eth1
169.254.0.0 *  255.255.0.0 U     0      0     0  eth1

5.在/etc/hosts中设置主机名:
192.168.1.1 node1
192.168.2.1 node2
192.168.3.1 node3
192.168.4.1 node4

6.重启网络服务:
# service network restart