Output only the IP addresses of the online machines with nmapDoing nmap on a networkWhat's the most effective...

Java guess the number

My coworkers think I had a long honeymoon. Actually I was diagnosed with cancer. How do I talk about it?

Select items in a list that contain criteria

Company did not petition for visa in a timely manner. Is asking me to work from overseas, but wants me to take a paycut

When writing an error prompt, should we end the sentence with a exclamation mark or a dot?

Should I "tell" my exposition or give it through dialogue?

After the loss of Challenger, why weren’t Galileo and Ulysses launched by Centaurs on expendable boosters?

Bent spoke design wheels — feasible?

Is it possible for people to live in the eye of a permanent hypercane?

Russian equivalent of the French expression "broyer du noir"

Did Darth Vader wear the same suit for 20+ years?

Incremental Ranges!

Approximate solutions to non polynomial equations

How to skip replacing first occurrence of a character in each line?

When conversion from Integer to Single may lose precision

Can characters escape from Death House through this method?

Are "living" organ banks practical?

How hard would it be to convert a glider into an powered electric aircraft?

SF novella separating the dumb majority from the intelligent part of mankind

Can an Eldritch Knight use Action Surge and thus Arcane Charge even when surprised?

How can you travel on a trans-Siberian train when it is fully booked?

What's the correct term for a waitress in the Middle Ages?

Payment instructions from HomeAway look fishy to me

Secure offsite backup, even in the case of hacker root access



Output only the IP addresses of the online machines with nmap


Doing nmap on a networkWhat's the most effective way to detect nmap scans?Resolve Host's IP on VMCan nmap display only hosts with specific ports open?How to tell stateful vs stateless firewall with nmap ACK scanCheck list of IPs against routing table and show which gw/dev each is accessed throughTips for Troubleshooting Remote IMAP/SMTP Host Connection with OPENSSL and NMAPDifferent Outputs for MX Toolbox Port Scan and nmapDoes `nmap -p0-65535 0.0.0.0` scan all the IP addresses on the local host?What's the NSE of nmap?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







17















I know how to use nmap to find the list of hosts that are currently online. What I would like to do is get a list of just their IP addresses, now it displays extra information such as



Nmap scan report for 192.168.x.x' and 'Host is up (0.12s latency).


What I would like is to be able to run an nmap command, get a text document of the IP addresses that are currently online.



Is this at all possible?










share|improve this question















migrated from serverfault.com Jan 28 '15 at 22:04


This question came from our site for system and network administrators.

























    17















    I know how to use nmap to find the list of hosts that are currently online. What I would like to do is get a list of just their IP addresses, now it displays extra information such as



    Nmap scan report for 192.168.x.x' and 'Host is up (0.12s latency).


    What I would like is to be able to run an nmap command, get a text document of the IP addresses that are currently online.



    Is this at all possible?










    share|improve this question















    migrated from serverfault.com Jan 28 '15 at 22:04


    This question came from our site for system and network administrators.





















      17












      17








      17


      9






      I know how to use nmap to find the list of hosts that are currently online. What I would like to do is get a list of just their IP addresses, now it displays extra information such as



      Nmap scan report for 192.168.x.x' and 'Host is up (0.12s latency).


      What I would like is to be able to run an nmap command, get a text document of the IP addresses that are currently online.



      Is this at all possible?










      share|improve this question
















      I know how to use nmap to find the list of hosts that are currently online. What I would like to do is get a list of just their IP addresses, now it displays extra information such as



      Nmap scan report for 192.168.x.x' and 'Host is up (0.12s latency).


      What I would like is to be able to run an nmap command, get a text document of the IP addresses that are currently online.



      Is this at all possible?







      ip nmap






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 28 '15 at 22:24









      jasonwryan

      51.5k14136190




      51.5k14136190










      asked Jan 28 '15 at 10:37







      Josh











      migrated from serverfault.com Jan 28 '15 at 22:04


      This question came from our site for system and network administrators.









      migrated from serverfault.com Jan 28 '15 at 22:04


      This question came from our site for system and network administrators.
























          3 Answers
          3






          active

          oldest

          votes


















          31














          This is a common one:



          nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up$/{print $2}'


          Quick rundown of options and commands:





          • -n turns off reverse name resolution, since you just want IP addresses. On a local LAN this is probably the slowest step, too, so you get a good speed boost.


          • -sn means "Don't do a port scan." It's the same as the older, deprecated -sP with the mnemonic "ping scan."


          • -oG - sends "grepable" output to stdout, which gets piped to awk.


          • /Up$/ selects only lines which end with "Up", representing hosts that are online.


          • {print $2} prints the second whitespace-separated field, which is the IP address.






          share|improve this answer
























          • Why have the $ after /Up? I found that the command nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up/{print $2}' provides the same results.

            – Michael
            Mar 5 at 19:37






          • 1





            @Michael It's just an extra level of safety to ensure we don't print garbage in case something else contains the string "Up". That way it works even if you run it against grepable output in a file from a different type of scan like -sV which can contain unpredictable strings from network service banners.

            – bonsaiviking
            Mar 5 at 20:26



















          2














          You could pipe it to awk:



          nmap -sP 192.168.1.0/24 | awk '/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'
          192.168.1.1
          192.168.1.10
          192.168.1.20
          192.168.1.30





          share|improve this answer































            0














            it show all host off and on, i just wanna see online host






            share|improve this answer








            New contributor



            Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "106"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f181676%2foutput-only-the-ip-addresses-of-the-online-machines-with-nmap%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown
























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              31














              This is a common one:



              nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up$/{print $2}'


              Quick rundown of options and commands:





              • -n turns off reverse name resolution, since you just want IP addresses. On a local LAN this is probably the slowest step, too, so you get a good speed boost.


              • -sn means "Don't do a port scan." It's the same as the older, deprecated -sP with the mnemonic "ping scan."


              • -oG - sends "grepable" output to stdout, which gets piped to awk.


              • /Up$/ selects only lines which end with "Up", representing hosts that are online.


              • {print $2} prints the second whitespace-separated field, which is the IP address.






              share|improve this answer
























              • Why have the $ after /Up? I found that the command nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up/{print $2}' provides the same results.

                – Michael
                Mar 5 at 19:37






              • 1





                @Michael It's just an extra level of safety to ensure we don't print garbage in case something else contains the string "Up". That way it works even if you run it against grepable output in a file from a different type of scan like -sV which can contain unpredictable strings from network service banners.

                – bonsaiviking
                Mar 5 at 20:26
















              31














              This is a common one:



              nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up$/{print $2}'


              Quick rundown of options and commands:





              • -n turns off reverse name resolution, since you just want IP addresses. On a local LAN this is probably the slowest step, too, so you get a good speed boost.


              • -sn means "Don't do a port scan." It's the same as the older, deprecated -sP with the mnemonic "ping scan."


              • -oG - sends "grepable" output to stdout, which gets piped to awk.


              • /Up$/ selects only lines which end with "Up", representing hosts that are online.


              • {print $2} prints the second whitespace-separated field, which is the IP address.






              share|improve this answer
























              • Why have the $ after /Up? I found that the command nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up/{print $2}' provides the same results.

                – Michael
                Mar 5 at 19:37






              • 1





                @Michael It's just an extra level of safety to ensure we don't print garbage in case something else contains the string "Up". That way it works even if you run it against grepable output in a file from a different type of scan like -sV which can contain unpredictable strings from network service banners.

                – bonsaiviking
                Mar 5 at 20:26














              31












              31








              31







              This is a common one:



              nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up$/{print $2}'


              Quick rundown of options and commands:





              • -n turns off reverse name resolution, since you just want IP addresses. On a local LAN this is probably the slowest step, too, so you get a good speed boost.


              • -sn means "Don't do a port scan." It's the same as the older, deprecated -sP with the mnemonic "ping scan."


              • -oG - sends "grepable" output to stdout, which gets piped to awk.


              • /Up$/ selects only lines which end with "Up", representing hosts that are online.


              • {print $2} prints the second whitespace-separated field, which is the IP address.






              share|improve this answer













              This is a common one:



              nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up$/{print $2}'


              Quick rundown of options and commands:





              • -n turns off reverse name resolution, since you just want IP addresses. On a local LAN this is probably the slowest step, too, so you get a good speed boost.


              • -sn means "Don't do a port scan." It's the same as the older, deprecated -sP with the mnemonic "ping scan."


              • -oG - sends "grepable" output to stdout, which gets piped to awk.


              • /Up$/ selects only lines which end with "Up", representing hosts that are online.


              • {print $2} prints the second whitespace-separated field, which is the IP address.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 29 '15 at 3:02









              bonsaivikingbonsaiviking

              2,1091013




              2,1091013













              • Why have the $ after /Up? I found that the command nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up/{print $2}' provides the same results.

                – Michael
                Mar 5 at 19:37






              • 1





                @Michael It's just an extra level of safety to ensure we don't print garbage in case something else contains the string "Up". That way it works even if you run it against grepable output in a file from a different type of scan like -sV which can contain unpredictable strings from network service banners.

                – bonsaiviking
                Mar 5 at 20:26



















              • Why have the $ after /Up? I found that the command nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up/{print $2}' provides the same results.

                – Michael
                Mar 5 at 19:37






              • 1





                @Michael It's just an extra level of safety to ensure we don't print garbage in case something else contains the string "Up". That way it works even if you run it against grepable output in a file from a different type of scan like -sV which can contain unpredictable strings from network service banners.

                – bonsaiviking
                Mar 5 at 20:26

















              Why have the $ after /Up? I found that the command nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up/{print $2}' provides the same results.

              – Michael
              Mar 5 at 19:37





              Why have the $ after /Up? I found that the command nmap -n -sn 192.0.2.0/24 -oG - | awk '/Up/{print $2}' provides the same results.

              – Michael
              Mar 5 at 19:37




              1




              1





              @Michael It's just an extra level of safety to ensure we don't print garbage in case something else contains the string "Up". That way it works even if you run it against grepable output in a file from a different type of scan like -sV which can contain unpredictable strings from network service banners.

              – bonsaiviking
              Mar 5 at 20:26





              @Michael It's just an extra level of safety to ensure we don't print garbage in case something else contains the string "Up". That way it works even if you run it against grepable output in a file from a different type of scan like -sV which can contain unpredictable strings from network service banners.

              – bonsaiviking
              Mar 5 at 20:26













              2














              You could pipe it to awk:



              nmap -sP 192.168.1.0/24 | awk '/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'
              192.168.1.1
              192.168.1.10
              192.168.1.20
              192.168.1.30





              share|improve this answer




























                2














                You could pipe it to awk:



                nmap -sP 192.168.1.0/24 | awk '/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'
                192.168.1.1
                192.168.1.10
                192.168.1.20
                192.168.1.30





                share|improve this answer


























                  2












                  2








                  2







                  You could pipe it to awk:



                  nmap -sP 192.168.1.0/24 | awk '/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'
                  192.168.1.1
                  192.168.1.10
                  192.168.1.20
                  192.168.1.30





                  share|improve this answer













                  You could pipe it to awk:



                  nmap -sP 192.168.1.0/24 | awk '/is up/ {print up}; {gsub (/(|)/,""); up = $NF}'
                  192.168.1.1
                  192.168.1.10
                  192.168.1.20
                  192.168.1.30






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 28 '15 at 22:23









                  jasonwryanjasonwryan

                  51.5k14136190




                  51.5k14136190























                      0














                      it show all host off and on, i just wanna see online host






                      share|improve this answer








                      New contributor



                      Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.
























                        0














                        it show all host off and on, i just wanna see online host






                        share|improve this answer








                        New contributor



                        Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.






















                          0












                          0








                          0







                          it show all host off and on, i just wanna see online host






                          share|improve this answer








                          New contributor



                          Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          it show all host off and on, i just wanna see online host







                          share|improve this answer








                          New contributor



                          Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.








                          share|improve this answer



                          share|improve this answer






                          New contributor



                          Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.








                          answered 21 mins ago









                          Raúl Fernández PerezRaúl Fernández Perez

                          1




                          1




                          New contributor



                          Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.




                          New contributor




                          Raúl Fernández Perez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.
































                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f181676%2foutput-only-the-ip-addresses-of-the-online-machines-with-nmap%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

                              The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

                              Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...