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 addressip link
ip link [show|ls|list|sh]
Take an interface up/downip 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 interfaceip link set dev (device) address (arp address)
IP ADDRESS (cmd subset)Show ip addressip addr
ip addr [show|sh|list|ls]
ip addr show dev eth0
# show specific deviceShow ip addresses (the old "ifconfig" way)
ifconfig -a
ifconfig
Assign IP address to interfaceip 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 interfaceip 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 mappingip 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 mappingip neigh del 192.168.1.100 dev eth0
Flush arp tableip neigh flush
IP ROUTE (cmd subset)
Show ip routing tablesip 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 Routeip route add default via GATEWAY_IP
Add Default Route (old "route" method)route add default gw 192.168.1.1
Del Routeip route del 10.0.0.0/24
Delete all routes on an interfaceip route flush dev eth0
http://www.policyrouting.org/iproute2.doc.html
http://gentoo-wiki.com/Dual_internet_connections