Skip to content

Instantly share code, notes, and snippets.

@hvnsweeting
Created August 6, 2012 10:49
Show Gist options
  • Save hvnsweeting/3273415 to your computer and use it in GitHub Desktop.
Save hvnsweeting/3273415 to your computer and use it in GitHub Desktop.
iproute2
iproute commands
Prerequisites
iproute2 package
kernel configure options:
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_IP_ROUTE_MULTIPATH=y
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
IP LINK (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
ifconfig
Assign IP address to interface
ip addr [add|a] (address)/(mask) dev (device)
ex: ip addr add 192.168.1.2/24 dev eth0
Assign IP address to interface (the old "ifconfig" way)
ifconfig eth0 192.168.1.2 netmask 255.255.255.0
Remove IP address from interface
ip addr [delete|del|d] (address)/(mask) dev (device)
ex: ip addr del 192.168.1.2/24 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 192.168.1.100 dev eth0 lladdr (mac address)
ip neigh add 192.168.1.100 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 192.168.1.100 dev eth0
Flush arp table
ip neigh flush
IP ROUTE (cmd subset)
Show ip routing tables
ip route
Show ip routing tabes (the old "route" way)
route
Add Static Route
ip route add (network)/(mask) via (ip to route through)
e.x. ip route add 10.0.0.0/24 via 192.244.7.65
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 10.0.0.0 netmask 255.255.255.0 dev eth0
Add Default Route
ip route add default via GATEWAY_IP
Add Default Route (old "route" method)
route add default gw 192.168.1.1
Del Route
ip route del 10.0.0.0/24
Delete all routes on an interface
ip route flush dev eth0
http://www.policyrouting.org/iproute2.doc.html
http://gentoo-wiki.com/Dual_internet_connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment