Tuesday, May 28, 2024

Curl


1. What is CURL
2. How to run curl on Windows
3. Hot to run api request with curl : GET, POST, PUT,  DELETE
https://curl.haxx.se


use Curl to get public IP address

curl ipinfo.io/ip

curl ifconfig.me

https://www.youtube.com/watch?v=8f9DfgRGOBo


C:\Users\dkhemr01>curl http://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>


C:\Users\dkhemr01>curl -L http://google.com


TO GET HEADER 
C:\Users\dkhemr01>curl -i http://google.com


C:\Users\dkhemr01>curl -i http://google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Thu, 07 May 2020 00:51:16 GMT
Expires: Sat, 06 Jun 2020 00:51:16 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

C:\Users\dkhemr01>


C:\Users\dkhemr01>curl --head http://google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Thu, 07 May 2020 00:52:35 GMT
Expires: Sat, 06 Jun 2020 00:52:35 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN


C:\Users\dkhemr01>


C:\Users\dkhemr01>curl -verbose http://google.com
* Rebuilt URL to: http://google.com/
*   Trying 172.217.10.78...
* TCP_NODELAY set
* Connected to google.com (172.217.10.78) port 80 (#0)
> GET / HTTP/1.1
> Host: google.com
> User-Agent: curl/7.55.1
> Accept: */*
> Referer: rbose
>
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Thu, 07 May 2020 00:53:20 GMT
< Expires: Sat, 06 Jun 2020 00:53:20 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
* Connection #0 to host google.com left intact

C:\Users\dkhemr01>





curl --insecure -v https://bcbsmastage.medhokapps.com/medhokws/ws/
* About to connect() to bcbsmastage.medhokapps.com port 443 (#0)
*   Trying 10.100.2.219...
^C

 





Friday, May 24, 2024

dig commands

 There are about 40 DNS Resources Records types, but you only have to know 5 of them:

  • A : Address record (IPv4); AAAA for IPv6,
  • CNAME : Canonical Name. Aliases to A or AAAA records,
  • SOA : Start Of Authority: primary nameserver, email of the domain admin, domain serial number, and timers relating to refreshing the zone,
  • MX : Mail eXchange. Points to a mail server,
  • NS : Name Server (a DNS).




Display only the ANSWER section
dig opensuse.org +noall +answer

Activate the short output
dig perdu.com +short

Reverse DNS (get name from IP)
dig -x 208.97.177.124

Use a specific DNS server
dig @8.8.4.4 redhat.com

Display the name resolution path 
dig google.com +trace

Request a zone transfer 
dig microsoft.com AXFR



Dig Command
Dig stands for (Domain Information Groper). Dig is a network administration command-line tool for querying Domain Name System (DNS) name servers. It is useful for verifying and troubleshooting DNS problems and also to perform DNS lookups and displays the answers that are returned from the name server that were queried. dig is part of the BIND domain name server software suite. dig command replaces older tool such as nslookup and the host. dig tool is available in major Linux distributions.

Query Domain “A” Record
# dig yahoo.com; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <<>> yahoo.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<
Above command causes dig to look up the “A” record for the domain name yahoo.com. Dig command reads the /etc/resolv.conf file and querying the DNS servers listed there. The response from the DNS server is what dig displays.

UNDERSTAND THE OUTPUT:
Lines beginning with ; are comments not part of the information.
The first line tell us the version of dig (9.8.2) command.
Next, dig shows the header of the response it received from the DNS server
Next comes the question section, which simply tells us the query, which in this case is a query for the “A” record of yahoo.com. The IN means this is an Internet lookup (in the Internet class).
The answer section tells us that yahoo.com has the IP address 72.30.38.140
Lastly there are some stats about the query. You can turn off these stats using the +nostats option.
Query Domain “A” Record with +short
By default dig is quite verbose. One way to cut down the output is to use the +short option. which will drastically cut the output as shown below.

# dig yahoo.com +short

98.139.183.24
72.30.38.140
98.138.253.109
Note: By default dig looks for the “A” record of the domain specified, but you can specify other records also. The MX or Mail eXchange record tells mail servers how to route the email for the domain. Likewise TTL, SOA etc.

Query MX Record
Querying different types of DNS resource records only.

# dig yahoo.com MX

; <> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <> yahoo.com MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31450
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 24

;; QUESTION SECTION:
;yahoo.com.                     IN      MX

;; ANSWER SECTION:
yahoo.com.              33      IN      MX      1 mta6.am0.yahoodns.net.
yahoo.com.              33      IN      MX      1 mta7.am0.yahoodns.net.
yahoo.com.              33      IN      MX      1 mta5.am0.yahoodns.net.
Query SOA Record
# dig yahoo.com SOA

; <> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <> yahoo.com SOA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2197
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 7, ADDITIONAL: 7

;; QUESTION SECTION:
;yahoo.com.                     IN      SOA

;; ANSWER SECTION:
yahoo.com.              1800    IN      SOA     ns1.yahoo.com. hostmaster.yahoo-inc.com. 2012081409 3600 300 1814400 600
Query TTL Record
# dig yahoo.com TTL

; <> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <> yahoo.com TTL
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56156
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yahoo.com.                     IN      A

;; ANSWER SECTION:
yahoo.com.              3589    IN      A       98.138.253.109
yahoo.com.              3589    IN      A       98.139.183.24
yahoo.com.              3589    IN      A       72.30.38.140
Query only answer section
# dig yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats
;; global options: +cmd
yahoo.com.              3442    IN      A       72.30.38.140
yahoo.com.              3442    IN      A       98.138.253.109
yahoo.com.              3442    IN      A       98.139.183.24
Query ALL DNS Records
# dig yahoo.com ANY +noall +answer

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> yahoo.com ANY +noall +answer
;; global options: +cmd
yahoo.com.              3509    IN      A       72.30.38.140
yahoo.com.              3509    IN      A       98.138.253.109
yahoo.com.              3509    IN      A       98.139.183.24
yahoo.com.              1709    IN      MX      1 mta5.am0.yahoodns.net.
yahoo.com.              1709    IN      MX      1 mta6.am0.yahoodns.net.
yahoo.com.              1709    IN      MX      1 mta7.am0.yahoodns.net.
yahoo.com.              43109   IN      NS      ns2.yahoo.com.
yahoo.com.              43109   IN      NS      ns8.yahoo.com.
yahoo.com.              43109   IN      NS      ns3.yahoo.com.
yahoo.com.              43109   IN      NS      ns1.yahoo.com.
yahoo.com.              43109   IN      NS      ns4.yahoo.com.
yahoo.com.              43109   IN      NS      ns5.yahoo.com.
yahoo.com.              43109   IN      NS      ns6.yahoo.com.
DNS Reverse Look-up
Querying DNS Reverse Look-up. Only display answer section with using +short.

# dig -x 72.30.38.140 +short

ir1.fp.vip.sp2.yahoo.com.
Query Multiple DNS Records
Query multiple website’s DNS specific query viz. MX, NS etc. records.

# dig yahoo.com mx +noall +answer redhat.com ns +noall +answer

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> yahoo.com mx +noall +answer redhat.com ns +noall +answer
;; global options: +cmd
yahoo.com.              1740    IN      MX      1 mta6.am0.yahoodns.net.
yahoo.com.              1740    IN      MX      1 mta7.am0.yahoodns.net.
yahoo.com.              1740    IN      MX      1 mta5.am0.yahoodns.net.
redhat.com.             132     IN      NS      ns1.redhat.com.
redhat.com.             132     IN      NS      ns4.redhat.com.
redhat.com.             132     IN      NS      ns3.redhat.com.
redhat.com.             132     IN      NS      ns2.redhat.com.
Create .digrc file
Create .digrc file under $HOME/.digrc to store default dig options.

# dig yahoo.com
yahoo.com.              3427    IN      A       72.30.38.140
yahoo.com.              3427    IN      A       98.138.253.109
yahoo.com.              3427    IN      A       98.139.183.24
We have store +noall +answer options permanently in .digrc file under user’s home directory. Now, whenever dig command executes it will show only answer section of dig output. No Need to type every-time options like +noall +answer


Upgrade and add Hotfix

 
To upgrade NIOS Software on Trinzic Infoblox 1506:

Setup 

  1. Trinzic Infoblox 1506   LAN1 Interface  default IP = 192.168.1.2  
  2. Set Laptop IP  = 192.168.1.10
  3. Patch Cable between infoblox LAN1 and Laptop RJ45 Interface.
  4. Open Browser and go to https://192.168.1.2

UserID: admin
Password: infoblox   (this is the default password)

  1. Click on "I ACCEPT"  dialog box
  2. Click on Cancel
  3. Click on Upgrade
  4. Browse to your software image  nios-9.0.3-50212-ee11d5834df9-2023-11-22-22-18-34_x86_64.bin where you copy the NIOS image  \Desktop\infoblox
  5. Click on Distribute <Distribute>
  6. Click on Test <Test>
  7. Click on Upgrade <Upgrade>

  • After upgrade - Box will reboot 
  • Do a Ping 192.168.1.2 from your laptop  
  • log back in and verfy version is 9.03


On the righ hand side of screen click  Apply hotfix 
Browse to your software image   Hotfix-Hotfix-9.0.1-49999-eb87c18471a7_9.0.2-50201-4282c85b9e4e_9.0.3-50212-ee11d5834df9-J98462-APPLY-6680b4d9534ae109f31c735a.bin
where you copy the NIOS hotfix image  \Desktop\infoblox

Do not require a reboot


Refresh page .. look for hotfix .. 














Curl

1. What is CURL 2. How to run curl on Windows 3. Hot to run api request with curl : GET, POST, PUT,  DELETE https://curl.haxx.se use C...