Version 0.4.5
Copyright © 2002, 2003 Martin A. Brown
2007-Mar-14
| Revision History | ||
|---|---|---|
| Revision 0.4.4 | 2003-04-26 | MAB |
| added index, began packet filtering chapter | ||
| Revision 0.4.3 | 2003-04-14 | MAB |
| ongoing editing, ARP/NAT fixes, routing content | ||
| Revision 0.4.2 | 2003-03-16 | MAB |
| ongoing editing; unreleased version | ||
| Revision 0.4.1 | 2003-02-19 | MAB |
| major routing revision; better use of callouts | ||
| Revision 0.4.0 | 2003-02-11 | MAB |
| major NAT revs; add inline scripts; outline FIB | ||
| Revision 0.3.9 | 2003-02-05 | MAB |
| fleshed out bonding; added bridging chapter | ||
| Revision 0.3.8 | 2003-02-03 | MAB |
| move to linux-ip.net; use TLDP XSL stylesheets | ||
| Revision 0.3.7 | 2003-02-02 | MAB |
| major editing on ARP; minor editing on routing | ||
| Revision 0.3.6 | 2003-01-30 | MAB |
| switch to XSLT processing; minor revs; CVS | ||
| Revision 0.3.5 | 2003-01-08 | MAB |
| ARP flux complete; ARP filtering touched | ||
| Revision 0.3.4 | 2003-01-06 | MAB |
| ARP complete; bridging added; ip neigh complete | ||
| Revision 0.3.3 | 2003-01-05 | MAB |
| split into 3 parts; ARP chapter begun | ||
| Revision 0.3.2 | 2002-12-29 | MAB |
| links updated; minor editing | ||
| Revision 0.3.1 | 2002-11-26 | MAB |
| edited: intro, snat, nat; split advanced in two | ||
| Revision 0.3.0 | 2002-11-14 | MAB |
| chapters finally have good HTML names | ||
| Revision 0.2.9 | 2002-11-11 | MAB |
| routing chapter heavily edited | ||
| Revision 0.2.8 | 2002-11-07 | MAB |
| basic chapter heavily edited | ||
| Revision 0.2.7 | 2002-11-04 | MAB |
| routing chapter finished; links rearranged | ||
| Revision 0.2.6 | 2002-10-29 | MAB |
| routing chapter continued | ||
| Revision 0.2.5 | 2002-10-28 | MAB |
| routing chapter partly complete | ||
| Revision 0.2.4 | 2002-10-08 | MAB |
| advanced routing additions and overview | ||
| Revision 0.2.3 | 2002-09-30 | MAB |
| minor editing; worked on tools/netstat; advanced routing | ||
| Revision 0.2.2 | 2002-09-24 | MAB |
| formalized revisioning; finished basic networking; started netstat | ||
| Revision 0.2.1 | 2002-09-21 | MAB |
| added network map to incomplete rough draft | ||
| Revision 0.2 | 2002-09-20 | MAB |
| incomplete rough draft released on LARTC list | ||
| Revision 0.1 | 2002-08-04 | MAB |
| rough draft begun | ||
Abstract
This guide provides an overview of many of the tools available for IP network administration of the linux operating system, kernels in the 2.2 and 2.4 series. It covers Ethernet, ARP, IP routing, NAT, and other topics central to the management of IP networks.
Table of Contents
- Introduction
- I. Concepts
- 1. Basic IP Connectivity
- 2. Ethernet
- 3. Bridging
- 4. IP Routing
- 5. Network Address Translation (NAT)
- 6. Masquerading and Source Network Address Translation
- 7. Packet Filtering
- 8. Statefulness and Statelessness
- II. Cookbook
- III. Appendices and Reference
- A. An Example Network and Description
- B. Ethernet Layer Tools
- 1. arp
- 2. arping
- 3. ip link
- 3.1. Displaying link layer characteristics with ip link show
- 3.2. Changing link layer characteristics with ip link set
- 3.3. Deactivating a device with ip link set
- 3.4. Activating a device with ip link set
- 3.5. Using ip link set to change the MTU
- 3.6. Changing the device name with ip link set
- 3.7. Changing hardware or Ethernet broadcast address with ip link set
- 4. ip neighbor
- 5. mii-tool
- C. IP Address Management
- D. IP Route Management
- 1. route
- 2. ip route
- 2.1. Displaying a routing table with ip route show
- 2.2. Displaying the routing cache with ip route show cache
- 2.3. Using ip route add to populate a routing table
- 2.4. Adding a default route with ip route add default
- 2.5. Setting up NAT with ip route add nat
- 2.6. Removing routes with ip route del
- 2.7. Altering existing routes with ip route change
- 2.8. Programmatically fetching route information with ip route get
- 2.9. Clearing routing tables with ip route flush
- 2.10. ip route flush cache
- 2.11. Summary of the use of ip route
- 3. ip rule
- E. Tunnels and VPNs
- F. Sockets; Servers and Clients
- G. Diagnostic Tools
- H. Miscellany
- I. Links to other Resources
- 1. Links to Documentation
- 1.1. Linux Networking Introduction and Overview Material
- 1.2. Linux Security and Network Security
- 1.3. General IP Networking Resources
- 1.4. Masquerading topics
- 1.5. Network Address Translation
- 1.6. iproute2 documentation
- 1.7. Netfilter Resources
- 1.8. ipchains Resources
- 1.9. ipfwadm Resources
- 1.10. General Systems References
- 1.11. Bridging
- 1.12. Traffic Control
- 1.13. IPv4 Multicast
- 1.14. Miscellaneous Linux IP Resources
- 2. Links to Software
- J. GNU Free Documentation License
- 1. PREAMBLE
- 2. APPLICABILITY AND DEFINITIONS
- 3. VERBATIM COPYING
- 4. COPYING IN QUANTITY
- 5. MODIFICATIONS
- 6. COMBINING DOCUMENTS
- 7. COLLECTIONS OF DOCUMENTS
- 8. AGGREGATION WITH INDEPENDENT WORKS
- 9. TRANSLATION
- 10. TERMINATION
- 11. FUTURE REVISIONS OF THIS LICENSE
- 12. ADDENDUM: How to use this License for your documents
- Reference Bibliography and Recommended Reading
- Index
List of Tables
- 2.1. Active ARP cache entry states
- 4.1. Keys used for hash table lookups during route selection
- 5.1. Filtering an iproute2 NAT packet with ipchains
- A.1. Example Network; Network Addressing
- A.2. Example Network; Host Addressing
- B.1. ip link link layer device states
- B.2. Ethernet Port Speed Abbreviations
- C.1. Interface Flags
- C.2. IP Scope under ip address
- G.1. Possible Session States in netstat output
- H.1. iproute2 Synonyms
List of Examples
- 1.1. Sample ifconfig output
- 1.2. Testing reachability of a locally connected host with ping
- 1.3. Testing reachability of non-local hosts
- 1.4. Sample routing table with a static route
- 1.5. ifconfig and route output before the change
- 1.6. Bringing down a network interface with ifconfig
- 1.7. Bringing up an Ethernet interface with ifconfig
- 1.8. Adding a default route with route
- 1.9. Adding a static route with route
- 1.10. Removing a static network route and adding a static host route
- 2.1. ARP conversation captured with tcpdump
- 2.2. Gratuitous ARP reply frames
- 2.3. Unsolicited ARP request frames
- 2.4. Duplicate Address Detection with ARP
- 2.5. ARP cache listings with arp and ip neighbor
- 2.6. ARP cache timeout
- 2.7. ARP flux
- 2.8. Correction of ARP flux with
conf/$DEV/arp_filter - 2.9. Correction of ARP flux with
net/$DEV/hidden - 2.10. Proxy ARP Network Diagram
- 2.11. Bringing up a VLAN interface
- 2.12. Link aggregation bonding
- 2.13. High availability bonding
- 4.1. Classes of IP addresses
- 4.2. Using ipcalc to display IP information
- 4.3. Identifying the locally connected networks with route
- 4.4. Routing Selection Algorithm in Pseudo-code
- 4.5. Listing the Routing Policy Database (RPDB)
- 4.6. Typical content of
/etc/iproute2/rt_tables - 4.7. unicast route types
- 4.8. broadcast route types
- 4.9. local route types
- 4.10. nat route types
- 4.11. unreachable route types
- 4.12. prohibit route types
- 4.13. blackhole route types
- 4.14. throw route types
- 4.15. Kernel maintenance of the
localrouting table - 4.16. unicast rule type
- 4.17. nat rule type
- 4.18. unreachable rule type
- 4.19. prohibit rule type
- 4.20. blackhole rule type
- 4.21. ICMP Redirect on the Wire
- 5.1. Stateless NAT Packet Capture
- 5.2. Basic commands to create a stateless NAT
- 5.3. Conditional Stateless NAT (not performing NAT for a specified destination network)
- 5.4. Using an ipchains packet filter with stateless NAT
- 5.5. Using DNAT for all protocols (and ports) on one IP
- 5.6. Using DNAT for a single port
- 5.7. Simulating full NAT with SNAT and DNAT
- 7.1. Blocking a destination and using the
REJECTtarget, cf. Example D.17, “Adding aprohibitroute with route add” - 10.1. Multiple Outbound Internet links, part I; ip route
- 10.2. Multiple Outbound Internet links, part II; iptables
- 10.3. Multiple Outbound Internet links, part III; ip rule
- 10.4. Multiple Internet links, inbound traffic; using iproute2 only
- 11.1. Proxy ARP SysV initialization script
- 11.2. Proxy ARP configuration file
- 11.3. Static NAT SysV initialization script
- 11.4. Static NAT configuration file
- B.1. Displaying the arp table with arp
- B.2. Adding arp table entries with arp
- B.3. Deleting arp table entries with arp
- B.4. Displaying reachability of an IP on the local Ethernet with arping
- B.5. Duplicate Address Detection with arping
- B.6. Using ip link show
- B.7. Using ip link set to change device flags
- B.8. Deactivating a link layer device with ip link set
- B.9. Activating a link layer device with ip link set
- B.10. Using ip link set to change device flags
- B.11. Changing the device name with ip link set
- B.12. Changing broadcast and hardware addresses with ip link set
- B.13. Displaying the ARP cache with ip neighbor show
- B.14. Displaying the ARP cache on an interface with ip neighbor show
- B.15. Displaying the ARP cache for a particular network with ip neighbor show
- B.16. Entering a permanent entry into the ARP cache with ip neighbor add
- B.17. Entering a proxy ARP entry with ip neighbor add proxy
- B.18. Altering an entry in the ARP cache with ip neighbor change
- B.19. Removing an entry from the ARP cache with ip neighbor del
- B.20. Removing learned entries from the ARP cache with ip neighbor flush
- B.21. Detecting link layer status with mii-tool
- B.22. Specifying Ethernet port speeds with mii-tool --advertise
- B.23. Forcing Ethernet port speed with mii-tool --force
- C.1. Viewing interface information with ifconfig
- C.2. Bringing down an interface with ifconfig
- C.3. Bringing up an interface with ifconfig
- C.4. Changing MTU with ifconfig
- C.5. Setting interface flags with ifconfig
- C.6. Displaying IP information with ip address
- C.7. Adding IP addresses to an interface with ip address
- C.8. Removing IP addresses from interfaces with ip address
- C.9. Removing all IPs on an interface with ip address flush
- D.1. Viewing a simple routing table with route
- D.2. Viewing a complex routing table with route
- D.3. Viewing the routing cache with route
- D.4. Adding a static route to a network route add
- D.5. Adding a static route to a host with route add
- D.6. Adding a static route to a host on the same media with route add
- D.7. Setting the default route with route
- D.8. An alternate method of setting the default route with route
- D.9. Removing a static host route with route del
- D.10. Removing the default route with route del
- D.11. Viewing the main routing table with ip route show
- D.12. Viewing the local routing table with ip route show table local
- D.13. Viewing a routing table with ip route show table
- D.14. Displaying the routing cache with ip route show cache
- D.15. Displaying statistics from the routing cache with ip -s route show cache
- D.16. Adding a static route to a network with route add, cf. Example D.4, “Adding a static route to a network route add”
- D.17. Adding a
prohibitroute with route add - D.18. Using
fromin a routing command with route add - D.19. Using
srcin a routing command with route add - D.20. Setting the default route with ip route add default
- D.21. Creating a NAT route for a single IP with ip route add nat
- D.22. Creating a NAT route for an entire network with ip route add nat
- D.23. Removing routes with ip route del
- D.24. Altering existing routes with ip route change
- D.25. Testing routing tables with ip route get
- D.26. Removing a specific route and emptying a routing table with ip route flush
- D.27. Emptying the routing cache with ip route flush cache
- D.28. Displaying the RPDB with ip rule show
- D.29. Creating a simple entry in the RPDB with ip rule add
- D.30. Creating a complex entry in the RPDB with ip rule add
- D.31. Creating a NAT rule with ip rule add nat
- D.32. Creating a NAT rule for an entire network with ip rule add nat
- D.33. Removing a NAT rule for an entire network with ip rule del nat
- F.1. Simple use of nc
- F.2. Specifying timeout with nc
- F.3. Specifying source address with nc
- F.4. Using nc as a server
- F.5. Delaying a stream with nc
- F.6. Using nc with UDP
- F.7. Simple use of socat
- F.8. Using socat with proxy connect
- F.9. Using socat perform SSL
- F.10. Connecting one end of socat to a file descriptor
- F.11. Connecting socat to a serial line
- F.12. Using a PTY with socat
- F.13. Executing a command with socat
- F.14. Connecting one socat to another one
- F.15. Simple use of tcpclient
- F.16. Specifying the local port which tcpclient should request
- F.17. Specifying the local IP to which tcpclient should bind
- F.18. IP redirection with xinetd
- F.19. Publishing a service with xinetd
- F.20. Simple use of tcpserver
- F.21. Specifying a CDB for tcpserver
- F.22. Limiting the number of concurrently accept TCP sessions under tcpserver
- F.23. Specifying a UID for tcpserver's spawned processes
- F.24. Redirecting a TCP port with redir
- F.25. Running redir in transparent mode
- F.26. Running redir from another TCP server
- F.27. Specifying a source address for redir's client side
- G.1. Using ping to test reachability
- G.2. Using ping to specify number of packets to send
- G.3. Using ping to specify number of packets to send
- G.4. Using ping to stress a network
- G.5. Using ping to stress a network with large packets
- G.6. Recording a network route with ping
- G.7. Setting the TTL on a ping packet
- G.8. Setting ToS for a diagnostic ping
- G.9. Specifying a source address for ping
- G.10. Simple usage of traceroute
- G.11. Displaying IP socket status with netstat
- G.12. Displaying IP socket status details with netstat
- G.13. Displaying the main routing table with netstat
- G.14. Displaying the routing cache with netstat
- G.15. Displaying the masquerading table with netstat
- G.16. Viewing an ARP broadcast request and reply with tcpdump
- G.17. Viewing a gratuitous ARP packet with tcpdump
- G.18. Viewing unicast ARP packets with tcpdump
- G.19. tcpdump reporting port unreachable
- G.20. tcpdump reporting host unreachable
- G.21. tcpdump reporting net unreachable
- G.22. Monitoring TCP window sizes with tcpdump
- G.23. Examining TCP flags with tcpdump
- G.24. Examining TCP acknowledgement numbers with tcpdump
- G.25. Writing tcpdump data to a file
- G.26. Reading tcpdump data from a file
- G.27. Causing tcpdump to use a line buffer
- G.28. Understanding fragmentation as reported by tcpdump
- G.29. Specifying interface with tcpdump
- G.30. Timestamp related options to tcpdump