Technical World

Wednesday, July 30, 2025

Top Tech Picks of Aug 2025

best budget phone: POCO X7 Pro 5G https://amzn.to/3U4uItm best vfm tws: CMF BY NOTHING Buds 2a https://amzn.to/3IWnkOh best vfm powerbank: boAt Energyshroom PB400 Pro 20000mAh https://amzn.to/40KgBgt best vfm charger: Nu Republic Cybotron 45W Dual Port Gan Superfast Wall Charger https://amzn.to/4mjL9y3

Thursday, April 24, 2025

Fortigate config parser

this python script will take fortigate config file as input with name "fortigate_config.conf" and generate the excel file ipsec_tunnels.xlsx with all the ipsec tunnel details. save and run the python sccript below: import re import pandas as pd from pathlib import Path from openpyxl import Workbook from openpyxl.utils import get_column_letter def parse_phase1_config(config_text): """Parse config vpn ipsec phase1-interface section.""" tunnels = {} current_tunnel = None phase1_patterns = { "Interface": r"set interface \"(\S+)\"", "Type": r"set type (\S+)", "Remote Gateway": r"set remote-gw (\S+)", "Local Gateway": r"set local-gw (\S+)", "Proposal": r"set proposal (\S+)", "NAT Traversal": r"set nattraversal (\S+)", "DPD": r"set dpd (\S+)", "DPD Retry Count": r"set dpd-retrycount (\d+)", "DPD Retry Interval": r"set dpd-retryinterval (\d+)", "Mode": r"set mode (\S+)", # For dial-up (main/aggressive) "Mode CFG": r"set mode-cfg (\S+)", # For dial-up IP assignment "Auth User Group": r"set authusrgrp \"(\S+)\"", # For dial-up "Client IP Range": r"set ipv4-name \"(\S+)\"", # For dial-up # Note: PSK Secret omitted for security; add if needed } phase1_section = re.search(r"config vpn ipsec phase1-interface.*?end", config_text, re.DOTALL) if not phase1_section: return tunnels for line in phase1_section.group(0).splitlines(): line = line.strip() if line.startswith("edit "): current_tunnel = line.split('"')[1] tunnels[current_tunnel] = {} elif line.startswith("set ") and current_tunnel: for key, pattern in phase1_patterns.items(): match = re.match(pattern, line) if match: tunnels[current_tunnel][key] = match.group(1) elif line == "next": current_tunnel = None # Set defaults for missing fields for tunnel in tunnels.values(): for key in phase1_patterns: tunnel.setdefault(key, "N/A") return tunnels def parse_phase2_config(config_text): """Parse config vpn ipsec phase2-interface section.""" tunnels = {} current_tunnel = None phase2_patterns = { "Phase 1 Name": r"set phase1name \"(\S+)\"", "Source Subnet": r"set src-subnet (\S+ \S+)", "Destination Subnet": r"set dst-subnet (\S+ \S+)", "Source Port": r"set src-port (\d+)", "Destination Port": r"set dst-port (\d+)", "Protocol": r"set protocol (\d+)", "Proposal": r"set proposal (\S+)" } phase2_section = re.search(r"config vpn ipsec phase2-interface.*?end", config_text, re.DOTALL) if not phase2_section: return tunnels for line in phase2_section.group(0).splitlines(): line = line.strip() if line.startswith("edit "): current_tunnel = line.split('"')[1] tunnels[current_tunnel] = {} elif line.startswith("set ") and current_tunnel: for key, pattern in phase2_patterns.items(): match = re.match(pattern, line) if match: tunnels[current_tunnel][key] = match.group(1) elif line == "next": current_tunnel = None # Set defaults for missing fields for tunnel in tunnels.values(): for key in phase2_patterns: tunnel.setdefault(key, "N/A") return tunnels def parse_firewall_policies(config_text, tunnel_names): """Parse config firewall policy section for policies referencing tunnels.""" policies = {name: [] for name in tunnel_names} current_policy = None policy_patterns = { "Policy ID": r"edit (\d+)", "Source Interface": r"set srcintf \"(\S+)\"", "Destination Interface": r"set dstintf \"(\S+)\"", "Source Address": r"set srcaddr \"(\S+)\"", "Destination Address": r"set dstaddr \"(\S+)\"", "Service": r"set service \"(\S+)\"", "Action": r"set action (\S+)", "Schedule": r"set schedule \"(\S+)\"" } policy_section = re.search(r"config firewall policy.*?end", config_text, re.DOTALL) if not policy_section: return policies for line in policy_section.group(0).splitlines(): line = line.strip() if line.startswith("edit "): current_policy = {"Policy ID": line.split()[1]} elif line.startswith("set ") and current_policy is not None: for key, pattern in policy_patterns.items(): match = re.match(pattern, line) if match: current_policy[key] = match.group(1) elif line == "next" and current_policy: for tunnel_name in tunnel_names: if (current_policy.get("Source Interface") == tunnel_name or current_policy.get("Destination Interface") == tunnel_name): policies[tunnel_name].append(current_policy) current_policy = None return policies def parse_address_objects(config_text): """Parse config firewall address section for address objects (e.g., client IP pools).""" addresses = {} current_address = None address_patterns = { "Type": r"set type (\S+)", "Start IP": r"set start-ip (\S+)", "End IP": r"set end-ip (\S+)", "Subnet": r"set subnet (\S+ \S+)" } address_section = re.search(r"config firewall address.*?end", config_text, re.DOTALL) if not address_section: return addresses for line in address_section.group(0).splitlines(): line = line.strip() if line.startswith("edit "): current_address = line.split('"')[1] addresses[current_address] = {} elif line.startswith("set ") and current_address: for key, pattern in address_patterns.items(): match = re.match(pattern, line) if match: addresses[current_address][key] = match.group(1) elif line == "next": current_address = None return addresses def create_excel_from_configs(phase1_configs, phase2_configs, firewall_policies, address_objects, output_file="ipsec_tunnels.xlsx"): """Create an Excel file from parsed IPsec configurations with an index sheet using openpyxl.""" # Initialize workbook workbook = Workbook() # Remove default sheet default_sheet = workbook.active workbook.remove(default_sheet) # Dictionary to store sheet names for index tunnel_sheets = {} # Create sheets for each tunnel for tunnel_name in phase1_configs: try: rows = [] # Phase 1 Configuration for key, value in phase1_configs[tunnel_name].items(): rows.append({"Category": "Phase 1 Configuration", "Field": key, "Value": value}) # Phase 2 Configuration for phase2_name, phase2_data in phase2_configs.items(): if phase2_data.get("Phase 1 Name") == tunnel_name: for key, value in phase2_data.items(): rows.append({"Category": f"Phase 2: {phase2_name}", "Field": key, "Value": value}) # Firewall Policies for policy in firewall_policies.get(tunnel_name, []): for key, value in policy.items(): rows.append({"Category": "Firewall Policy", "Field": key, "Value": value}) # Address Objects (for dial-up VPNs) client_ip_range = phase1_configs[tunnel_name].get("Client IP Range", "N/A") if client_ip_range != "N/A" and client_ip_range in address_objects: for key, value in address_objects[client_ip_range].items(): rows.append({"Category": "Client IP Range", "Field": key, "Value": value}) # Create DataFrame df = pd.DataFrame(rows) # Create sheet with truncated name sheet_name = tunnel_name[:31] # Excel sheet name limit worksheet = workbook.create_sheet(sheet_name) tunnel_sheets[tunnel_name] = sheet_name # Write DataFrame to worksheet using openpyxl # Write headers headers = df.columns.tolist() for col_idx, header in enumerate(headers, 1): worksheet[f"{get_column_letter(col_idx)}1"] = header # Write data for row_idx, row in enumerate(df.itertuples(index=False), 2): for col_idx, value in enumerate(row, 1): worksheet[f"{get_column_letter(col_idx)}{row_idx}"] = str(value) except Exception as e: print(f"Error processing tunnel {tunnel_name}: {e}") # Create index sheet index_sheet = workbook.create_sheet("Index", 0) # Place at the beginning index_sheet.append(["Tunnel Name", "Link"]) # Add hyperlinks to each tunnel sheet row = 2 for tunnel_name, sheet_name in tunnel_sheets.items(): cell = index_sheet[f"A{row}"] cell.value = tunnel_name link_cell = index_sheet[f"B{row}"] # Escape single quotes in sheet name for Excel HYPERLINK formula escaped_sheet_name = sheet_name.replace("'", "''") link_cell.value = f'=HYPERLINK("#\'{escaped_sheet_name}\'!A1", "{sheet_name}")' row += 1 # Save workbook try: workbook.save(output_file) print(f"Excel file created with index sheet: {output_file}") except Exception as e: print(f"Error saving Excel file: {e}") def main(): # Input file config_file = "fortigate_config.conf" # Replace with your config file output_file = "ipsec_tunnels.xlsx" try: # Read config file with open(config_file, "r") as f: config_text = f.read() # Parse configurations phase1_configs = parse_phase1_config(config_text) phase2_configs = parse_phase2_config(config_text) firewall_policies = parse_firewall_policies(config_text, phase1_configs.keys()) address_objects = parse_address_objects(config_text) if not phase1_configs: print("No IPsec tunnels found in the configuration file.") return # Create Excel with index sheet create_excel_from_configs(phase1_configs, phase2_configs, firewall_policies, address_objects, output_file) except FileNotFoundError: print(f"Config file {config_file} not found.") except Exception as e: print(f"Error: {e}") if __name__ == "__main__": main()

Thursday, March 20, 2025

URL testing script and exe using python

the script/exe and URL test file need to be in same folder for it to work the URL should be in format http://abc.com format only https://drive.google.com/drive/folders/1sUsyqpMoS2VWXlKsoE2QTHDmB7iHN77v?usp=drive_link

Wednesday, February 19, 2025

JIO Plans analysis for 19-Feb-2025

Hi, below is the analysis of some of the plans of jio to choose wisely most affordable for you if you are using home WiFi most of the time you dont need daily data packs.

Monday, February 17, 2025

Best portable HDD

This is the best portable compact value for money and rugged external drive you can find https://amzn.to/4hGq0Mn

best travel adaptor in 2025

This is the best and compact travel adapter you can buy in 2025 rts Universal Travel Adapter https://amzn.to/42Vl1TL

Best TWS in 2025

OnePlus Buds 3 Best in class sound ANC works well for calls Noise cancellaton is the best price is a bit high but it matches premium TWS which cost 5 times more build to last https://amzn.to/3QnelGi

Monday, August 28, 2023

Best Neckband 2023

OnePlus Bullets Wireless Z2 PRO: 1) ANC Active Noise Cancellation 2) 12.4 mm drivers 3) Magnetic buds 4) 28 Hrs Battery Life 5) Fast charging 6) IP55 water resistant 7) Type-C charging 8) Bluetooth version 5.2 for better connectivity Cons: 1) High latency not suitable for gaming. click on image to buy now !!

