Difference between revisions of "iproute2"

From Noah.org
Jump to navigationJump to search
m (Created page with 'Category:Engineering Category:Networking <pre> ip addr add local 10.10.10.17/32 dev eth0 </pre> <pre> ip addr del local 10.10.10.17/32 dev eth0 </pre> …')
 
m
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
[[Category:Networking]]
 
[[Category:Networking]]
  
 +
== add an IP address to an interface ==
 
<pre>
 
<pre>
ip addr add
+
ip addr add \
     local 10.10.10.17/32
+
     local 10.10.10.17/32 \
 
     dev eth0
 
     dev eth0
 
</pre>
 
</pre>
 +
 +
== show IP addresses assigned to an interface ==
  
 
<pre>
 
<pre>
ip addr del
+
ip addr show
     local 10.10.10.17/32
+
</pre>
 +
== delete an IP address from an interface ==
 +
 
 +
<pre>
 +
ip addr del \
 +
     local 10.10.10.17/32 \
 
     dev eth0
 
     dev eth0
 
</pre>
 
</pre>
  
 +
== default gateway route ==
 +
 +
This requires two steps.
 
<pre>
 
<pre>
ip route add
+
ip route add \
     10.10.10.0/24
+
     10.10.10.0/24 \
 
     dev eth0
 
     dev eth0
  
ip route add
+
ip route add \
     default via
+
     default via \
 
     10.10.10.1
 
     10.10.10.1
 +
</pre>
 +
 +
== virtual interfaces ==
 +
 +
The '''iproute2''' system does not need the idea of a virtual interface. Instead, you can simply add additional IP addresses to an existing interface.
 +
 +
<pre>
 +
ip addr add \
 +
    local 10.10.10.17/32 \
 +
    dev eth0
 +
ip addr add \
 +
    local 10.10.10.18/32 \
 +
    dev eth0
 +
ip addr add \
 +
    local 10.10.10.19/32 \
 +
    dev eth0
 +
</pre>
 +
 +
=== labeling virtual interfaces for compatibility with `ifconfig` ===
 +
 +
Note that the `ifconfig -a` command will '''not''' show these additional IP addresses unless they are labeled. They don't show up as additional IP addresses on an interface, and they don't show up as separate virtual interfaces. This is be confusing.
 +
 +
You can label an IP address. If the label is unique, then it will show up under `ifconfig -a` as a separate interface. The following will show up under `ifconfig -a`.
 +
<pre>
 +
ip addr add \
 +
    local 10.10.10.17/32 \
 +
    dev eth0 \
 +
    label eth0:1
 +
ip addr add \
 +
    local 10.10.10.18/32 \
 +
    dev eth0 \
 +
    label eth0:2
 +
ip addr add \
 +
    local 10.10.10.19/32 \
 +
    dev eth0 \
 +
    label eth0:3
 
</pre>
 
</pre>

Latest revision as of 12:11, 3 February 2011


add an IP address to an interface

ip addr add \
    local 10.10.10.17/32 \
    dev eth0

show IP addresses assigned to an interface

ip addr show

delete an IP address from an interface

ip addr del \
    local 10.10.10.17/32 \
    dev eth0

default gateway route

This requires two steps.

ip route add \
    10.10.10.0/24 \
    dev eth0

ip route add \
    default via \
    10.10.10.1

virtual interfaces

The iproute2 system does not need the idea of a virtual interface. Instead, you can simply add additional IP addresses to an existing interface.

ip addr add \
    local 10.10.10.17/32 \
    dev eth0
ip addr add \
    local 10.10.10.18/32 \
    dev eth0
ip addr add \
    local 10.10.10.19/32 \
    dev eth0

labeling virtual interfaces for compatibility with `ifconfig`

Note that the `ifconfig -a` command will not show these additional IP addresses unless they are labeled. They don't show up as additional IP addresses on an interface, and they don't show up as separate virtual interfaces. This is be confusing.

You can label an IP address. If the label is unique, then it will show up under `ifconfig -a` as a separate interface. The following will show up under `ifconfig -a`.

ip addr add \
    local 10.10.10.17/32 \
    dev eth0 \
    label eth0:1
ip addr add \
    local 10.10.10.18/32 \
    dev eth0 \
    label eth0:2
ip addr add \
    local 10.10.10.19/32 \
    dev eth0 \
    label eth0:3