Saturday, April 14, 2007

iproute commands

iproute2 package

kernel configure options:


menuconfig path:
- Networking -->
-- Networking Support -->
--- Networking options -->
---- TCP/IP networking
----- IP: Advanced router
----- IP: policy routing
----- IP: equal cost multipath

Enable IP Forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter

(cmd subset)

Show hardware address

ip link
ip link [show|ls|list|sh]

Take an interface up/down
ip link set dev (device) up
ip link set (device) up
ip link set dev (device) down
ip link set (device) up

Change the MAC address of the interface
ip link set dev (device) address (arp address)

IP ADDRESS (cmd subset)

Show ip address
ip addr
ip addr [show|sh|list|ls]
ip addr show dev eth0 # show specific device

Show ip addresses (the old "ifconfig" way)
ifconfig -a

Assign IP address to interface
ip addr [add|a] (address)/(mask) dev (device)
ex: ip addr add dev eth0

Assign IP address to interface (the old "ifconfig" way)
ifconfig eth0 netmask

Remove IP address from interface
ip addr [delete|del|d] (address)/(mask) dev (device)
ex: ip addr del dev eth0

IP NEIGHBOR (cmd subset)

Show ip Layer 2 neighbors (arp table)
ip neigh

Show ip Layer 2 netighbors (the old "arp" way)
arp -a

Add new ARP mapping
ip neigh add dev eth0 lladdr (mac address)
ip neigh add dev eth0 lladdr (mac address) nud reachable

NUD Statuses
--permanent (perm) # administrative mapping
--noarp # neighbor valid but no attempt to rearp will be made
--reachable # neighbor entry valid until timeout
--stale # old arp entry

Remove ARP mapping
ip neigh del dev eth0

Flush arp table
ip neigh flush

(cmd subset)

Show ip routing tables

ip route

Show ip routing tabes (the old "route" way)

Add Static Route
ip route add (network)/(mask) via (ip to route through)
e.x. ip route add via
ip route add (network)/(mask) src INTERFACE_IP dev (device)
ip route add (network)/(mask) dev (device) protocol static

Add Static Route (old "route" method)
route add -net netmask dev eth0

Add Default Route
ip route add default via GATEWAY_IP

Add Default Route (old "route" method)
route add default gw

Del Route
ip route del

Delete all routes on an interface
ip route flush dev eth0

1 comment:

Linux_Admin_Junior said...

I used the ip command a little in the Red Hat Classes, I am going to start using it more now. Thanks for posting the commands this is GREAT information. Espicially on the ip neigh command, very helpful and clearly arp.