Chapter 10 - (Web server application) IP Accounting In today’s world

Chapter 10 - IP Accounting In today’s world of commercial Internet service, it is becoming increasingly important to know how much data you are transmitting and receiving on your network connections. If you are an Internet Service Provider and you charge your customers by volume, this will be essential to your business. If you are a customer of an Internet Service Provider that charges by data volume, you will find it useful to collect your own data to ensure the accuracy of your Internet charges. There are other uses for network accounting that have nothing to do with dollars and bills. If you manage a server that offers a number of different types of network services, it might be useful to you to know exactly how much data is being generated by each one. This sort of information could assist you in making decisions, such as what hardware to buy or how many servers to run. The Linux kernel provides a facility that allows you to collect all sorts of useful information about the network traffic it sees. This facility is called IP accounting. Configuring the Kernel for IP Accounting The Linux IP accounting feature is very closely related to the Linux firewall software. The places you want to collect accounting data are the same places that you would be interested in performing firewall filtering: into and out of a network host, and in the software that does the routing of datagrams. If you haven’t read the section on firewalls, now is probably a good time to do so, as we will be using some of the concepts described in Chapter 9, TCP/IP Firewall. To activate the Linux IP accounting feature, you should first see if your Linux kernel is configured for it. Check to see if the /proc/net/ip_acct file exists. If it does, your kernel already supports IP accounting. If it doesn’t, you must build a new kernel, ensuring that you answer “Y” to the options in 2.0 and 2.2 series kernels: Networking options —> [*] Network firewalls [*] TCP/IP networking … [*] IP: accounting or in 2.4 series kernels: Networking options —> [*] Network packet filtering (replaces ipchains) Configuring IP Accounting Because IP accounting is closely related to IP firewall, the same tool was designated to configure it, so ipfwadm, ipchainsor iptables are used to configure IP accounting. The command syntax is very similar to that of the firewall rules, so we won’t focus on it, but we will discuss what you can discover about the nature of your network traffic using this feature. The general syntax for IP accounting with ipfwadmis: # ipfwadm -A [direction][command][parameters] The direction argument is new. This is simply coded as in, out, or both. These directions are from the perspective of the linux machine itself, so in means data coming into the machine from a network connection and out means data that is being transmitted by this host on a network connection. The both direction is the sum of both the incoming and outgoing directions. The general command syntax for ipchains and iptablesis: # ipchains -A chain rule-specification # iptables -A chain rule-specification The ipchains and iptables commands allow you to specify direction in a manner more consistent with the firewall rules. IP Firewall Chains doesn’t allow you to configure a rule that aggregates both directions, but it does

Leave a Reply