! --tcp-flags SYN,ACK ACK -j ACCEPT

$IPTABLES -A FORWARD -m multiport -p tcp -s $OURNET --sports $TCPIN /

 ! --tcp-flags SYN,ACK ACK -j ACCEPT

# TCP - INCOMING CONNECTIONS

# We will accept connection requests from the outside only on the

# allowed TCP ports.

$IPTABLES -A FORWARD -m multiport -p tcp -i $ANYDEV -d $OURNET $TCPIN /

 --syn -j ACCEPT

# TCP - OUTGOING CONNECTIONS

# We will accept all outgoing tcp connection requests on the allowed / TCP ports.

$IPTABLES -A FORWARD -m multiport -p tcp -i $OURDEV -d $ANYADDR /

 --dports $TCPOUT --syn -j ACCEPT

# UDP - INCOMING

# We will allow UDP datagrams in on the allowed ports and back.

$IPTABLES -A FORWARD -m multiport -p udp -i $ANYDEV -d $OURNET /

 --dports $UDPIN -j ACCEPT

$IPTABLES -A FORWARD -m multiport -p udp -i $ANYDEV -s $OURNET /

 --sports $UDPIN -j ACCEPT

# UDP - OUTGOING

# We will allow UDP datagrams out to the allowed ports and back.

$IPTABLES -A FORWARD -m multiport -p udp -i $OURDEV -d $ANYADDR /

 --dports $UDPOUT -j ACCEPT

$IPTABLES -A FORWARD -m multiport -p udp -i $OURDEV -s $ANYADDR /

 --sports $UDPOUT -j ACCEPT# ICMP - INCOMING

# We will allow ICMP datagrams in of the allowed types.

$IPTABLES -A FORWARD -m multiport -p icmp -i $ANYDEV -d $OURNET /

 --dports $ICMPIN -j ACCEPT

# ICMP - OUTGOING

# We will allow ICMP datagrams out of the allowed types.

$IPTABLES -A FORWARD -m multiport -p icmp -i $OURDEV -d $ANYADDR /

 --dports $ICMPOUT -j ACCEPT

# DEFAULT and LOGGING

# All remaining datagrams fall through to the default

# rule and are dropped. They will be logged if you've

# configured the LOGGING variable above.

#

if [ '$LOGGING' ]

then

 # Log barred TCP

 $IPTABLES -A FORWARD -m tcp -p tcp -j LOG

 # Log barred UDP

 $IPTABLES -A FORWARD -m udp -p udp -j LOG

 # Log barred ICMP

 $IPTABLES -A FORWARD -m udp -p icmp -j LOG

fi

#

# end.

In many simple situations, to use the sample all you have to do is edit the top section of the file labeled 'USER CONFIGURABLE section' to specify which protocols and datagrams type you wish to allow in and out. For more complex configurations, you will need to edit the section at the bottom, as well. Remember, this is a simple example, so scrutinize it very carefully to ensure it does what you want while implementing it.

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, ipchains or iptables are used to configure IP accounting. The command syntax is very similar to that of

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату