Re: Bash scripting help...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/7/06, Jacques B. <jjrboucher@xxxxxxxxx> wrote:
Or even easier:

ip=$(/sbin/arping -f -I eth0 10.255.255.1 | grep Unicast | awk '{print
substr($5,2,17)}')

This greps for the line with the MAC, then using awk prints out the
5th field (space delimited by default so this is the MAC with the [
and ]), and using substr I carve out the MAC by saying I want the 5th
field ($5), starting at the 2nd character, for 17 characters.

Jacques B.

Of course both examples require you to put in the IP you wish to
target.  Remember that if the IP is on another subnet that the MAC
that you will get will be the last physical hop to you, so the
router/switch/ at the mouth of your subnet.  Check your gateway's MAC.
If you get that as a reply, then you know it's something outside of
your network (if you aren't sure to start off with).  You could always
write a condition in your script where you'd get the MAC of your
gateway and return a warning to the end user if they query an IP other
than the gateway that returns the gateway's MAC.

Jacques B.

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux