commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Interfaces like lo can be omitted from the beginning, there are probably better ways of doing this, i'm a noob at awk.
If you want to check that the spoof worked, type the same command as earlier:
ifconfig en1 | grep ether
Now you will see:
For the wired ethernet port:
sudo ifconfig en0 ether 00:e2:e3:e4:e5:e6
Gets the IP addresses of all interfaces except loopback. Cuts out all of the extra text.
Shorter than the other options, and much easier to type.
'ifconfig | grep cast' is enough to get the IP address, but it doesn't strip the rest of the junk out.
This doesn't make any assumptions about your IP address and prints out one IP address per line if you have multiple network interfaces.
This assumes your local ip starts with 192.something (e.g. 192.168), it greps ifconfig output for an ip that starts with 192, then strips the extra garbage (besides the ip)
Maybe `ifconfig | grep addr | grep Bcast` would also do it
Easy way to grab the IP address of a machine for easy script use. If needed a "| grep -v 127.0.0.1" at the end will suppress localhost.
Get mac address listed for all interfaces.
HP UX doesn't have a -a switch in the ifconfig command.
This line emulates the same result shown in Solaris, AIX or Linux
the below command create a alias for share your internet connection with another.
ifconfig eth0:1 192.168.0.1/24
Its obviously necessary too activate the iptables post-routing and ip forwarding, as root:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
Be sure that the alias 192.168.0.0/24 is not your active real ip range
Get the line containing "inet addr:" and the line before that, get down to only the first line, and then get the first word on that line, which should be the interface.
same thing as the other
grabs your local IP Address.
Simple MAC adrress, thanks to ifconfig.
Sometimes, you don't really care about all the other information that ifconfig spits at you (however useful it may otherwise be). You just want an IP. This strips out all the crap and gives you exactly what you want.
Gets the internal and external IP addresses of all your interfaces, or the ones given as arguments
Will return your internal IP address.
The example command deletes all aliases for network interface 'em0' assuming that the aliases have netmask of 255.255.255.255 and the master IP has some other netmask (such as 255.255.255.0). See here -> http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/ for more on the rationale of this command.