Code to get the IP address and format it to run in nmap
up vote
0
down vote
favorite
For scanning my subnet using my IP address, I need to run the following command
nmap -sn 192.168.100.*
I want to extend this functionality such that I don't have to manually specify the first three parts of the IP range myself. I came up with this rough solution.
ip=$( hostname -I | awk '{print $1}' | awk -F. '{print $1; print $2; print $3}' ORS="."; echo -n "*");
nmap -sn $ip
Is there a more cleaner way of achieving the same?
bash
add a comment |
up vote
0
down vote
favorite
For scanning my subnet using my IP address, I need to run the following command
nmap -sn 192.168.100.*
I want to extend this functionality such that I don't have to manually specify the first three parts of the IP range myself. I came up with this rough solution.
ip=$( hostname -I | awk '{print $1}' | awk -F. '{print $1; print $2; print $3}' ORS="."; echo -n "*");
nmap -sn $ip
Is there a more cleaner way of achieving the same?
bash
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For scanning my subnet using my IP address, I need to run the following command
nmap -sn 192.168.100.*
I want to extend this functionality such that I don't have to manually specify the first three parts of the IP range myself. I came up with this rough solution.
ip=$( hostname -I | awk '{print $1}' | awk -F. '{print $1; print $2; print $3}' ORS="."; echo -n "*");
nmap -sn $ip
Is there a more cleaner way of achieving the same?
bash
For scanning my subnet using my IP address, I need to run the following command
nmap -sn 192.168.100.*
I want to extend this functionality such that I don't have to manually specify the first three parts of the IP range myself. I came up with this rough solution.
ip=$( hostname -I | awk '{print $1}' | awk -F. '{print $1; print $2; print $3}' ORS="."; echo -n "*");
nmap -sn $ip
Is there a more cleaner way of achieving the same?
bash
bash
asked 6 mins ago
user3079474
1165
1165
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f208667%2fcode-to-get-the-ip-address-and-format-it-to-run-in-nmap%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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