返回介绍

最佳实践 35:NetScaler 的初始化设置

发布于 2025-04-20 17:44:43 字数 6263 浏览 0 评论 0 收藏

NetScaler 中各种用途的 IP 概念

在配置 NetScaler 的初始化设置之前,首先需要了解 NetScaler 里面的各种用途的 IP 地址。

1)NetScaler IP Address(NSIP):

- 管理 NetScaler。

- HA 心跳。

- Weblog 收集。

- SNMP 监控。

2)Mapped IP Address(MIP):连接后端实际提供业务的服务器。

3)Subnet IP Address(SNIP):用于连接后端实际提供业务的服务器(该服务器所在的网段和 MIP 及 NSIP 都不同)。简单地说,MIP 可以理解为 NetScaler 做反向代理时连接后端实际提供业务的服务器的“最后努力”,SNIP 优先。

4)Virtual Server IP Address(VIP):

- 用户访问网站时解析到此 IP。

- Reverse Network Address Translation(RNAT),用于 NetScaler 后端的服务器访问公网做地址转换。

NetScaler 初始化的步骤

本案例配置 x.y.z.134(主机名 BJ-NS-1)和 x.y.z.135(BJ-NS-2)为双机热备,然后配置基本的网络、账号、NTP、SNMP 等,为后续配置负载均衡做基础准备。

配置出厂后的 NetScaler 大致分以下步骤。

1)将 NetScaler 使用 console 接入到笔记本,默认账号 nsroot/nsroot。

2)设置链路层聚合。使用如下命令:

set interface 0/1 -haMonitor OFF -throughput 0 -bandwidthHigh 0 -bandwidthNormal 0
set interface 1/1 -flowControl RXTX -throughput 0 -bandwidthHigh 0 -bandwidthNormal 0
set interface 1/2 -flowControl RXTX -throughput 0 -bandwidthHigh 0 -bandwidthNormal 0
set interface 1/3 -flowControl RXTX -throughput 0 -bandwidthHigh 0 -bandwidthNormal 0
set interface 1/4 -flowControl RXTX -throughput 0 -bandwidthHigh 0 -bandwidthNormal 0
add channel LA/1 -ifnum 1/1 1/2 -throughput 0 -bandwidthHigh 0 -bandwidthNormal 0 #绑定 1/1 1/2 为聚合端口 LA/1
add channel LA/2 -ifnum 1/3 1/4 -throughput 0 -bandwidthHigh 0 -bandwidthNormal 0 #绑定 1/3 1/4 为聚合端口 LA/2

3)设置 hostname。使用以下命令:

set ns hostName BJ-NS-1

4)设置 NSIP。使用以下命令:

set ns config -IPAddress x.y.z.134 -netmask 255.255.255.128
add route 0.0.0.0 0.0.0.0 x.y.z.129

5)设置 MIP。使用以下命令:

add ns ip 10.3.12.134 255.255.255.0 -type MIP -vServer DISABLED
add route 10.0.0.0 255.0.0.0 10.3.12.1

6)设置 RNAT。使用如下命令:

add ns ip x.y.z.133 255.255.255.128 -type VIP -vServer DISABLED
set rnat 10.0.0.0 255.0.0.0 -natIP x.y.z.133 #10.0.0.0/8 网段的服务器通过该 NetScaler 上网时,对公网服务器上来说看到的源 IP 是 x.y.z.133

7)修改密码。使用以下命令:

set system user nsroot <password>

8)ACL(Access Control List,访问控制列表)是 NetScaler 里面对网络安全性的保护。NSIP 为公网时,经常会有不同来源的登录端口扫描和登录尝试,对 NetScaler 的安全性产生一定的风险。通过设置 ACL,在网络层限制对 NSIP 的访问。使用如下命令:

add ns acl ALLOW2105834626  ALLOW -srcIP 127.0.0.1  -protocol TCP
add ns acl ALLOW2105834627  ALLOW -srcIP 127.0.0.2  -protocol TCP
add ns acl ALLOW1022709603  ALLOW -srcIP 61.172.240.228  -protocol TCP
add ns acl ALLOW1022709728  ALLOW -srcIP 61.172.241.98  -protocol TCP
add ns acl ALLOW1022709750  ALLOW -srcIP 61.172.241.120  -protocol TCP
add ns acl ALLOW1895512673  ALLOW -srcIP 114.80.133.8  -protocol TCP
add ns acl ALLOW1895512785  ALLOW -srcIP 114.80.133.120  -protocol TCP
add ns acl ALLOW1918713719  ALLOW -srcIP x.y.z.134  -protocol TCP
add ns acl ALLOW1918713720  ALLOW -srcIP x.y.z.135  -protocol TCP
add ns acl BlockTcpTo134 DENY -destIP x.y.z.134 -protocol TCP -priority 1000
add ns acl BlockTcpTo135 DENY -destIP x.y.z.135 -protocol TCP -priority 1010
apply ns acls

9)配置 NTP 时间服务器。使用如下命令:

shell #进入到 FreeBSD 操作系统命令行状态
cd /nsconfig
touch rc.netscaler #此文件在 Netscaler 启动时会被执行
echo  '/usr/sbin/ntpd -g -l /var/log/ntpd.log' >> rc.netscaler
echo 'server x.y.z.29 minpoll 6 maxpoll 10' > ntp.conf
echo 'restrict default ignore' > ntp.conf 

注意

完成以上操作后,应重启 NetScaler,重启前先保存配置,具体命令如下:

save ns config

执行 shell,进入到 FreeBSD 操作系统命令行状态:

reboot

重启后使用如下命令检查 NTP 时间服务器的配置是否成功:

> show ntp server
        NTP Server: x.y.z.29
        Minimum Poll Interval: 6 (64secs)
        Maximum Poll Interval: 10 (1024secs)
 Done

10)配置 HA(High Availablity,高可用)。使用如下命令添加 HA 节点:

> add HA node 1 nsip_of_the_other_node

使用如下命令检查当前 HA 的配置和状态:

> show  nodes

如下是一个 HA 配置和状态示例(由 show nodes 命令得出):

1)      Node ID:      0 
        IP:  x.y.z.134 (BJ-NS-1) 
        Node State: UP
        Master State: Primary #该 NetScaler 为主
        Fail-Safe Mode: OFF
        INC State: DISABLED
        Sync State: ENABLED
        Propagation: ENABLED
        Enabled Interfaces : 0/1 LA/1 LA/2
        Disabled Interfaces : None
        HA MON ON Interfaces : LA/1 LA/2
        Interfaces on which heartbeats are not seen : 0/1
        Interfaces causing Partial Failure: None
        SSL Card Status: UP
        Hello Interval: 200 msecs
        Dead Interval: 3 secs
        Node in this Master State for: 1:17:38:7 (days:hrs:min:sec)
2)      Node ID:      1 
        IP:  x.y.z.135 
        Node State: UP
        Master State: Secondary #该 NetScaler 为辅
        Fail-Safe Mode: OFF
        INC State: DISABLED
        Sync State: SUCCESS
        Propagation: ENABLED
        Enabled Interfaces : 0/1 LA/1 LA/2
        Disabled Interfaces : None
        HA MON ON Interfaces : LA/1 LA/2
        Interfaces on which heartbeats are not seen : 0/1
        Interfaces causing Partial Failure: None
        SSL Card Status: UP
 Local node information:
        Critical Interfaces: LA/1 LA/2
 Done 

注意

HA 两台 NetScaler 的 nsroot 密码必须相同。

11)配置 SNMP。使用如下命令:

> add snmp community public GET
>add snmp manager x.y.z.9

在 x.y.z.9 上,测试下 SNMP 的效果,使用如下命令:

# snmpwalk -v 2c -c public x.y.z.134
SNMPv2-MIB::sysDescr.0 = STRING: NetScaler NS9.2: Build 48.6.cl, Date: Sep 23 2010, 08:17:54  
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.5951.1
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (15288400) 1 day, 18:28:04.00
SNMPv2-MIB::sysContact.0 = STRING: WebMaster (default)
SNMPv2-MIB::sysName.0 = STRING: NetScaler
SNMPv2-MIB::sysLocation.0 = STRING: POP (default)
SNMPv2-MIB::sysServices.0 = INTEGER: 72
IF-MIB::ifNumber.0 = INTEGER: 10
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifIndex.4 = INTEGER: 4
IF-MIB::ifIndex.5 = INTEGER: 5
IF-MIB::ifIndex.6 = INTEGER: 6
IF-MIB::ifIndex.7 = INTEGER: 7
IF-MIB::ifIndex.8 = INTEGER: 8
IF-MIB::ifDescr.1 = STRING: 1/3

至此,一台出厂后的 NetScaler 初始化完毕,可以进行负载均衡的配置了。

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。