add a ip address to a network device

ip addr add 192.168.10.1/24 dev eth0
Allows to add more than one ip address to one network device.

2
By: wincus
2010-01-12 13:07:36

These Might Interest You

  • Found this useful for scripts where I needed to work with the machine's IP. If $DEVICE is not specified, this will return all IPs on the machine. If $DEVICE is set to a network adapter, it will return just that adapter's IP.


    -2
    ifconfig $DEVICE | perl -lne '/inet addr:([\d.]+)/ and print $1'
    jdob · 2009-07-21 13:48:19 0
  • Note, the [remotePort] should be opened in the firewall first. First, start the destination box listening, then fire off the sending box. Data from the /dev/zero device in memory of the source machine is read out using dd, sent over the network with nc, and read back in from the other side of the network with nc, going to the /dev/null device. Essentially, it is a memory-network-memory copy operation, the output of dd will tell you how fast your network really is performing.


    0
    dd if=/dev/zero bs=256M count=1 | nc [remoteIP] [remotePort] and on the other host nc -l port >/dev/null
    tkunz · 2009-07-14 20:30:52 1
  • Prevents the need for the grep & awk statements. Sort is optional if you don't care about the output order. The network range can also be specified as in the original post. -A Display targets by address rather than DNS name. (Probably unnecessary...) -a Show systems that are alive. S fping -r1 -ag 192.168.nnn.0/24 2>/dev/null Without sorting... Show Sample Output


    0
    fping -r1 -Aag <network>/<cidr_mask> 2>/dev/null | sort -gt. -k4
    SuperJC · 2011-12-21 22:38:51 0
  • This is a quick replacement for lspci if you need to know what's in a given system but pciutils is not installed. You then need something that can look up the IDs from pci.ids if you want the verbose output. Show Sample Output


    4
    for device in /sys/bus/pci/devices/*; do echo "$(basename ${device} | cut -c '6-') $(cut -c '3-6' ${device}/class): $(cut -c '3-' ${device}/vendor):$(cut -c '3-' ${device}/device)"; done
    Flameeyes · 2012-04-13 03:26:02 0

What Others Think

"ip addr add" can be shortened to "ip a a" as all flags to ip can be written as single characters!
phaidros · 440 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: