Skip to Content
Linux Administration Cookbook
book

Linux Administration Cookbook

by Adam K. Dean
December 2018
Beginner
826 pages
22h 54m
English
Packt Publishing
Content preview from Linux Administration Cookbook

Adding and removing an IP against an interface

This can be accomplished with the ip address command, but does require root.

In this example, I chose another IP in the 192.168.33.0/24 subnet, which I know isn't in use:

In the real world, it's good practice to ping an IP first, even if you believe it's free to use.
$ sudo ip address add 192.168.33.22/24 dev eth1

Checking our eth1 interface, we can now see the secondary IP:

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 08:00:27:0d:d9:0c brd ff:ff:ff:ff:ff:ff    inet 192.168.33.10/24 brd 192.168.33.255 scope global noprefixroute eth1       valid_lft forever preferred_lft forever    inet 192.168.33.22/24 scope global secondary eth1 valid_lft ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Linux Security Cookbook - Second Edition

Practical Linux Security Cookbook - Second Edition

Tajinder Kalsi
Mastering Linux Administration

Mastering Linux Administration

Alexandru Calcatinge, Julian Balog

Publisher Resources

ISBN: 9781789342529Supplemental Content