Quelques notes concernant les paramètres sysctl décrites dans la documentation du noyau linux ip-sysctl.txt.
Je détaille plus particulièrement les paramètres forwarding et ip_forward dans une page dédiée : Packet forwarding.
Quel différence y a-t-il entre les paramètres net.ipv[46].conf.all…, net.ipv[46].conf.default… et net.ipv[46].conf.X… (X étant une NIC) ?
As far as I researched for IPv4 some time ago, the “default” value gets copied to newly created interfaces only once.
“all” on the other hand allways gets applied in addition to the current setting, but it depends on the exact setting, if its ORed, ANDed, or whatevered:
- log_martians OR
- accept_redirects AND
- …
(see include/linux/inetdevice.h:83 for IN_DEV_{AND,OR,MAX}CONF)
Putting a new value in “all” doesn’t change the value you read from “$interface”, but it only gets computed and used internally.
On a donc :
- les paramètre
net.ipv[46].conf.default…est donc un skeleton qui sera appliqué à une nouvelle interface. Genre si on branche à chaud une nouvelle NIC sur la machine. - les paramètres
net.ipv[46].conf.X…etnet.ipv[46].conf.all…sont utilisé conjointement pour déterminer la politique à appliquer sur chaque interface.
Exemple
log_martians
Log packets with impossible addresses to kernel log.
En recherchant, martians dans le fichier on tombe sur IN_DEV_LOG_MARTIANS :
#define IN_DEV_LOG_MARTIANS(in_dev) IN_DEV_ORCONF((in_dev), LOG_MARTIANS)
#define IN_DEV_ORCONF(in_dev, attr) \
IN_DEV_NET_ORCONF(in_dev, dev_net(in_dev->dev), attr)
#define IN_DEV_NET_ORCONF(in_dev, net, attr) \
(IPV4_DEVCONF_ALL(net, attr) || \
IN_DEV_CONF_GET((in_dev), attr))
On voit bien que c’est un OR entre all et la conf de l’interface.
accept_redirects
accept_redirects for the interface will be enabled if:
- both conf/{all,interface}/accept_redirects are TRUE in the case forwarding for the interface is enabled
or
- at least one of conf/{all,interface}/accept_redirects is TRUE in the case forwarding for the interface is disabled
#define IN_DEV_RX_REDIRECTS(in_dev) \
((IN_DEV_FORWARD(in_dev) && \
IN_DEV_ANDCONF((in_dev), ACCEPT_REDIRECTS)) \
|| (!IN_DEV_FORWARD(in_dev) && \
IN_DEV_ORCONF((in_dev), ACCEPT_REDIRECTS)))