Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking_ex/amit #41

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions projects/bash_networking_security/SOLUTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
Local DNS Server IP
-------------------
<ip-here>
127.0.0.53



Default gateway IP
-------------------
<ip-here>
10.0.0.1



DHCP IP allocation sys-logs
-------------------
<logs-here>
Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x8b932f1f)
Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPOFFER of 10.0.0.171 from 10.0.0.1
Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPREQUEST for 10.0.0.171 on eth0 to 255.255.255.255 port 67 (xid=0x1f2f938b)
Jun 9 07:29:19 ip-10-0-0-171 dhclient[346]: DHCPACK of 10.0.0.171 from 10.0.0.1 (xid=0x8b932f1f)

29 changes: 29 additions & 0 deletions projects/bash_networking_security/bastion_connect.sh
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
#!/bin/bash

# Check if KEY_PATH environment variable is set
if [ -z "$KEY_PATH" ]; then
echo "KEY_PATH env var is expected"
fi

# Check if the public instance IP is provided
if [ -z "$1" ]; then
echo "Please provide bastion IP address"
exit 5
fi

# Set variables
BASTION_IP=$1
PRIVATE_IP=$2
COMMAND=$3

# Connect to the public instance
if [ -z "$PRIVATE_IP" ]; then
ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP"
else
# Connect to the private instance through the public instance
if [ -z "$COMMAND" ]; then
ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" ssh -tt -i new_key ubuntu@"$PRIVATE_IP"
else
# Run a command on the private instance
ssh -i "$KEY_PATH" ubuntu@"$BASTION_IP" ssh -tt -i anew_key ubuntu@"$PRIVATE_IP" "$COMMAND"
fi
fi
8 changes: 4 additions & 4 deletions projects/bash_networking_security/vpc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REGION=""
VPC_ID=""
PUBLIC_INSTANCE_ID=""
PRIVATE_INSTANCE_ID=""
REGION="us-east-1"
VPC_ID="vpc-01dfe779f8f43669a"
PUBLIC_INSTANCE_ID="i-07acba4579a7dbbc3"
PRIVATE_INSTANCE_ID="i-04ef2bb5caef53905"