Monday, August 21, 2023

Best TWS for 2023

Buy Link:

https://amzn.to/3P4OKCb

Pro:

1) can connect to laptop and mobile at same time for seamless connectivity

2) long battery life

3) compact

4) rubber tips for sound isolation and prevents from falling off from ears

5) touch controls

6) amazing sound quality

7) ANC is very much required for TWS for attending calls 

cons:

1) price is bit higher than budget TWS but features offered are like premium TWS


Pro TIP:

Buy the grey or white one for lesser price, the green has a higher price.


Friday, October 15, 2021

Youtube Shortcut Keys:

0 = Restart video
M = Mute
F = Full Screen

J = Rev 10 sec
K= Pause/Play
L = FF 10 sec

Left arrow = rev 5 sec
Right arrow = FF 5 sec
Up arrow = vol up
Down arrow = vol down

Wednesday, September 1, 2021

interview questions

what aws services are you familiar with?
compute
database
network
storage
security
migration and transfer

encryption vs encapsulation what is difference?
Encapsulation means Wrapping or method in which data is encapsuled into a single frame.
and
Encryption is the process of transforming information using an algorithm to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key.

how is data integrity different?
Data integrity refers to the accuracy and consistency (validity) of data over its lifecycle.

DATA INTEGRITY VS. DATA SECURITY
Data security refers to the protection of data against unauthorized access or corruption and is necessary to ensure data integrity.

