Internet

De WikiMar
Dreceres ràpides: navegació, cerca

Connectar Wifi (Wireless) a internet

iwconfig rausb0 mode managed essid NOM_WIFI enc on key CLAU channel 10

Configurar IP

Obtenir ip automàticament

dhcpcd rausb0  (-k)

Connectar a Internet amb IP fixa

ifconfig eth0 10.8.0.70 netmask 255.255.255.0

Compartir una connexió a internet

Automaticament:

Amb el NetworkManager. Pestanya IPv4 de la connexio que NO te internet, seleccionar "Shared to other computers".

Mes info: https://jeremy.visser.name/2009/03/simple-internet-connection-sharing-with-networkmanager/

Manualment:

En el ordinador que comparteix:

  • 1 Configurar ip
ifconfig eth0 10.0.0.1 netmask 255.255.255.0
  • 2 ip_forward:
echo 1 > /proc/sys/net/ipv4/ip_forward
  • 3 iptables:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

En el ordinador client:

  • 1 Configurar ip
ifconfig eth0 10.0.0.2 netmask 255.255.255.0
  • 2 route:
route add default gw 10.0.0.1
  • 3 DNS:
vi /etc/resolv.conf

afegir els nameserver del ordinador que comparteix o el 8.8.8.8 DNS de google

Detectar quins parametres utiliza una xarxa

Posar la targeta en mode Promisc:

sudo ifconfig eth0 promisc

Imprimir els paquets

sudo tcpdump -i eth0 -s 0 

(Funciona clar, si estas connectat a un Hub no a un Switch)

Mes info sobre Packet Sniffing / sniffers: http://www.noah.org/wiki/Packet_sniffing

Connectar amb FTP

ftp ORDINADOR
passive off
bin
pwd
mput FITXER
...

Fer un traceroute per un port en concret

sudo traceroute -T -p21 ftp.valldelges.net

En aquest cas es fa el ping pel port 21


Mirar si un port esta lliure i quin programa hi ha

lsof -i tcp:3000


Llistar ports oberts

netstat -panut | grep LISTEN

o bé

netstat -ntl

o bé

ss -a | grep LISTEN

o bé

nmap -P0 localhost

Més info: http://emergeworld.blogspot.com/2007/07/cmo-listar-los-puertos-abiertos-de-una.html


Escanejar maquines enegades

Fer ping a la direccio broadcast

ping -b -c5 192.168.1.255

Using nmap

nmap -sP 192.168.1.60-70

find all active IP addresses in a network

You send a unicast ICMP packet to each host. Many firewalls will drop that ICMP. However, in order to send the ICMP, you'll have first done an ARP request and the remote machine is unlikely to ignore that, so the computer will be in your ARP table.

nmap -sP 192.168.1.0/24; arp -n | grep "192.168.1.[0-9]* *ether"


Bash script and ping

for ip in 192.168.1.{1..10}; do ping -t 1 $ip > /dev/null && echo "${ip} is up"; done

apr-scan

More info: http://www.commandlinefu.com/commands/view/3268/find-all-active-ip-addresses-in-a-network

find all active IP addresses in a network

Have to run as superuser... but easier and more informational if you are looking for actual devices. Need to install arp-scan.

arp-scan -l

Find & watch active IP and MAC addresses in a wireless network in real time. (IPv4 only)

sudo watch arp-scan --interface=wlan0 --localnet