Sunday, August 16, 2026

Inter VLAN configuration

 



PC configuration

PC0 

IP address: 192.168.10.1

subnet mask: 255.255.255.0

Default gateway: 192.168.10.254

PC1

IP address: 192.168.10.2

subnet mask: 255.255.255.0

Default gateway: 192.168.10.254

PC2

IP address: 192.168.20.1

subnet mask: 255.255.255.0

Default gateway: 192.168.20.254

PC3

IP address: 192.168.20.2

subnet mask: 255.255.255.0

Default gateway: 192.168.20.254

PC4

IP address: 192.168.30.1

subnet mask: 255.255.255.0

Default gateway: 192.168.30.254

PC5

IP address: 192.168.30.2

subnet mask: 255.255.255.0

Default gateway: 192.168.30.254

Switch configuration

Create 3 Vlans. 

Vlan 10(interface range fa0/1-5)

Switch(config)#interface range fastEthernet 0/1-5

Switch(config-if-range)#switchport mode access 

Switch(config-if-range)#switchport access vlan 10

wr

Vlan 20(interface range fa0/6-10) 

Switch(config)#interface range fastEthernet 0/6-10

Switch(config-if-range)#switchport mode access 

Switch(config-if-range)#switchport access vlan 20

wr

Vlan30(interface range fa0/11-15).

Switch(config)#interface range fastEthernet 0/10-15

Switch(config-if-range)#switchport mode access 

Switch(config-if-range)#switchport access vlan 30

wr


Switch#show vlan brief


VLAN Name Status Ports

---- -------------------------------- --------- -------------------------------

1 default active Fa0/16, Fa0/17, Fa0/18, Fa0/19

Fa0/20, Fa0/21, Fa0/22, Fa0/23

Gig0/1, Gig0/2

10 VLAN0010 active Fa0/1, Fa0/2, Fa0/3, Fa0/4

Fa0/5

20 VLAN0020 active Fa0/6, Fa0/7, Fa0/8, Fa0/9

Fa0/10

30 VLAN0030 active Fa0/11, Fa0/12, Fa0/13, Fa0/14

Fa0/15

 Trunk port configuation on switch

Switch(config)#interface fastEthernet 0/24

Switch(config-if)#switchport mode trunk

Switch(config-if)#switchport trunk allowed vlan all

Switch(config-if)#Switch(config-if)#switchport mode trunk

Switch#wr

Router configuration


R1(config)#interface gigabitEthernet 0/0

R1(config-if)#no ip ad

R1(config-if)#no ip address

R1(config-if)#no shu

R1(config-if)#no shutdown 

wr


R1(config)#interface gigabitEthernet 0/0.10

R1(config-subif)#encapsulation dot1Q 10

R1(config-subif)#ip address 192.168.10.254 255.255.255.0

R1(config-subif)#no shutdown

wr


R1(config)#interface gigabitEthernet 0/0.20

R1(config-subif)#encapsulation dot1Q 20

R1(config-subif)#ip address 192.168.20.254 255.255.255.0

R1(config-subif)#no shutdown

wr


R1(config)#interface gigabitEthernet 0/0.30

R1(config-subif)#encapsulation dot1Q 30

R1(config-subif)#ip address 192.168.30.254 255.255.255.0

R1(config-subif)#no shutdown

wr


Ping TEST 


PC0-PC2


Ping 192.168.20.1


C:\>ping 192.168.20.1


Pinging 192.168.20.1 with 32 bytes of data:


Request timed out.

Reply from 192.168.20.1: bytes=32 time<1ms TTL=127

Reply from 192.168.20.1: bytes=32 time<1ms TTL=127

Reply from 192.168.20.1: bytes=32 time=1ms TTL=127


Ping statistics for 192.168.20.1:

Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 1ms, Average = 0ms


PC0-PC4


C:\>ping 192.168.30.1


Pinging 192.168.30.1 with 32 bytes of data:


Request timed out.

Reply from 192.168.30.1: bytes=32 time<1ms TTL=127

Reply from 192.168.30.1: bytes=32 time<1ms TTL=127

Reply from 192.168.30.1: bytes=32 time=1ms TTL=127


Ping statistics for 192.168.30.1:

Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 1ms, Average = 0ms


Now we are able to ping between Vlan 10, Vlan 20 and Vlan 30 IPs.

Wednesday, June 3, 2026

 Python: get weather of cities


import requests

def get_wether(latitude, longitude):

    response = requests.get(f"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&current=temperature_2m")

    data = response.json()

    return data['current']['temperature_2m']


paris_temp = get_wether(48.85, 2.35)

london_temp = get_wether(51.50, -0.12)

tokyo_temp = get_wether(35.68, 139.69)

bangalore_temp = get_wether(12.9629, 77.5775)


print(f"Paris: {paris_temp}°C")

print(f"London: {london_temp}°C")

print(f"Tokyo: {tokyo_temp}°C")

print(f"Bangalore: {bangalore_temp}°C")


Output

Paris: 15.9°C

London: 14.0°C

Tokyo: 22.5°C

Bangalore: 26.2°C

Tuesday, June 2, 2026

 Python program to check licence

age = 18
has_licence = True

can_drive = age > 18 and has_licence

print(can_drive)


output

True

Monday, May 18, 2026

 Python script to add users and assign group

#!/usr/bin/python3

import os


userlist = ["alpha", "beta", "gamma"]


print("Adding users to system")

print("###############################")


#Loop to add user from userlist

for user in userlist:

    exitcode = os.system("id {}".format(user))

    if exitcode != 0:

        print("User {} does not exist. Adding it.".format(user))

        print("#########################################")

        print()

        os.system("useradd {}".format(user))

    else:

        print("User already exist, skipping it.")

        print("#################################")

        print()