what is TCP three way handshake?

Syn use to initiate and establish a connection
ACK helps to confirm to the other side that it has received the SYN.
SYN-ACK is a SYN message from local device and ACK of the earlier packet.
FIN is used for terminating a connection.

what info is sent in syn message?
The packets contain a random sequence number (For example, 4321) that indicates the beginning of the sequence numbers for data that the Host X should transmit.

MTU and MSS difference?
MTU is maximum IP packet size of a given link. MSS is Maximum TCP segment size. MTU is used for fragmentation i.e packet larger than MTU is fragmented. But in case of MSS, packet larger than MSS is discarded.
MSS is normally decided in the TCP three-way handshake

why is packet fragmented?
If the packet is too big to travel in between two routing devices, it gets broken into fragments. These fragments look like IP packets in their own right and can traverse the network. They are reassembled when they reach their destination.

what is MF bit?
More fragments (MF = 1 bit) – tells if more fragments ahead of this fragment i.e. if MF = 1, more fragments are ahead of this fragment and if MF = 0, it is the last fragment.

DF bit value on Ethernet.
A DF bit is a bit within the IP header that determines whether a router is allowed to fragment a packet.

while closing TCP connection 4 steps why?
Fin-->Ack-->Fin-->Ack

How IPSEC tunnel is formed.
      Step 1     Interesting traffic initiates the IPSec process—Traffic is deemed interesting when the IPSec security policy configured in the IPSec peers starts the IKE process.
      Step 2     IKE phase one—IKE authenticates IPSec peers and negotiates IKE SAs during this phase, setting up a secure channel for negotiating IPSec SAs in phase two.
      Step 3     IKE phase two—IKE negotiates IPSec SA parameters and sets up matching IPSec SAs in the peers.
      Step 4     Data transfer—Data is transferred between IPSec peers based on the IPSec parameters and keys stored in the SA database.
      Step 5     IPSec tunnel termination—IPSec SAs terminate through deletion or by timing out.

what is NAT-T in vpn? how one device know if there is a NAT device in path? on firewall how will you see there is a NAT device in path in case of NAT-T?
NAT Traversal performs two tasks:
    Detects if both ends support NAT-T
    Detects NAT devices along the transmission path (NAT-Discovery)
Step one occurs in ISAKMP Main Mode messages one and two.  If both devices support NAT-T, then NAT-Discovery is performed in ISKAMP Main Mode messages (packets) three and four.  THe NAT-D payload sent is a hash of the original IP address and port. Devices exchange two NAT-D packets, one with source IP and port, and another with destination IP and port. The receiving device recalculates the hash and compares it with the hash it received; if they don't match a NAT device exists.
If a NAT device has been determined to exist, NAT-T will change the ISAKMP transport with ISAKMP Main Mode messages five and six, at which point all ISAKMP packets change from UDP port 500 to UDP port 4500.  NAT-T encapsulates the Quick Mode (IPsec Phase 2) exchange inside UDP 4500 as well.  After Quick Mode completes data that gets encrypted on the IPsec Security Association is encapsulated inside UDP port 4500 as well, thus providing a port to be used in the PAT device for translation.  

different kinds of NAT, why use source NAT?
static NAT:  a single private IP address is mapped with single Public IP address
dynamic NAT: multiple private IP address are mapped to a pool of public IP address
PAT: This is also known as NAT overload. In this, many local (private) IP addresses can be translated to single public IP address. Port numbers are used to distinguish the traffic

what is a typical 3 tier mobile app architecture, components, security?
presentation tier: user interface
application tier: where data is processed
data tier: where the data associated with the application is stored and managed.

how is DDOS attack known in AWS infra and how to protect.
 AWS Shield Standard is inbuilt and free.DDoS attacks are detected by a system that automatically baselines traffic, identifies anomalies, and, as necessary, creates mitigations

security services aws has against attacks?
AWS Shield is a managed Distributed Denial of Service (DDoS) protection service that safeguards applications running on AWS

how is ddos attack protected in any firewall.
how to mitigate large scale DDOS attack.

layer3 vs layer7 load balancer?
l3
simple, fast, efficient.
more secure as packet is not opened for inspection
uses NAT,only 1 connection betn client and server so can support max TCP connections supported by server cluster.
no smart lb based on content
sticky by nature once connection is establised with 1 server.
l7
smart routing based on URL
caching support
more expensive
required decrypting
less secure as certifiates are stored on LB which can be compromised by attacker
creates multiple connections as its proxy by nature.so you are bounded by the max TCP connection on your load balancer.

what is a http 502 error?

The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server.
    Informational responses (100–199)
    Successful responses (200–299)
    Redirects (300–399)
    Client errors (400–499)
    Server errors (500–599)

situation where you went above and beyond what you are assigned for?

what are the technology you are learning these days?

can you discuss about anytime where you helped your colleague etc?

why do you want to join XYZ company?





Thursday, February 13, 2020

Cisco automation

To login and run multiple commands on cisco switch
1. Download plinkx86 app from internet
2. Browse windows cli to folder where plinkx86 is downloaded
3. Run below command
Plinkx86 -ssh -l USERNAME -pw PASSWORD DEVICE IP "COMMAND" >> output.txt

Create similar command for other cisco commmand and run it one by one to get all the outputs

Note: replace
USERNAME with username to login with eg admin
PASSWORD with user password
DEVICE IP with actual device ip or hostname
COMMAND with cisco command eg: "sh int status"
You can also connect with telnet protocol instead of ssh for older devices

Thursday, September 12, 2019

Ansible Installation and basic commands

To install and setup Ansible on orable VM Box
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible

/etc/ansible/hosts --> ansible host inventory and format
[group name 1]
ip address/hostname
[group name 2]
ip address/hostname

Basic commands
ansible all -m ping
ansible [group name] -m command -a "ls"  --> ping all hosts in group
ansible -i inventory all -m command -a 'iptables -F" --become--ask-become-pass   --> flush iptables rules for all hosts in inventory
ansible all -m setup  -->capture info of all hosts
ansible-doc setup  -->extract facts from documents setup

Monday, April 8, 2019

create f5 ltm virtual pool node using tmsh with input from csv

