juniper关闭集群HA

在开启了HA集群后,面板上的HA指示灯会亮绿色或者橙色。

# 注意是在命令行模式下
# 查看集群状态(HA)
root> show chassis cluster status

# 关闭集群并重启
root> set chassis cluster disable reboot

# 重启完成后再查看集群状态
root> show chassis cluster status
error: Chassis cluster is not enabled.

# 进入配置模式
root> configure
Entering configuration mode
[edit]

# 恢复出厂设置
root# load factory-default
warning: activating factory configuration

[edit]

# 设置root密码
root# set system root-authentication plain-text-password
New password:
Retype new password:

[edit]

# 提交
root# commit

juniper srx320升级固件

在格式化U盘的时候格式选项只有exFAT,没有FAT32格式

这是因为所选的分区大于32GB。在默认的Windows格式化功能选项之中,仅允许在32GB或更低的驱动器上使用FAT32文件系统分区。
Windows系统内置的格式化方法(如磁盘管理、文件资源管理器或DiskPart)不允许将32GB以上的硬盘、U盘或SD卡格式化为FAT32文件系统。
可以使用磁盘精灵格式化

# 插上优盘后console控制台会提示分区名

# 挂载到/mnt
root@% mount -t msdosfs /dev/da1s1 /mnt

# 如果是非fat32会提示错误
mount_msdosfs: /dev/da1s1: Invalid argument

# 加载新固件
root> request system software add /mnt/junos-srxsme-22.4R3.25.tgz no-copy no-validate

# 重启
root> request system reboot


root> show version
Model: srx320
Junos: 22.4R3.25
JUNOS Software Release [22.4R3.25]

juniper配置dnat规则并配置安全策略

# 添加pool用于dnat时匹配要转发到的目的地址及端口
root@juniper1# set security nat destination pool kibana address 10.1.2.5 port 5601    
root@juniper1# set security nat destination pool es description "elasticsearch port" address 10.1.2.5 port 9200    

# 查看pool(用问号?提示时会显示出来所有的pool)
root@juniper1# show security nat destination pool kibana 
address 10.1.2.5/32 port 5601;

# 查看dnat规则集,ssh为规则集名
root@juniper1# show security nat destination rule-set ssh    

# 添加具体的规则到某个规则集,es为规则名
root@juniper1# set security nat destination rule-set ssh rule es description "elasticsearch" match destination-address 174.71.214.155     
root@juniper1# set security nat destination rule-set ssh rule es description "elasticsearch" match protocol tcp destination-port 9200    
root@juniper1# set security nat destination rule-set ssh rule es then destination-nat pool es    
root@juniper1# commit 


# 查看所有服务,也就是安全策略中的 services
root@juniper1# show applications 

# 通过问号可以显示所有的服务名
root@juniper1# show applications application ? 

# 通过指定服务名,可以查看此服务的协议端口信息
root@juniper1# show applications application es 

# 创建用户自定义应用服务,服务名叫es
root@juniper1# set applications application es protocol tcp destination-port 9200 description elasticsearch 

# 删除一条自定义服务
root@juniper1# delete applications application es    

# 查看安全策略
root@juniper1# show security policies from-zone untrust to-zone trust 

# 安全策略,往一个已有的策略中添加一个新服务,已有的策略名为 ping,服务名为 es
root@juniper1# set security policies from-zone untrust to-zone trust policy ping match application es

# 或者创建一个新策略
root@juniper1# set security policies from-zone untrust to-zone trust policy es then permit 
root@juniper1# set security policies from-zone untrust to-zone trust policy es match application es

root@juniper1# commit 

关于iptables放行端口无效

之前在iptables配置时都是直接去修改配置文件,然后重启,这次在命令行添加放行端口发现端口还不通。

# 查看当前iptables netfilter表的INPUT链规则

[root@HKSRV2426 ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22 state NEW 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:443 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:5555 state NEW 
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

# 比如放行21端口

[root@HKSRV2426 ~]# iptables -A INPUT  -p tcp --dport 21 -j ACCEPT

这么添加还是无法访问21端口。

# 查看规则其实是在第8条规则下面新增的。

[root@HKSRV2426 ~]# iptables -L -n --line-number
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22 state NEW 
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:443 
3    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:5555 state NEW 
4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
5    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
6    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
8    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 
9    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:21 

第8条规则已经REJECT拒绝包了,下面的规则就不需要再继续匹配了。
所以防火墙规则一般是允许的放在拒绝上面,最后为默认规则才是拒绝或者丢弃。

# 可以通过插入规则解决,比如在规则3上面插入一条

[root@HKSRV2426 ~]# iptables -I INPUT 3 -p tcp --dport 3306 -j ACCEPT

分析原因:
# 查看防火墙配置文件

[root@HKSRV2426 ~]# vi /etc/sysconfig/iptables
略·
-A INPUT -j REJECT --reject-with icmp-host-prohibited

上面这条规则就是上面查询到的第8条规则。

REJECT和DROP基本一样,区别在于它除了阻塞包之外, 还向发送者返回错误信息。

--reject-with # 设置返回错误信息种类 
icmp-host-prohibited # 种类

全部的种类可以通过下面命令查到。

[root@HKSRV2426 ~]# iptables -j REJECT --help
Valid reject types:
icmp-net-unreachable     	ICMP network unreachable
net-unreach              	alias
icmp-host-unreachable    	ICMP host unreachable
host-unreach             	alias
icmp-proto-unreachable   	ICMP protocol unreachable
proto-unreach            	alias
icmp-port-unreachable    	ICMP port unreachable (default)
port-unreach             	alias
icmp-net-prohibited      	ICMP network prohibited
net-prohib               	alias
icmp-host-prohibited     	ICMP host prohibited
host-prohib              	alias
tcp-reset                	TCP RST packet
tcp-rst                  	alias
icmp-admin-prohibited    	ICMP administratively prohibited (*)
admin-prohib             	alias

hillstone防火墙整理的入门命令

支持 命令自动补全 命令缩写  ?号提示/列出当前模式可用的命令  上下查找历史命令  快捷键参考手册

接口模式下:

manage telnet

manage ssh

show interface e0/0   //查看接口信息

命令模式:

hillstone#

在命令模式输入 configure  进入全局模式

全局配置模式:

hillstone(config)#

子模块配置模式:

hillstone(config-if-eth0/0)#

退回到上一级模式:exit  从任何模式退回到执行模式:end

常见命令语法错误信息:

unrecognized command  命令错误、未被接受  [‘rekeɡnaiz]

incomplete command 命令不完整

ambiguous command 参数不完整

设置连接超时:

configure->ssh/console/telnet timeout 1-60 分钟 默认10分钟

恢复默认设置超时时间:configure->no ssh timeout

设置主机名:configure->hostname NQ

添加管理员admin:

hillstone(config)# admin user admin       //添加admin用户并自动进入用户配置模式

hillstone(config-admin)# ?      

  access            Configure admin’s allowed login access

  password          Configure password of administrator

  privilege         Configure privilege of the administrator

  clear             Reset functions

  debug             Debugging functions

  delete            Delete a file

  end               Exit from configure mode

  exec              Perform command operation

  exit              Exit from Admin configuration mode

  help              CLI help

  no                Negate a command or reset to default

  ping              Test network connectivity

  rollback          Rollback to previous saved configuration

  save              Save configuration

  show              Show running system information

  terminal          Configure terminal line parameters

  traceroute        Trace route to destination

  undebug           Negate debugging functions

  unset             Back to the default configuration

hillstone(config-admin)#

hillstone(config-admin)# privilege RXW //设置完全权限

hillstone(config-admin)# password admin123 //设置密码

hillstone(config-admin)# access https      //添加用户以后是无法登陆的,必须为用户添加可登陆类型的权限,否则会提示密码错误。

hillstone(config-admin)# show admin user  //查看系统中的用户

========================================================

Username        Privilege  Console Telnet SSH HTTP HTTPS

——————————————————–

hillstone       RXW        Y       Y      Y   Y    Y

admin           RX         –       –      –   –    –

hillstone(config)# no admin user admin    //全局模式下删除用户

hillstone(config)# show admin user hillstone   //查看用户具体信息

============================================

admin    : hillstone

privilege: RXW

access   : console telnet ssh http https

password : 52/rxu0vP8f9jQ2alM9l7tQyM

hillstone(config)# show admin host  //查看可信主机配置(访问设备的地址段)

=========================================================================

IP range                                Login type

————————————————————————-

0.0.0.0/0                           Telnet  SSH     HTTP    HTTPS  

————————————————————————-

hillstone(config)# admin host {A,B,C,D A,B,C,D | any } {http | https | ssh | telnet | any }

hillstone(config)# ssh port ?  //设置ssh端口

  <1-65535>         SSH service port(22: default, or <1-65535>)

hillstone(config)# ssh port

hillstone(config)# show ssh  //查看设置ssh的信息 或者是show http

SSH server options:

=============================================================

SSH idle timeout is: 20 minute(s)

SSH server listen port is: 57891

SSH server accept connection interval: 2

=============================================================

hillstone(config)#

hillstone(config)# http port ?  //设置http端口

  <1-65535>         HTTP port (1-65535)

hillstone(config)# https po 

hillstone(config)# https port ?  //设置https端口

  <1-65535>         HTTPS port (1-65535)

hillstone(config)# https port

hillstone(config)# show http  //查看http /https信息

HTTP server options:

=============================================================

web(HTTP/HTTPS) idle timeout is: 10 minute(s)

HTTP port is: 65499

HTTPS port is: 65498

HTTPS trust domain is: trust_domain_default

=============================================================

hillstone(config)#

指定https方式访问时使用的pki信任域,当https启动时,https服务器将使用指定的pki信任域中的证书,默认使用trust_domain_default

在登陆https时无法打开,选用http登陆,修改此项试试。