Skip to content

Networking ex/yadrishi #71

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

Open
wants to merge 4 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
11 changes: 8 additions & 3 deletions projects/bash_networking_security/SOLUTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
Local DNS Server IP
-------------------
<ip-here>
10.0.0.2



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



DHCP IP allocation sys-logs
-------------------
<logs-here>
Jun 15 15:12:25 ip-10-0-0-41 dhclient[355]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x73dd755c)

Jun 15 15:12:25 ip-10-0-0-41 dhclient[355]: DHCPOFFER of 10.0.0.41 from 10.0.0.1

Jun 15 15:12:25 ip-10-0-0-41 dhclient[355]: DHCPREQUEST for 10.0.0.41 on eth0 to 255.255.255.255 port 67 (xid=0x5c75dd73)

Jun 15 15:12:25 ip-10-0-0-41 dhclient[355]: DHCPACK of 10.0.0.41 from 10.0.0.1 (xid=0x73dd755c)
26 changes: 26 additions & 0 deletions projects/bash_networking_security/bastion_connect.sh
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
#!/bin/bash
# Check if the KEY_PATH environment variable is set
if [ -z "$KEY_PATH" ]; then
echo "KEY_PATH env var is expected"
exit 5
fi

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

# If both public and private instance IPs are provided, connect to the private instance via the public instance
if [ -n "$2" ]; then
if ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -i "$KEY_PATH" ubuntu@"$1" stat new_key \> /dev/null 2\>\&1; then
PRIVATE_KEY_FILE="new_key"
else
PRIVATE_KEY_FILE="$KEY_PATH"
fi

ssh -ti "$KEY_PATH" ubuntu@"$1" ssh -i "$PRIVATE_KEY_FILE" ubuntu@"$2" "$3"

# Otherwise, connect to the public instance
else
ssh -i "$KEY_PATH" ubuntu@"$1"
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-west-1"
VPC_ID="vpc-05495054ca5e34202"
PUBLIC_INSTANCE_ID="i-0a6f8bcf45bd9dcf8"
PRIVATE_INSTANCE_ID="i-02d1d83748e76ebf6"