http://www.frozentux.net/ipsysctl-tutorial/ipsysctl-tutorial.html
Aquesta comanda la proporciona el paquet procps
$ dpkg -S /sbin/sysctl procps: /sbin/sysctl
Permet modificar paràmetres del kernel sense necessitat de recompilar. Els paràmetres disponibles són els de la carpeta
/proc/sys
Els podem consultar amb:
$ sysctl -a | more
# sysctl -a | grep vm error: permission denied on key 'net.ipv4.route.flush' error: permission denied on key 'net.ipv6.route.flush' error: "Invalid argument" reading key "fs.binfmt_misc.register" error: "Invalid argument" reading key "dev.parport.parport0.autoprobe" error: "Invalid argument" reading key "dev.parport.parport0.autoprobe0" error: "Invalid argument" reading key "dev.parport.parport0.autoprobe1" error: "Invalid argument" reading key "dev.parport.parport0.autoprobe2" error: "Invalid argument" reading key "dev.parport.parport0.autoprobe3" vm.overcommit_memory = 0 vm.panic_on_oom = 0 vm.overcommit_ratio = 50 vm.page-cluster = 3 vm.dirty_background_ratio = 5 vm.dirty_ratio = 10 vm.dirty_writeback_centisecs = 500 vm.dirty_expire_centisecs = 3000 vm.nr_pdflush_threads = 2 vm.swappiness = 60 vm.lowmem_reserve_ratio = 256 32 vm.drop_caches = 0 vm.min_free_kbytes = 3816 vm.percpu_pagelist_fraction = 0 vm.max_map_count = 65536 vm.laptop_mode = 0 vm.block_dump = 0 vm.vfs_cache_pressure = 100 vm.legacy_va_layout = 0 vm.stat_interval = 1 vm.vdso_enabled = 2 fs.binfmt_misc.sun-java6 = interpreter /usr/lib/jvm/java-6-sun-1.6.0.03/jre/lib/jexec
És la info que hi ha a:
# ls /proc/sys/vm block_dump laptop_mode overcommit_memory swappiness dirty_background_ratio legacy_va_layout overcommit_ratio vdso_enabled dirty_expire_centisecs lowmem_reserve_ratio page-cluster vfs_cache_pressure dirty_ratio max_map_count panic_on_oom dirty_writeback_centisecs min_free_kbytes percpu_pagelist_fraction drop_caches nr_pdflush_threads stat_interval
Recursos:
El que trobareu a una Ubuntu 10.4 és el següent:
$ cat /etc/sysctl.conf # # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl.conf (5) for information. # #kernel.domainname = example.com # Uncomment the following to stop low-level messages on console #kernel.printk = 4 4 1 7 ##############################################################3 # Functions previously found in netbase # # Uncomment the next two lines to enable Spoof protection (reverse-path filter) # Turn on Source Address Verification in all interfaces to # prevent some spoofing attacks #net.ipv4.conf.default.rp_filter=1 #net.ipv4.conf.all.rp_filter=1 # Uncomment the next line to enable TCP/IP SYN cookies #net.ipv4.tcp_syncookies=1 # Uncomment the next line to enable packet forwarding for IPv4 #net.ipv4.ip_forward=1 # Uncomment the next line to enable packet forwarding for IPv6 #net.ipv6.conf.all.forwarding=1 ################################################################### # Additional settings - these settings can improve the network # security of the host and prevent against some network attacks # including spoofing attacks and man in the middle attacks through # redirection. Some network environments, however, require that these # settings are disabled so review and enable them as needed. # # Ignore ICMP broadcasts #net.ipv4.icmp_echo_ignore_broadcasts = 1 # # Ignore bogus ICMP errors #net.ipv4.icmp_ignore_bogus_error_responses = 1 # # Do not accept ICMP redirects (prevent MITM attacks) #net.ipv4.conf.all.accept_redirects = 0 #net.ipv6.conf.all.accept_redirects = 0 # _or_ # Accept ICMP redirects only for gateways listed in our default # gateway list (enabled by default) # net.ipv4.conf.all.secure_redirects = 1 # # Do not send ICMP redirects (we are not a router) #net.ipv4.conf.all.send_redirects = 0 # # Do not accept IP source route packets (we are not a router) #net.ipv4.conf.all.accept_source_route = 0 #net.ipv6.conf.all.accept_source_route = 0 # # Log Martian Packets #net.ipv4.conf.all.log_martians = 1
A una Ubuntu Server:
$ ls /etc/sysctl.d/ 10-console-messages.conf 10-network-security.conf 10-zeropage.conf README
Per exemple a:
$ cat /etc/sysctl.d/10-network-security.conf
És on s'activa rp_filter per defecte a una Ubuntu.
Per aplicar els canvis (segons el README):
$ sudo service procps start
o
$ invoke-rc.d procps start
S'activen alguns paràmetres de seguretat per defecte.
IMPORTANT: Cal vigilar que en segons quines circumstàncies no s'ha d'activar (per exemple una màquina multihomed o un ruter. Consulteu Encaminament)
$ cat /etc/sysctl.d/10-network-security.conf # Turn on Source Address Verification in all interfaces to # prevent some spoofing attacks. net.ipv4.conf.default.rp_filter=1 net.ipv4.conf.all.rp_filter=1 # Turn on SYN-flood protections. Starting with 2.6.26, there is no loss # of TCP functionality/features under normal conditions. When flood # protections kick in under high unanswered-SYN load, the system # should remain more stable, with a trade off of some loss of TCP # functionality/features (e.g. TCP Window scaling). net.ipv4.tcp_syncookies=1
Per activar el forwarding cal modificar el fitxer sysctl.conf:
$ cat /etc/sysctl.conf | grep forward # Uncomment the next line to enable packet forwarding for IPv4 #net.ipv4.ip_forward=1 # Uncomment the next line to enable packet forwarding for IPv6 #net.ipv6.ip_forward=1
Per:
$ cat /etc/sysctl.conf | grep forward # Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1 # Uncomment the next line to enable packet forwarding for IPv6 net.ipv6.ip_forward=1
Consulteu també Encaminament.
Afegiu les següent línies al fitxer /etc/sysctl.conf:
#increase the amount of RAM pagecache is allowed to use #before we start moving it back to disk vm.pagecache="10 40 100"
# Controls IP packet forwarding net.ipv4.ip_forward = 1 # Controls source route verification net.ipv4.conf.default.rp_filter = 0 # Do not accept source routing net.ipv4.conf.default.accept_source_route = 0
Consulteu:
Squid#Servidor_proxy_transparent
Connection Tracking (Seguiment de connexions):
Consulteu:
Registre d'activitats sospitoses. ens permet registrar als logs del sistema aquelles situacions que són potencialment sospitoses. intent d'enviar paquets amb adreça no vàlida, paquets amb canvis de rutes i altres situacions similars. Es tracta d'una serie de situacions que en un funcionament normal de la xarxa no haurien de produir-se. Un exemple pot ser rebre un paquet amb una adreça d'origen 127.0.0.1
Per activar-lo:
# sysctl -w net.ipv4.conf.all.log_martians = 1 # sysctl -w net.ipv4.conf.default.log_martians = 1
rp són les sigles de reversed path. Aquest paràmetre del kernel activa la validació d'IP d'origen per reversed path.
IMPORTANT: En màquines multi-homed (amb múltiples IP) o routers aquesta opció ha d'estar desactivada. Consulteu Encaminament. Com es comenta a: http://www.frozentux.net/ipsysctl-tutorial/ipsysctl-tutorial.html#AEN634 Si esteu utilitzant Policy Routing es recomana desactivar aquesta opció
Serveix per evitar el spoofing (farsa).
El podeu activar/desactivar amb sysctl als fitxer /etc/sysctl.conf o a /etc/sysctl.d. Es pot canviar a /etc/sysctl.conf
$ sudo joe /etc/sysctl.conf # Uncomment the next two lines to enable Spoof protection (reverse-path filter) # Turn on Source Address Verification in all interfaces to # prevent some spoofing attacks net.ipv4.conf.default.rp_filter=1 net.ipv4.conf.all.rp_filter=1
Però compte que al fitxer /etc/sysctl.d/10-network-security.conf es torna a establir.
IMPORTANT: Però compte que es torna a canviar al fitxer /etc/sysctl.d
Per a cada targeta de xarxa es pot definir el paràmetre a part, per exemple eth0:
/proc/sys/net/ipv4/conf/eth0/rp_filter
TODO
El spoofing consiste en modificar la dirección origen de un paquete de forma que la máquina que recibe el paquete se crea que proviene de una maquina de confianza, normalmente se usa 127.0.0.1. Por ejemplo, si yo soy un malo maloso y quiero atacar el firewall que estamos montando una forma de hacerlo sería haciendome pasar por uno de los equipos de la oficina de forma que utilizaría una dirección de tipo 192.168.0.x, como no estoy en la oficina esta petición entrará por eth1 y no por eth0, que es por donde debería venir como me muestra la tabla de rutas.
firewall:/# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 127.0.0.0 * 255.255.255.0 U 0 0 0 lo 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 10.42.0.0 * 255.255.0.0 U 0 0 0 eth1 default * 0.0.0.0 U 0 0 0 eth1
El kernel de linux viene con un mecanismo de protección que implementa lo especificado en el RFC1812, para habilitarlo haremos lo siguiente:
firewall:/# for x in /proc/sys/net/ipv4/conf/*; do > echo "1" > $x/rp_filter > done
Esta opción es muy recomendable
Accepta paquets amb l'opció SRR. Per que una interfície ho permeti cal que estigui activat conf/all/accept_source_route i el propi de la interfície.
Vegeu també:
Vegeu també
Consulteu REISUB