SOURCECODEBD.NET

Live Experience

Configuring a Filter to Block Telnet and SSH Access on JUNIPER

First need to create Allow Rules for IP Block and port. Here I use allowed IP Block 192.168.1.0/24 and allowed port ssh and telent.

#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Allow from address 192.168.1.0/24
#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Allow from protocol tcp

#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Allow from port ssh
#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Allow from port telnet
#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Allow then accept

Now you need to create Block Rule. Here I create block all ssh and telnet without IP Block 192.168.1.0/24.

#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Block from protocol tcp
#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Block from port ssh
#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Block from port telnet
#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Block then log
#set firewall family inet filter Telnet_SSH_Access term Telnet_SSH_Block then reject

#set firewall family inet filter Telnet_SSH_Access term default-term then accept

At last you need to Call this filter to Loopback interface.

#set interfaces lo0 unit 0 family inet filter input Telnet_SSH_Access

 

# show firewall family inet filter Telnet_SSH_Access
term Telnet_SSH_Allow {
    from {
        address {
            192.168.1.0/24;
        }
        protocol tcp;
        port [ telnet ssh ];
    }
    then accept;
}
term Telnet_SSH_Block {
    from {
        protocol tcp;
        port [ telnet ssh ];
    }
    then {
        log;
        reject;
    }
}
term Default_Term {
    then accept;
}
 
 
# show interfaces lo0
unit 0 {
    family inet {
        filter {
            input Telnet_SSH_Access;
        }
    }
}

 

You are here: Home / Firewall & Policy / Block Telnet and SSH Access on JUNIPER