508
◾
Linux with Operating System Concepts
where
object
is one of
link
,
addr
,
addrlabel
,
route
,
rule
,
neigh
,
tunnel
,
maddr
,
mroute,
or
monitor
. These are described below. The
command
will vary
depending on the object selected. Options are –V for version, -s for statistics, -r for
resolve, -f for
family that is followed by
inet
,
inet6
,
ipx
,
dnet,
or
link
, and –o to
output on one line.
The object specified dictates just what ip will return or set.
• link—can have a command of
set
or
show
. For set, you are then required to specify
the device such as lo or eth0. This should be followed by one of
• up/down
• arp on/off
• promisc on/off
• allmulticast on/off
• txqueuelen
numpackets
• name/alias
newname
• address/broadcast new_link_layer_address
•
mtu
MTUvalue
(maximum transmission unit)
• netps
PID
•
vf
NUM
(virtual function device number)
• addr—can
have commands of
add
,
del
,
show
, and
flush
to add or remove an IP
address from the device, show the current IP address(es), or flush (remove) an address
based on some specified criteria. With add, you can specify a new name for a device, a
peer or broadcast address(es), label, or scope. The show command can be followed by
one
of dev
name
, scope
scope_val
, to
addr
, label
value
, dynamic, permanent, tentative,
deprecated, primary, or secondary.
• addrlabel—to label an IPv6 address for later use, this object can be followed by one
of
add
,
del
, or
list
.
• route—this object allows you to manipulate or inspect any of the routing tables. There
are several types of routing tables maintained:
unicast
,
unreachable
,
black-
hole
,
prohibit
,
local
,
broadcast
,
throw
,
nat
,
anycast
, and
multicast
.
The
command for route is one of
add
,
change
,
replace
,
del
(delete),
show
,
flush,
or
get
. For add, change, and replace, you may follow this with the word
to
and then both the type of table (e.g.,
unicast
,
nat
) and
IP
or
IPv6
. Alternate
options for add, change, and replace are to specify a new preference number, a table
ID, a new device name,
a new src or via address, and a new mtu value among other
values. The usage of the arguments for del differ somewhat from add, and show has
Network Configuration
◾
509
additional arguments available. The flush command flushes the given table(s) while
the get command can be used to retrieve one specific value from a table. Here are a
few examples of route commands.
• ip route add 10.11.12.0/24 dev eth0
• ip route add default via 10.11.12.13
• ip route add 10.11.1.2 via 10.11.30.1
• ip route add nat 192.51.185.16 via 10.11.12.1
• ip route change default via 10.11.30.6 dev eth0
•
ip route show cache
• rule—change the route selection algorithm so that the routing table used in a par-
ticular setting changes.
• neigh—
add
,
change
,
delete
,
replace
, or
show
, where neighbors are objects
specified as bindings between a protocol address and a link layer address.
• maddress—multicast address, commands are
show
,
add
, and
delete
.
• mroute—multicast-routing cache management,
show
is the only command here.
• tunnel—
add
,
change
, and
delete
a network tunnel.
•
monitor
and
rtmon
(state monitoring).
12.5.2 Other Network Commands
The ip instruction has replaced
route
that previously let you view and manipulate the
IP routing table. This table would contain the gateway address and the gateway’s
router
address along with netmasks for each interface device (excluding lo).
To view interface IP addresses, you can use
ip addr
. Alternatively, the
ifconfig
command will respond with the same information. The ifconfig statement, like ip, also
allows you to configure your network interfaces. The command is followed by the interface
in question (e.g., lo or eth0) and any options that you want to establish or the new address
for that interface (if you omit the options/address, ifconfig
responds with the already-
established address). The command will look like one of these:
ifconfig
Do'stlaringiz bilan baham: