From d0b42e84074648b8b7e0a62b8975bdfde0413d7f Mon Sep 17 00:00:00 2001 From: williamt1997 Date: Sat, 27 Apr 2024 12:58:29 +0100 Subject: [PATCH] Add files via upload --- appa_host.sh | 165 ++++++++++++++++++++++++++++++++ appb_host.sh | 167 +++++++++++++++++++++++++++++++++ dhcp_servers.sh | 122 ++++++++++++++++++++++++ dns_servers.sh | 228 +++++++++++++++++++++++++++++++++++++++++++++ network_gateway.sh | 140 ++++++++++++++++++++++++++++ 5 files changed, 822 insertions(+) create mode 100644 appa_host.sh create mode 100644 appb_host.sh create mode 100644 dhcp_servers.sh create mode 100644 dns_servers.sh create mode 100644 network_gateway.sh diff --git a/appa_host.sh b/appa_host.sh new file mode 100644 index 0000000..e91c9f5 --- /dev/null +++ b/appa_host.sh @@ -0,0 +1,165 @@ +#! /bin/bash + +my_time=$(date +%H) +txt_col='\033[1;33m' +txt_col_rev='\033[0m' +txt_col_inp='\033[1;31m' +txt_col_titl='\033[1;34m' + +if [ $my_time -lt 12 ]; then + grt_time="Good Morning" +elif [ $my_time -le 18 ]; then + grt_time="Good Afternoon" +elif [ $my_time -le 18 ]; then + grt_time="Good Evening" +else + grt_time="Good Night" +fi + +echo -n -e "${txt_col}" + +while : + +do + + echo -n -e "$grt_time $SUDO_USER, \n\nYou Have Now Entered The App A Host Client Configuration Setup!\n\nPlease Follow These Commands To Create And Troubleshoot The Apps Creation Stage\n\nEnter The Number [1] To: \tConfigure And Create The App \nEnter The Number [2] To: \tRun The App On This Terminal \nEnter The Number [3] To: \tCurl And Communicate With AppB \t\t${txt_col_inp} Alert! AppB Needs To Be Running ${txt_col} \nEnter The Number [4] To: \tTest the gateway and network connection \nEnter The Number [5] To: \tTest the DNS \nEnter The Number [6] To: \tQuit\n\n" + + echo -n -e "${txt_col_inp}" + echo "Please Enter A Number: " + read usr_input + echo -n -e "${txt_col}" + + case $usr_input in + 1) + echo -n -e "${txt_col_titl}" + echo -e "Step 1: Installing NPM Via Yum \n---------------------------------\n" + echo -n -e "${txt_col}" + curl -fsSL https://rpm.nodesource.com/setup_22.x | bash - + yum install -y nodejs + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 2: Installing git Via Yum \n---------------------------------\n" + echo -n -e "${txt_col}" + yum install git + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 3: Cloning App From Github \n---------------------------------\n" + echo -n -e "${txt_col_inp}" + echo -e "Please Note That you Will Require My Github Username And Token\nUsername: williamt1997\nToken: Ask William\n---------------------------------\n" + echo -n -e "${txt_col}" + git clone https://github.com/Enterprise-Automation/trainee-challenge-node-app.git + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 4: Redirecting Into trainee-challenge-node-app \n---------------------------------\n" + echo -n -e "${txt_col}" + cd trainee-challenge-node-app + npm install dotenv + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 5: Adding Firewall To Port 3546 \n---------------------------------\n" + echo -n -e "${txt_col}" + firewall-cmd --permanent --add-port=3546/tcp + firewall-cmd --permanent --add-port=3546/udp + firewall-cmd --reload + sleep 1 + echo -e "Done! \n\n" + ;; + 2) + echo -n -e "${txt_col_titl}" + echo -e "Step 1: Redirecting Into trainee-challenge-node-app \n---------------------------------\n" + echo -n -e "${txt_col}" + cd trainee-challenge-node-app + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 2: Amending The PORT And TARGET_URL \n---------------------------------\n" + echo -n -e "${txt_col}" + export PORT=3546 + export TARGET_URL=https://jsonplaceholder.typicode.com/users + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 3: Starting The Application \n---------------------------------\n" + echo -n -e "${txt_col}" + sleep 1 + echo "5" + sleep 1 + echo "4" + sleep 1 + echo "3" + sleep 1 + echo "2" + sleep 1 + echo "1" + npm start + ;; + 3) + echo -n -e "${txt_col_titl}" + echo "Curling And Communicating With AppA Via 10.8.0.97:3546 \n---------------------------------\n" + echo -n -e "${txt_col}" + curl 10.8.0.97:3546 + sleep 1 + echo -e "Done! \n\n" + ;; + 4) + echo -n -e "${txt_col_titl}" + echo "Peforming Ping to google.com from 10.8.0.30 Gateway 5 times \n---------------------------------\n" + echo -n -e "${txt_col}" + ping -c 5 google.com + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo "Performing traceroute to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + traceroute google.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nPerforming curl to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + curl google.com + sleep 1 + ;; + 5) + echo -n -e "${txt_col_titl}" + echo -e "\n\nVerifying DNS Locally Via Dig \n---------------------------------\n" + echo -n -e "${txt_col}" + dig www.wjrtscrtask.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nVerifying DNS Locally Via nslookup \n---------------------------------\n" + echo -n -e "${txt_col}" + nslookup www.wjrtscrtask.com + sleep 1 + ;; + 6) + echo -n -e "${txt_col_titl}" + echo -e "\n\ngoodbye $SUDO_USER" + echo -n -e "${txt_col_rev}" + break + ;; + *) + echo -n -e "${txt_col_titl}" + echo -e "Unknown Input\n\n" + ;; + + esac + echo -n -e "${txt_col_inp}" + echo -e "\n\nPress Enter To Continue" + read + echo -n -e "${txt_col}" + echo -e "\n\n" + +done diff --git a/appb_host.sh b/appb_host.sh new file mode 100644 index 0000000..73be96c --- /dev/null +++ b/appb_host.sh @@ -0,0 +1,167 @@ +#! /bin/bash + +my_time=$(date +%H) +txt_col='\033[1;33m' +txt_col_rev='\033[0m' +txt_col_inp='\033[1;31m' +txt_col_titl='\033[1;34m' + +if [ $my_time -lt 12 ]; then + grt_time="Good Morning" +elif [ $my_time -le 18 ]; then + grt_time="Good Afternoon" +elif [ $my_time -le 18 ]; then + grt_time="Good Evening" +else + grt_time="Good Night" +fi + +echo -n -e "${txt_col}" + +while : + +do + + echo -n -e "$grt_time $SUDO_USER, \n\nYou Have Now Entered The App B Host Client Configuration Setup!\n\nPlease Follow These Commands To Create And Troubleshoot The Apps Creation Stage\n\nEnter The Number [1] To: \tConfigure And Create The App \nEnter The Number [2] To: \tRun The App On This Terminal \nEnter The Number [3] To: \tCurl And Communicate With AppA \t\t${txt_col_inp} Alert! AppA Needs To Be Running ${txt_col} \nEnter The Number [4] To: \tTest the gateway and network connection \nEnter The Number [5] To: \tTest the DNS \nEnter The Number [6] To: \tQuit\n\n" + + echo -n -e "${txt_col_inp}" + echo "Please Enter A Number: " + read usr_input + echo -n -e "${txt_col}" + + case $usr_input in + 1) + echo -n -e "${txt_col_titl}" + echo -e "Step 1: Installing NPM Via Yum \n---------------------------------\n" + echo -n -e "${txt_col}" + curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash - + yum install -y nodejs + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 2: Installing git Via Yum \n---------------------------------\n" + echo -n -e "${txt_col}" + yum install git + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 3: Cloning App From Github \n---------------------------------\n" + echo -n -e "${txt_col_inp}" + echo -e "Please Note That you Will Require My Github Username And Token\nUsername: williamt1997\nToken: Ask William\n---------------------------------\n" + echo -n -e "${txt_col}" + git clone https://github.com/Enterprise-Automation/trainee-challenge-node-app.git + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 4: Redirecting Into trainee-challenge-node-app \n---------------------------------\n" + echo -n -e "${txt_col}" + cd trainee-challenge-node-app + npm install dotenv + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 5: Adding Firewall To Port 3546 \n---------------------------------\n" + echo -n -e "${txt_col}" + firewall-cmd --permanent --add-port=3546/tcp + firewall-cmd --permanent --add-port=3546/udp + firewall-cmd --reload + sleep 1 + echo -e "Done! \n\n" + ;; + 2) + echo -n -e "${txt_col_titl}" + echo -e "Step 1: Redirecting Into trainee-challenge-node-app \n---------------------------------\n" + echo -n -e "${txt_col}" + cd trainee-challenge-node-app + export PORT=3546 + export TARGET_URL=https://jsonplaceholder.typicode.com/users + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 2: Amending The PORT And TARGET_URL \n---------------------------------\n" + echo -n -e "${txt_col}" + export PORT=3546 + export TARGET_URL=https://jsonplaceholder.typicode.com/users + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 3: Starting The Application \n---------------------------------\n" + echo -n -e "${txt_col}" + sleep 1 + echo "5" + sleep 1 + echo "4" + sleep 1 + echo "3" + sleep 1 + echo "2" + sleep 1 + echo "1" + npm start + ;; + 3) + echo -n -e "${txt_col_titl}" + echo "Curling And Communicating With AppA Via 10.8.0.96:3546 \n---------------------------------\n" + echo -n -e "${txt_col}" + curl 10.8.0.96:3546 + sleep 1 + echo -e "Done! \n\n" + ;; + 4) + echo -n -e "${txt_col_titl}" + echo "Peforming Ping to google.com from 10.8.0.30 Gateway 5 times \n---------------------------------\n" + echo -n -e "${txt_col}" + ping -c 5 google.com + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo "Performing traceroute to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + traceroute google.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nPerforming curl to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + curl google.com + sleep 1 + ;; + 5) + echo -n -e "${txt_col_titl}" + echo -e "\n\nVerifying DNS Locally Via Dig \n---------------------------------\n" + echo -n -e "${txt_col}" + dig www.wjrtscrtask.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nVerifying DNS Locally Via nslookup \n---------------------------------\n" + echo -n -e "${txt_col}" + nslookup www.wjrtscrtask.com + sleep 1 + ;; + 6) + echo -n -e "${txt_col_titl}" + echo -e "\n\ngoodbye $SUDO_USER" + echo -n -e "${txt_col_rev}" + break + ;; + *) + echo -n -e "${txt_col_titl}" + echo -e "Unknown Input\n\n" + ;; + + esac + echo -n -e "${txt_col_inp}" + echo -e "\n\nPress Enter To Continue" + read + echo -n -e "${txt_col}" + echo -e "\n\n" + +done diff --git a/dhcp_servers.sh b/dhcp_servers.sh new file mode 100644 index 0000000..8b3072c --- /dev/null +++ b/dhcp_servers.sh @@ -0,0 +1,122 @@ +#! /bin/bash + +my_time=$(date +%H) +txt_col='\033[1;33m' +txt_col_rev='\033[0m' +txt_col_inp='\033[1;31m' +txt_col_titl='\033[1;34m' + +if [ $my_time -lt 12 ]; then + grt_time="Good Morning" +elif [ $my_time -le 18 ]; then + grt_time="Good Afternoon" +elif [ $my_time -le 18 ]; then + grt_time="Good Evening" +else + grt_time="Good Night" +fi + +echo -n -e "${txt_col}" + +while : + +do + echo -e "$grt_time $SUDO_USER, \n\nYou Have Now Entered The DHCP Server Configuration Setup!\n\nPlease Follow These Commands To Create And Troubleshoot The DHCP Server Creation Stage\n\nEnter The Number [1] To: \t Start The DHCP Creation Process \nEnter The Number [2] To: \t Test The Connectivity With The Gateway \nEnter The Number [3] To: \t Quit\n\n" + + echo -n -e "${txt_col_inp}" + echo "Please Enter A Number: " + read usr_input + echo -n -e "${txt_col}" + + case $usr_input in + 1) + echo -n -e "${txt_col_titl}" + echo -e "Step 1: Installing dhcp-server Via Yum \n---------------------------------\n" + echo -n -e "${txt_col}" + yum install dhcp-server + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 2: Assigning Ens33 With A Static IP Via nscli \n---------------------------------\n" + echo -n -e "${txt_col}" + nmcli connection modify ens33 ipv4.method manual ipv4.addresses 10.8.0.90/16 ipv4.dns "8.8.8.8 8.8.4.4" + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 3: Configuring DHCP Server \n---------------------------------\n" + echo -n -e "${txt_col}" + bash -c 'echo "ddns-update-style none; +authoritative; +subnet 10.8.0.0 netmask 255.255.0.0 { + range 10.8.0.91 10.8.0.141; + option routers 10.8.0.30; + option subnet-mask 255.255.0.0; + option domain-name-servers 10.8.0.29, 8.8.8.8, 8.8.4.4; +}" > /etc/dhcp/dhcpd.conf' + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 4: Starting And Enabling The DHCP Service \n---------------------------------\n" + echo -n -e "${txt_col}" + systemctl enable dhcpd + systemctl start dhcpd + systemctl status dhcpd + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 5: Configuring The DHCP Firewall \n---------------------------------\n" + echo -n -e "${txt_col}" + firewall-cmd --add-service=dhcp --permanent + firewall-cmd --reload + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 6: Connecting DHCP To The Gateway Via ip route for testing \n---------------------------------\n" + echo -n -e "${txt_col}" + ip route add default via 10.8.0.30 dev ens33 + sleep 1 + ;; + 2) + echo -n -e "${txt_col_titl}" + echo "Peforming Ping to google.com from 10.8.0.30 Gateway 5 times \n---------------------------------\n" + echo -n -e "${txt_col}" + ping -c 5 google.com + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo "Performing traceroute to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + traceroute google.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nPerforming curl to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + curl google.com + sleep 1 + ;; + 3) + echo -n -e "${txt_col_titl}" + echo -e "\n\ngoodbye $SUDO_USER" + echo -n -e "${txt_col_rev}" + break + ;; + *) + echo -n -e "${txt_col_titl}" + echo -e "Unknown Input\n\n" + ;; + esac + echo -n -e "${txt_col_inp}" + echo -e "\n\nPress Enter To Continue" + read + echo -n -e "${txt_col}" + echo -e "\n\n" + +done + diff --git a/dns_servers.sh b/dns_servers.sh new file mode 100644 index 0000000..1f204c5 --- /dev/null +++ b/dns_servers.sh @@ -0,0 +1,228 @@ +#! /bin/bash + +my_time=$(date +%H) +txt_col='\033[1;33m' +txt_col_rev='\033[0m' +txt_col_inp='\033[1;31m' +txt_col_titl='\033[1;34m' + +if [ $my_time -lt 12 ]; then + grt_time="Good Morning" +elif [ $my_time -le 18 ]; then + grt_time="Good Afternoon" +elif [ $my_time -le 18 ]; then + grt_time="Good Evening" +else + grt_time="Good Night" +fi + +echo -n -e "${txt_col}" + +while : + +do + + echo -e "$grt_time $SUDO_USER, \n\nYou Have Now Entered The DNS Server Configuration Setup!\n\nPlease Follow These Commands To Create And Troubleshoot The DNS Server Creation Stage\n\nEnter The Number [1] To: \t Start The DNS Creation Process \nEnter The Number [2] To: \t Test The Connectivity With The Gateway\nEnter The Number [3] To: \t Test And Verify The DNS Server And Bind Zones \nEnter The Number [4] To: \t Quit\n\n" + + echo -n -e "${txt_col_inp}" + echo "Please Enter A Number: " + read usr_input + echo -n -e "${txt_col}" + + case $usr_input in + 1) + echo -n -e "${txt_col_titl}" + echo -e "Step 1: Installing bind and bind-utils and Via Yum \n---------------------------------\n" + echo -n -e "${txt_col}" + yum install bind bind-utils + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 2: Assigning Ens33 With A Static IP Via nscli \n---------------------------------\n" + echo -n -e "${txt_col}" + nmcli connection modify ens33 ipv4.method manual ipv4.addresses 10.8.0.29/16 ipv6.method ignore + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 3: Starting The Bind Services \n---------------------------------\n" + echo -n -e "${txt_col}" + systemctl enable named + systemctl start named + systemctl status named + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 4: Amending The Bind Server Configurations \n---------------------------------\n" + echo -n -e "${txt_col}" + bash -c 'echo "options { + directory \"/var/named\"; + dump-file \"/var/named/data/cache_dump.db\"; + statistics-file \"/var/named/data/named_stats.txt\"; + memstatistics-file \"/var/named/data/named_mem_stats.txt\"; + secroots-file \"/var/named/data/named.secroots\"; + recursing-file \"/var/named/data/named.recursing\"; + recursion yes; + dnssec-enable yes; + dnssec-validation yes; + managed-keys-directory \"/var/named/dynamic\"; + pid-file \"/run/named/named.pid\"; + session-keyfile \"/run/named/session.key\"; + include \"/etc/crypto-policies/back-ends/bind.config\"; + allow-query { localhost; 10.8.0.0/16; 8.8.8.8; 8.8.4.4; }; +}; + +logging { + channel default_debug { + file \"data/named.run\"; + severity dynamic; + }; +}; + +zone \".\" IN { + type hint; + file \"named.ca\"; +}; + +zone \"wjrtscrtask.com\" IN { + type master; + file \"wjrtscrtask.com.db\"; + allow-update { none; }; +}; + +zone \"10.8.0.0.in-addr.arpa\" IN { + type master; + file \"10.8.0.0.db\"; + allow-update { none; }; +}; + +include \"/etc/named.rfc1912.zones\"; +include \"/etc/named.root.key\";" > /etc/named.conf' + sleep 1 + echo -e "Done! \n\n" + echo -n -e "${txt_col_titl}" + echo -e "Step 5: Creating The Bind Zone File For wjrtscrtask.com.db \n---------------------------------\n" + echo -n -e "${txt_col}" + bash -c 'echo "\$TTL 86400 +@ IN SOA ns1.wjrtscrtask.com. admin.wjrtscrtask.com. ( +2024042601 +3600 +1800 +604800 +43200 +) +@ IN NS ns1.wjrtscrtask.com. +ns1 IN A 10.8.0.29 +www IN A 10.8.0.30 +ftp IN CNAME www.wjrtscrtask.com." > /var/named/wjrtscrtask.com.db' + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 6: Creating The Bind Zone For 10.8.0.0.db \n---------------------------------\n" + echo -n -e "${txt_col}" + bash -c 'echo "\$TTL 86400 +@ IN SOA ns1.wjrtscrtask.com. admin.wjrtscrtask.com. ( +2024042602 +3600 +1800 +604800 +86400 +) +@ IN NS www.wjrtscrtask.com. +8 IN PTR ns1.wjrtscrtask.com. +100 IN PTR www.wjrtscrtask.com." > /var/named/10.8.0.0.db' + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 7: Restarting The Bind Services \n---------------------------------\n" + echo -n -e "${txt_col}" + systemctl restart named.service + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 8: Configuring The DNS Firewall \n---------------------------------\n" + echo -n -e "${txt_col}" + firewall-cmd --permanent --add-port=53/tcp + firewall-cmd --permanent --add-port=53/udp + firewall-cmd --reload + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 9: Connecting DNS To The Gateway Via ip route for testing \n---------------------------------\n" + echo -n -e "${txt_col}" + ip route add default via 10.8.0.30 dev ens33 + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 10: Amending resolv.conf \n---------------------------------\n" + echo -n -e "${txt_col}" + bash -c 'echo "search dev.easlab.co.uk storage.easlab.co.uk client.easlab.co.uk easlab.co.uk +nameserver 10.8.0.29 +nameserver 8.8.8.8 +nameserver 8.8.4.4" > /etc/resolv.conf' + #search dev.easlab.co.uk storage.easlab.co.uk client.easlab.co.uk easlab.co.uk + #nameserver 10.8.0.1 + sleep 1 + echo -e "Done! \n\n" + ;; + 2) + echo -n -e "${txt_col_titl}" + echo "Peforming Ping to google.com from 10.8.0.30 Gateway 5 times \n---------------------------------\n" + echo -n -e "${txt_col}" + ping -c 5 google.com + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo "Performing traceroute to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + traceroute google.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nPerforming curl to google.com from 10.8.0.30 Gateway \n---------------------------------\n" + echo -n -e "${txt_col}" + curl google.com + sleep 1 + ;; + + 3) + echo -n -e "${txt_col_titl}" + echo -e "\n\nVerifying DNS Locally Via Dig \n---------------------------------\n" + echo -n -e "${txt_col}" + dig www.wjrtscrtask.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nVerifying DNS Locally Via nslookup \n---------------------------------\n" + echo -n -e "${txt_col}" + nslookup www.wjrtscrtask.com + sleep 1 + ;; + + 4) + echo -n -e "${txt_col_titl}" + echo -e "\n\ngoodbye $SUDO_USER" + echo -n -e "${txt_col_rev}" + break + ;; + + *) + echo -n -e "${txt_col_titl}" + echo -e "Unknown Input\n\n" + ;; + esac + echo -n -e "${txt_col_inp}" + echo -e "\n\nPress Enter To Continue" + read + echo -n -e "${txt_col}" + echo -e "\n\n" + +done diff --git a/network_gateway.sh b/network_gateway.sh new file mode 100644 index 0000000..6963524 --- /dev/null +++ b/network_gateway.sh @@ -0,0 +1,140 @@ +#! /bin/bash + +my_time=$(date +%H) +txt_col='\033[1;33m' +txt_col_rev='\033[0m' +txt_col_inp='\033[1;31m' +txt_col_titl='\033[1;34m' + +if [ $my_time -lt 12 ]; then + grt_time="Good Morning" +elif [ $my_time -le 18 ]; then + grt_time="Good Afternoon" +elif [ $my_time -le 18 ]; then + grt_time="Good Evening" +else + grt_time="Good Night" +fi + +echo -n -e "${txt_col}" + + +while : + +do + echo -e "$grt_time $SUDO_USER, \n\nYou Have Now Entered The Network Gateway Configuration Setup!\n\nPlease Follow These Commands To Create And Troubleshoot The Network Creation Stage\n\nEnter The Number [1] To: \t Start The Network, Routing And Gateway Creation Process \nEnter The Number [2] To: \t Check The Network Configurations \nEnter The Number [3] To: \t Check the connectivity to the internet \nEnter The Number [4] To: \t Quit\n\n" + echo -n -e "${txt_col_inp}" + echo "Please Enter A Number: " + read usr_input + echo -n -e "${txt_col}" + + case $usr_input in + 1) + echo -n -e "${txt_col_titl}" + echo -e "Step 1: Creating New Connection [wills_gateway] Via nmcli \n---------------------------------\n" + echo -n -e "${txt_col}" + if nmcli connection show | grep -q "wills_gateway"; then + echo -e "Network Already Exists:\t Deleting Current wills_gateway Network..." + nmcli connection delete wills_gateway + fi + nmcli connection add type ethernet con-name wills_gateway ifname ens35 -- ethernet.mac-address 00:50:56:90:c0:72 + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 2: Modifying wills_gateway via nmcli \n---------------------------------\n" + echo -n -e "${txt_col}" + nmcli connection modify wills_gateway ipv4.method manual ipv4.addresses 10.8.0.30/16 ipv4.dns 8.8.8.8 ipv4.never-default true ipv6.method ignore ipv4.may-fail false + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 3: Connecting wills_gateway via nmcli \n---------------------------------\n" + echo -n -e "${txt_col}" + nmcli connection up wills_gateway + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 4: Flushing Existing Firewall Rules \n---------------------------------\n" + echo -n -e "${txt_col}" + iptables -F + iptables -t nat -F + iptables -t mangle -F + + iptables -X + iptables -t nat -X + iptables -t mangle -X + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 5: Setting Up Forwarding And Masquerading Between Isolated And External Network \n---------------------------------\n" + echo -n -e "${txt_col}" + firewall-cmd --add-masquerade --permanent + firewall-cmd --reload + iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE + iptables -A FORWARD -i wills_gateway -j ACCEPT + sleep 1 + echo -e "Done! \n\n" + + echo -n -e "${txt_col_titl}" + echo -e "Step 6: Enabling Packet Forwarding \n---------------------------------\n" + echo -n -e "${txt_col}" + echo "net.ipv4.ip_forward=1" > /etc/sysctl.conf + sleep 1 + echo -e "Done! \n\n" + ;; + 2) + echo -n -e "${txt_col_titl}" + echo -e "Performing ifconfig \n---------------------------------\n" + echo -n -e "${txt_col}" + ifconfig + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nPerforming ip addr show \n---------------------------------\n" + echo -n -e "${txt_col}" + ip addr show + sleep 1 + ;; + 3) + echo -n -e "${txt_col_titl}" + echo -e "Performing ping to google.com five times \n---------------------------------\n" + echo -n -e "${txt_col}" + ping -c 5 google.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nPerforming traceroute to google.com \n---------------------------------\n" + echo -n -e "${txt_col}" + traceroute google.com + sleep 1 + + echo -n -e "${txt_col_titl}" + echo -e "\n\nPerforming curl to google.com \n---------------------------------\n" + echo -n -e "${txt_col}" + curl google.com + sleep 1 + ;; + 4) + echo -n -e "${txt_col_titl}" + echo -e "\n\ngoodbye $SUDO_USER" + echo -n -e "${txt_col_rev}" + break + ;; + *) + echo -n -e "${txt_col_titl}" + echo -e "Unknown Input\n\n" + ;; + + esac + echo -n -e "${txt_col_inp}" + echo -e "\n\nPress Enter To Continue" + read + echo -n -e "${txt_col}" + echo -e "\n\n" + +done + +