juniper srx 更改默認ssh端口


juniper srx系列防火牆默認ssh管理的端口是無法更改的,但要想使用其它端口實現ssh管理,可通過將外網的其它端口映射到環回接口的22端口實現

思路:

1.新建環回接口並配置IP地址

2.將環回接口划入到loopback_zone 這個安全域,並在接口層面開放ssh管理

3.配置端口映射,將外網端口22222映射環回接口端口22上

4.放行untrust到loopbaco_zone ssh的流量

 

實驗配置:

set version 12.1X47-D20.7
set system root-authentication encrypted-password "$1$Cu1r32.n$ivA34PWVEXK9lNKzaf1"
set system services ssh
set interfaces ge-0/0/0 unit 0 family inet address 192.168.2.200/24
set interfaces lo0 unit 0 family inet address 1.1.1.1/24
set security nat destination pool ssh_manage address 1.1.1.1/32
set security nat destination pool ssh_manage address port 22
set security nat destination rule-set ssh_manage from zone untrust
set security nat destination rule-set ssh_manage rule 1 match source-address 0.0.0.0/0
set security nat destination rule-set ssh_manage rule 1 match destination-address 192.168.2.200/32
set security nat destination rule-set ssh_manage rule 1 match destination-port 22222
set security nat destination rule-set ssh_manage rule 1 then destination-nat pool ssh_manage
set security policies from-zone untrust to-zone loopback_zone policy untrust-to-loopback match source-address any
set security policies from-zone untrust to-zone loopback_zone policy untrust-to-loopback match destination-address ssh-manage-address
set security policies from-zone untrust to-zone loopback_zone policy untrust-to-loopback match application junos-ssh
set security policies from-zone untrust to-zone loopback_zone policy untrust-to-loopback then permit
set security zones security-zone untrust interfaces ge-0/0/0.0 host-inbound-traffic system-services ping
set security zones security-zone loopback_zone address-book address ssh-manage-address 1.1.1.1/32
set security zones security-zone loopback_zone interfaces lo0.0 host-inbound-traffic system-services ssh

  

 

version 12.1X47-D20.7;
system {
    root-authentication {
        encrypted-password "$1$Cu1r32.n$ivACpMVEXK9lNKzaf1"; ## SECRET-DATA
    }
    services {
        ssh;
    }
}
interfaces {
    ge-0/0/0 {
        unit 0 {
            family inet {
                address 192.168.2.200/24;
            }
        }
    }
    lo0 {
        unit 0 {
            family inet {
                address 1.1.1.1/24;
            }
        }
    }
}
security {
    nat {
        destination {
            pool ssh_manage {
                address 1.1.1.1/32 port 22;
            }
            rule-set ssh_manage {
                from zone untrust;
                rule 1 {
                    match {
                        source-address 0.0.0.0/0;
                        destination-address 192.168.2.200/32;
                        destination-port {
                            22222;
                        }
                    }
                    then {
                        destination-nat {
                            pool {
                                ssh_manage;
                            }
                        }
                    }
                }
            }
        }
    }
    policies {
        from-zone untrust to-zone loopback_zone {
            policy untrust-to-loopback {
                match {
                    source-address any;
                    destination-address ssh-manage-address;
                    application junos-ssh;
                }
                then {
                    permit;
                }
            }
        }
    }
    zones {
        security-zone untrust {
            interfaces {
                ge-0/0/0.0 {
                    host-inbound-traffic {
                        system-services {
                            ping;
                        }
                    }
                }
            }
        }
        security-zone loopback_zone {
            address-book {
                address ssh-manage-address 1.1.1.1/32;
            }
            interfaces {
                lo0.0 {
                    host-inbound-traffic {
                        system-services {
                            ssh;
                        }
                    }
                }
            }
        }
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM