Location and Address Automatically
Introduction:
Often when the Nodegrid comes up. it would be great if the NG knows where it is automatically. currently, the user would have to enter the address and the coordinates manually in the System::Preferences.
Requirement:

The Nodegrid needs to be plugged into an ethernet IP network with internet accessible
Steps:
This script will automatically run when the Nodegrid boots up.
1. In the Nodegrid console log in as root "shell sudo su -"
2. Copy the attached script "getNGLoc.sh" to the Nodegrid /etc/init.d folder
3. Go to /etc/init.d folder and change script to be executable "chmod +x getNGLoc.sh"
4. Go to /etc/rc5.d folder
5. Set a soft link to the script "ln -s /etc/init.d/getNGLoc.sh S99getNGLoc.sh"
The system will now run this script when the Nodegrid boots up to update the System::Preference address and coordinates
getNGLoc.sh
- #!/bin/bash
- # wait for the system to comes up first before execution sleep 60 Seconds
- sleep 60
- myLocData=$(curl http://ip-api.com/json?fields=lat,lon)
- longitude=$(echo "$myLocData" | jq -r .lon)
- latitude=$(echo "$myLocData" | jq -r .lat)
- coord="$latitude,$longitude"
- # Fetch geolocation data using ipinfo.io
- location_data=$(curl -s ipinfo.io)
- # Extract city and region (state) from the JSON response
- city=$(echo $location_data | jq -r '.city')
- state=$(echo $location_data | jq -r '.region')
- address="$city,$state"
- tmpFile="/home/admin/outLoc.cli"
- echo "cd /settings/system_preferences/" > $tmpFile
- echo "set address_location=$address" >> $tmpFile
- echo "set coordinates=$coord" >> $tmpFile
- echo "commit" >> $tmpFile
- su - admin -c "cli -f $tmpFile"
- rm $tmpFile
Related Articles
MIB files location in NodeGrid
Introduction: A management information base (MIB) is a database used for managing the entities in a communication network. Most often associated with the Simple Network Management Protocol (SNMP). MIB file are found in NodeGrid by default at ...
Setting a firewall rule to block a single IP address
Nodegrid can act as a firewall to filter traffic. It has six build in chains ( three for ipv4 and three for ipv6 ) - INPUT, OUTPUT and FORWARD Default policy can be assigned for each chain. For each chain, rules can be added deleted and modified. ...
Creating a New Firewall rule to block an Ip address or a network
There are six default chains to configure firewall rules. Three for IPv4 and three for IPv6. These chains are input , output and forward packets. One can make additional user chain if required. For each chain, policy can be created. Configuration ...
PaloAlto VM installation in the Nodegrid
Why have a PaloAlto VM in the Nodegrid Having a PaloAlto VM running in the Nodegrid provides a secured OOB network. Stopping the back-door access into the production network. Not only securing the OOB network, The PaloAlto can also secured the ...
Setting a Firewall Rule to Block a Single IP Address