LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grapping local ip using mac (https://www.linuxquestions.org/questions/linux-newbie-8/grapping-local-ip-using-mac-4175594202/)

P.G.Krish 11-25-2016 01:00 AM

Grapping local ip using mac
 
I gather all my local ip using arp-scan , Then filter particular system ip by mac address, And connect automatically to that particular system using ssh. I tried the following commands through piping
Quote:

sudo arp-scan --localnet|grep 10|cut -c1-12|xargs ssh myuser@
Here 1c in grep is the mac address starting letter of my system.

Its return the following error

Quote:

ssh: Could not resolve hostname : Name or service not known

xargs: ssh: exited with status 255; aborting

ferrari 11-25-2016 02:33 AM

I'm assuming that the following yields one IP address
Code:

sudo arp-scan --localnet|grep 10|cut -c1-12
This should work for you
Code:

sudo arp-scan --localnet|grep 10|cut -c1-12|xargs -L 1 -I host ssh user@host
More info about using xargs
Code:

man xargs
Similar asked here...
http://unix.stackexchange.com/questi...-multi-command

ferrari 11-25-2016 02:40 AM

BTW, I noticed that you mentioned
Quote:

Here 1c in grep is the mac address starting letter of my system.
but your command was
Code:

sudo arp-scan --localnet|grep 10...

P.G.Krish 11-25-2016 04:12 AM

Quote:

Originally Posted by ferrari (Post 5634351)
BTW, I noticed that you mentioned

but your command was
Code:

sudo arp-scan --localnet|grep 10...

Hey ,
Thanks for info, But even i tried with this , I got the same error

P.G.Krish 11-25-2016 04:15 AM

Quote:

Originally Posted by ferrari (Post 5634349)
I'm assuming that the following yields one IP address
Code:

sudo arp-scan --localnet|grep 10|cut -c1-12
This should work for you
Code:

sudo arp-scan --localnet|grep 10|cut -c1-12|xargs -L 1 -I host ssh user@host
More info about using xargs
Code:

man xargs
Similar asked here...
http://unix.stackexchange.com/questi...-multi-command

Code:

sudo arp-scan --localnet|grep 10|cut -c1-12|xargs -L 1 -I host ssh

user@host

Why did you add host here?

ferrari 11-25-2016 05:28 AM

It is used as a variablle

P.G.Krish 11-25-2016 06:33 AM

Quote:

Originally Posted by ferrari (Post 5634377)
It is used as a variablle

Hai ferrari,
Its just a show a welcome message instead opening a shell
Quote:

Pseudo-terminal will not be allocated because stdin is not a terminal.
Welcome to Ubuntu 15.10 (GNU/Linux 4.2.0-16-generic x86_64)

* Documentation: https://help.ubuntu.com/

Your Ubuntu release is not supported anymore.
For upgrade information, please visit:
http://www.ubuntu.com/releaseendoflife

New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it
I want a interactive shell

BW-userx 11-25-2016 07:12 AM

be sure to have your hostname you want to use with its respective ip in your hosts file, as well. It looks to that to resolve addresses and hostnames. (i think first, then goes to the DSN server, if I remember correctly)

chrism01 11-27-2016 10:30 PM

@BW-userx: the order is set in /etc/nsswitch.conf ; as you say, normally 'files' first (for some value of 'normal ;) )
My laptop has:
Code:

#hosts:    db files nisplus nis dns
hosts:      files dns



All times are GMT -5. The time now is 10:36 PM.