iptables: what does "--src-type LOCAL" mean exactly?

Pretty good explanation here: http://security.maruhn.com/iptables-tutorial/x6330.html

Another discussion about it: http://www.linuxquestions.org/questions/linux-networking-3/wtf-addrtype-in-iptables-manpage-746659/


I believe the answer that addr-type LOCAL means loopback is wrong, because it is only a partial answer and is extremely misleading. LOCAL means ANY IP assigned on one of the interfaces of the host, including the loopback. If you say that LOCAL is simply 127.0.0.0/8 (as sasanet has stated), then you'd limit it to the loopback interface, which is plain wrong.

Moreover, the IP can even be routable and public. For the host it's irrelevant, because from its perspective that IP is going to refer to the host itself. If you curl or ping to the public ip assigned on one if its interfaces, it will obviously not going to send the packet out, it will route it locally. example:

ip address show dev eth0:

 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 0a:e7:8b:89:d5:f4 brd ff:ff:ff:ff:ff:ff
    inet 172.31.20.254/20 brd 172.31.31.255 scope global dynamic eth0
       valid_lft 3110sec preferred_lft 3110sec

ip route show table local:

local 172.31.20.254 dev eth0 proto kernel scope host src 172.31.20.254

(as already stated, it is obviously irrelevant if the ip is private or public, as long as it is assigned to the network interface)