$inputCSV = "C:\path\ltm_input.csv"
$outputFile = "C:\path\ltm_output.txt"
$i=1
Import-Csv $inputCSV | ForEach-Object {

$policy = $_.policy
if ($i -eq 1)
{
 Add-Content -PassThru $outputFile -Value "modify ltm policy $policy create-draft"
 }
 $i++
}
Import-Csv $inputCSV | ForEach-Object {
 $vipportno = $_.vipportno
 $poolportno1 = $_.poolportno1
 $poolportno2 = $_.poolportno2
 $poolportno3 = $_.poolportno3
 $appname = $_.appname
 $nodeip1 = $_.nodeip1
 $nodeip2 = $_.nodeip2
 $nodeip3 = $_.nodeip3
 $vipip = $_.vipip
 $poolmember1 = $_.nodeip1 + ":"+ $_.poolportno1
 $poolmember2 = $_.nodeip2 + ":"+ $_.poolportno2
 $poolmember3 = $_.nodeip3 + ":"+ $_.poolportno3
 $fullappname = $_.vipip + ":" + $_.vipportno
 $vsname = $_.appname + "-" + $_.vipportno
 $url = $_.url
 $monitor = $_.monitor
 $persistance = $_.persistance
 $policy = $_.policy

 Add-Content -Path $outputFile -Value "create ltm node $nodeip1 fqdn { autopopulate enabled interval ttl name $nodeip1.company.com }"
 Add-Content -Path $outputFile -Value "create ltm node $nodeip2 fqdn { autopopulate enabled interval ttl name $nodeip2.company.com }"
 Add-Content -Path $outputFile -Value "create ltm node $nodeip3 fqdn { autopopulate enabled interval ttl name $nodeip3.company.com }"
 Add-Content -Path $outputFile -Value "create ltm pool pl-$appname members add { $poolmember1 $poolmember2 $poolmember3 } monitor $monitor"
 Add-Content -Path $outputFile -Value "create ltm virtual vs-$vsname destination $fullappname profiles add { wilcard-company company-program-http serverssl-insecure-compatible } pool pl-$appname description $url source-address-translation { pool Internal_SNAT } translate-address enabled vlans-enabled vlans add { External } persist replace-all-with { $persistance } source-address-translation { type snat }"
 Add-Content -Path $outputFile -Value "modify ltm policy /Common/Drafts/$policy rules add { rl-$appname { actions add { 0 { forward select virtual /Common/vs-$vsname } } conditions add { 0 { http-host host values {$url} } } description $url } }"
  }
 Add-Content -PassThru $outputFile -Value "publish ltm policy /Common/Drafts/$policy"
 Add-Content -PassThru $outputFile -Value "save sys config"
create a csv file named ltm-input.csv with columns as per the variables called
vipportno
appname
nodeip1
nodeip2
nodeip3
vipip
poolportno1
poolportno2
poolportno3
policy
persistance
monitor
url




















Thursday, March 28, 2019

create f5 vip pool node from tmsh shell


port-no
app-name
nodeip

rl-app-name                 app-name.company.com

create ltm node nodeip fqdn { autopopulate enabled interval ttl name nodeip }

create ltm pool pl-app-name members add { nodeip:443 } monitor mn-https

create ltm virtual vs-app-name-port-no destination 10.10.10.10:port-no profiles add { wilcard-company company-http serverssl-insecure-compatible } pool pl-app-name description app-name.company.com source-address-translation { pool Internal_SNAT } translate-address enabled vlans-enabled vlans add { External } persist replace-all-with { company-nisp-cookie } source-address-translation { type snat }

TIP: user find/replace to customize the command replacing the bold keywords

Tuesday, November 20, 2018

Address object creation script for fortigate using powershell

1. Create a  csv file named Server.csv with below format with all the address objects to be created
do not change the column names as they are refereed in the script
Assetname IPAddress    


ad-(ip address)(Ip address)


2. Create a notepad file and copy the below test and save it as script.ps1
$inputCSV = "c:\Servers.csv"
$outputFile = "c:\Addresses.txt"
Add-Content -PassThru $outputFile -Value "config firewall address"
Import-Csv $inputCSV | ForEach-Object {
 $Name = $_.Assetname
 $IP = $_.IPAddress
 Add-Content -Path $outputFile -Value "edit $Name"
 Add-Content -Path $outputFile -Value "set subnet $IP 255.255.255.255"
 Add-Content -Path $outputFile -Value "next"
}
Add-Content -PassThru $outputFile -Value "end"


3. Save the Servers.csv and script.ps1 files in C: on machine
4. open power shell and goto c drive and run .\script.ps1





Monday, May 7, 2018

F5 irules