# Condition to check if group exists or not, add if not exist.

exitcode = os.system("grep science /etc/group")

if exitcode != 0:

    print("Group science does not exist. Adding it")

    print("#####################################")

    print()

    os.system("groupadd science")

else:

    print("Group already exist, skipping it.")

    print("#############################")

    print()


for user in userlist:

    print("Adding user {} in the science group".format(user))

    print("################################")

    print()

    os.system("usermod -G science {}".format(user))

------------
Output

Adding users to system
###############################
uid=1002(alpha) gid=1002(alpha) groups=1002(alpha),1005(science)
User already exist, skipping it.
#################################

uid=1003(beta) gid=1003(beta) groups=1003(beta),1005(science)
User already exist, skipping it.
#################################

uid=1004(gamma) gid=1004(gamma) groups=1004(gamma),1005(science)
User already exist, skipping it.
#################################

science:x:1005:alpha,beta,gamma
Group already exist, skipping it.
#############################

Adding user alpha in the science group
################################

Adding user beta in the science group
################################

Adding user gamma in the science group
################################

Sunday, May 17, 2026

 Python script to check a file or directory exists or not in linux

vim check-file.py

#!/usr/bin/python3

import os

path = '/tmp/testfile.txt'

if os.path.isdir(path):

    print("It is a directory")

elif os.path.isfile(path):

    print("It is a file.")

else:

    print("file or dir does not exist")

--------------
Grant execute permission to the file

chmod +x check-file.py

Execute the file

./check-file.py

Output

It is a file.

Since I have created this file already, it gave the above output.


Saturday, May 16, 2026

Windows laptop mic volume dropped

My laptop volume suddenly dropped low. Below fix worked for me.

start menu -> settings -> Advanced -> Volume mixer

Select Volume mixer


Click Reset. 


Try to record a video and listen or test your mic.

Tuesday, February 10, 2026

Python

Passing arguments through function using args and kwargs

args take non keyworded arguments, while kwargs take keyworded arguments.

def act1(*args, **kwargs):
print(args)
print(kwargs)


act1(5,10,15,vehicle="Car",job="Doctor",country="India")

Output
(5, 10, 15)
{'vehicle': 'Car', 'job': 'Doctor', 'country': 'India'}


Monday, February 9, 2026

 Python

Built-in functions

msg = "hello world"
print(msg.capitalize())
print(msg.islower())
print(msg.isupper())
IP=("192","168","1","1")
print(".".join(IP))
countries = ["India","Pakistan","UAE","Germany","UK","Australia"]
print(countries)
#append to add item
countries.append("US")
print(countries)
#pop to delete item
countries.pop()
print(countries)
countries.pop(3)
print(countries)

Output
Hello world
True
False
192.168.1.1
['India', 'Pakistan', 'UAE', 'Germany', 'UK', 'Australia']
['India', 'Pakistan', 'UAE', 'Germany', 'UK', 'Australia', 'US']
['India', 'Pakistan', 'UAE', 'Germany', 'UK', 'Australia']
['India', 'Pakistan', 'UAE', 'UK', 'Australia']


 Python

Conditions

IT = ["Tech Support", "Development", "QA"]
Healthcare = ("Doctor", "Nurse", "Attender")

profession = input("Enter your profession:")

if profession in IT:
print(f" {profession} in IT")
elif (profession in Healthcare):
print(f" {profession} in healthcare")
else:
print("Profession not found")

Output
Enter your profession:Doctor
 Doctor in healthcare

Sunday, February 8, 2026

 Python

Dictionary 

Dictionaries are used to store data values in key:value pairs.

#Dictionary
Countries = {"Asia":("India","China", "Pakistan", "Thailand"), "Europe":["Germany","Italy"]}
print(Countries)
print(Countries["Asia"])
print(Countries["Europe"])

Output
{'Asia': ('India', 'China', 'Pakistan', 'Thailand'), 'Europe': ['Germany', 'Italy']}
('India', 'China', 'Pakistan', 'Thailand')
['Germany', 'Italy']

Friday, February 6, 2026

 Python

String indexing        

state = "Kerala is a state located in the southwestern region of India"
print(state[0])
print(state[1])
print(state[2])

print(state[-1])
print(state[-2])

Output
K
e
r
a
i

 Python

Dictionary

Elements in the variable are always in pairs(key: value), curly brackets.

#Dictionary
Dictionary1 = {"Name": "Hafeed", "Age": 36, "Hobbies":["Reading", "Cycling"] }
print(Dictionary1)

Output
{'Name': 'Hafeed', 'Age': 36, 'Hobbies': ['Reading', 'Cycling']}

 Python

Tuple                        

It is a collection data types enclosed in round bracket. 

#Tuple
str1 = "Hello"
num1 = 15
tuple1 = (str1, "India", 10, num1, 3.5)
print(tuple1)  

output
('Hello', 'India', 10, 15, 3.5)          

 Python

List

It is a collection of multi data types enclosed in square brackets.

#List
str1 = "Hello"
num1 = 15
list1 = [str1, "India", 10, num1, 3.5]
print(list1)

output

['Hello', 'India', 10, 15, 3.5]

 Python - Variables

# printing variables
a = 10
b= 20
c = 30
print(a)
print(b)
print(c)            

Output

10
20
30

Wednesday, January 21, 2026

 Shell script - Find number of times a specific alphabet in a word 


Output



 For loop in shell script


Output



 If else in shell script


Output



Shell script tutorial  - set

This script shows the importance of set command.

set -x #debug mode

set - e #exit the script when there is an error

set -o pipefail #(if there is pipe used in script, set -e won't fail, hence we should also use set -o).




Output





Inter VLAN configuration