simple permanent redirect
when HTTP_REQUEST {
    if { [HTTP::host] equals "www.xyz.com" } {
        HTTP::respond 301 Location "https://www.xyz.com"
    }
}
to select different ssl profile based on source IP
when CLIENT_ACCEPTED {
  if { [class match [IP::client_addr] equals clientIPList ]} {
    log local0. "MATCH! Profile client-ssl-profile selected for [IP::client_addr]"
    SSL::profile client-ssl-profile
  } else {
    #log local0. "Profile clientssl selected for [IP::client_addr]"
    SSL::profile wilcard-company
  }
}
irule to respond 200 ok without any pool
when HTTP_REQUEST {
if { ( [IP::addr [IP::client_addr] equals 10.0.0.0/8] ) or ( [IP::addr [IP::client_addr] equals 172.16.0.0/12] ) or ( [IP::addr [IP::client_addr] equals 192.168.0.0/16] )} {
HTTP::respond 200 content "Connection" "ok"
}
}
HTTP URI path based redirection for multiple URI
when HTTP_REQUEST {
    if { [HTTP::host] equals "www.company.com" } {
        switch -glob [HTTP::uri] {
            "/about-ie/newsroom/trials-medical-panel*" {
                HTTP::respond 301 Location "https://www.company.com/news-and-stories"
            }
            "/about-/newsroom/customer-improvements-move-next-stage*" {
                HTTP::respond 301 Location "https://www.company.com/news-and-stories"
            }
            "/about/profile/vivek-bhatia*" {
                HTTP::respond 301 Location "https://www.company.com/about-us/our-people/our-group-leadership-teama"
}
URI path redirection to different pool
when HTTP_REQUEST {
if {
[string tolower [HTTP::uri]]  contains "/scim1450" }
{
HTTP::uri [string map -nocase {"/SCIM1450/" "/"} [HTTP::uri]]
pool pl-SCIM1450}
elseif {
[string tolower [HTTP::uri]]  contains "/scim1451" }
{
HTTP::uri [string map -nocase {"/SCIM1451/" "/"} [HTTP::uri]]
pool pl-SCIM1451}
Display maintenance page if all pools members are down or disabled.
when HTTP_REQUEST {
if { [active_members [LB::server pool]] == 0 }
   { set http_reply "You have reached [HTTP::host],


Our website is offline while we make some important updates. Please check back again soon.

 Please contact helpdesk if you continue to experience issues after this maintenance window."
        HTTP::respond 200 content $http_reply

}
}
use maintenance page uploaded to f5 ifile with name maintenance-page
when HTTP_REQUEST {
if {[active_members [LB::server pool]] < 1} {

    switch [HTTP::uri] {
          default {HTTP::respond 200 content [ifile get "maintenance-page.html"] }
        }
    }
}

Friday, March 9, 2018

F5 UCS backup to FTP script

# BIG-IP Backup Script
#
# This script automates LTM Backups and saves the files with hostname and date
# off to an FTP server
# version 1.0
# Author: Yusuf
# Original Date: 03/09/18
#save this file to /etc/cron.daily for daily backup
#remember to change permission to read/write/execute using
#chmod 777
tmsh save /sys ucs /var/tmp/BIG-IP_backup
export a='date +"%y%m%d"'
export aa=$HOSTNAME.$a.ucs
export b=/var/tmp/$aa
mv /var/tmp/BIG-IP_backup.ucs $b
tar -cf /var/tmp/certs.tar /config/ssl
export ff=$HOSTNAME.$a.certs.tar
export f=/var/tmp/$ff
mv /var/tmp/certs.tar $f
export c=$HOSTNAME.$a.crontab
export cc=/var/tmp/$c
cp /etc/crontab $cc
export MName=
export Log=/var/tmp/log.bigip
export UserName=
export UserPassword=
export Machine1f2=$aa
export Machine1f3=$c
export Machine1f4=$ff
ftp -nvd ${MName} <&2 > ${Log}
user ${UserName} ${UserPassword}
bin
put ${b} ${Machine1f2}
put ${cc} ${Machine1f3}
put ${f} ${Machine1f4}
quit
END
rm -f ${b}
rm -f ${cc}
rm -f ${f}
RTN_CODE=$?
exit $RTN_CODE