Diferència entre revisions de la pàgina «A2. Eines bàsiques. Instal·lació, configuració i comprovació»
(→Comprovació i connectivitat) |
(→Eines entorns Linux) |
||
Línia 44: | Línia 44: | ||
=== arp === | === arp === | ||
+ | |||
+ | Consulta i gestiona la taula arp de l'equip | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ sudo arp -n | ||
+ | Address HWtype HWaddress Flags Mask Iface | ||
+ | 192.168.1.21 (incomplete) enp2s0 | ||
+ | 192.168.1.1 ether 64:6e:60:25:fd:00 C enp2s0 | ||
+ | 192.168.1.20 (incomplete) enp2s0 | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | === ethtool === | ||
+ | |||
+ | |||
+ | Consulta els paràmetres Ethernet d'una interfície | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ sudo ethtool enp2s0 | ||
+ | Settings for enp2s0: | ||
+ | Supported ports: [ TP MII ] | ||
+ | Supported link modes: 10baseT/Half 10baseT/Full | ||
+ | 100baseT/Half 100baseT/Full | ||
+ | 1000baseT/Full | ||
+ | Supported pause frame use: Symmetric Receive-only | ||
+ | Supports auto-negotiation: Yes | ||
+ | Supported FEC modes: Not reported | ||
+ | Advertised link modes: 10baseT/Half 10baseT/Full | ||
+ | 100baseT/Half 100baseT/Full | ||
+ | 1000baseT/Full | ||
+ | Advertised pause frame use: Symmetric Receive-only | ||
+ | Advertised auto-negotiation: Yes | ||
+ | Advertised FEC modes: Not reported | ||
+ | Link partner advertised link modes: 10baseT/Half 10baseT/Full | ||
+ | 100baseT/Half 100baseT/Full | ||
+ | 1000baseT/Half 1000baseT/Full | ||
+ | Link partner advertised pause frame use: No | ||
+ | Link partner advertised auto-negotiation: Yes | ||
+ | Link partner advertised FEC modes: Not reported | ||
+ | Speed: 1000Mb/s | ||
+ | Duplex: Full | ||
+ | Auto-negotiation: on | ||
+ | master-slave cfg: preferred slave | ||
+ | master-slave status: slave | ||
+ | Port: Twisted Pair | ||
+ | PHYAD: 0 | ||
+ | Transceiver: external | ||
+ | MDI-X: Unknown | ||
+ | Supports Wake-on: pumbg | ||
+ | Wake-on: d | ||
+ | Link detected: yes | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | === iwconfig | iw === | ||
+ | |||
+ | Consulta la informació d'una interfície WiFi | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ iwconfig wlan1 | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ iw dev | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ iw phy | ||
+ | </code></pre></html> | ||
+ | |||
Línia 49: | Línia 121: | ||
− | + | Consulta i configura l'adreçament IP de les interfícies de xarxa. Es troba disponible al '''paquet net-tools'''. | |
− | + | <html><pre><code class="basic"> | |
+ | $ sudo ifconfig enp2s0 | ||
+ | enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 | ||
+ | inet 192.168.1.137 netmask 255.255.255.0 broadcast 192.168.1.255 | ||
+ | inet6 2a0c:5a84:c40f:c800:4727:68bb:8d05:6999 prefixlen 64 scopeid 0x0<global> | ||
+ | inet6 fe80::201:6cff:fed2:cca6 prefixlen 64 scopeid 0x20<link> | ||
+ | inet6 2a0c:5a84:c40f:c800:201:6cff:fed2:cca6 prefixlen 64 scopeid 0x0<global> | ||
+ | ether 00:01:6c:d2:cc:a6 txqueuelen 1000 (Ethernet) | ||
+ | RX packets 24945 bytes 19127846 (18.2 MiB) | ||
+ | RX errors 0 dropped 0 overruns 0 frame 0 | ||
+ | TX packets 18461 bytes 7344974 (7.0 MiB) | ||
+ | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
+ | </code></pre></html> | ||
− | |||
=== ip === | === ip === | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | === route === | ||
+ | |||
+ | Consulta i gestiona la taula de ruta de l'equip | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ sudo route -n | ||
+ | Kernel IP routing table | ||
+ | Destination Gateway Genmask Flags Metric Ref Use Iface | ||
+ | 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp2s0 | ||
+ | 0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp2s0 | ||
+ | 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0 | ||
+ | 192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr1 | ||
+ | 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
=== netstat === | === netstat === | ||
+ | Consulta informació i estadístiques de les comunicacions de xarxa de l'equip | ||
+ | |||
+ | Per exemple connexions TCP sobre IPv4 | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ netstat -nt -4 | ||
+ | Active Internet connections (w/o servers) | ||
+ | Proto Recv-Q Send-Q Local Address Foreign Address State | ||
+ | tcp 0 0 192.168.1.137:54798 87.106.143.229:443 ESTABLISHED | ||
+ | tcp 0 0 192.168.1.137:54554 34.107.243.93:443 ESTABLISHED | ||
+ | tcp 0 0 192.168.1.137:33110 74.120.9.237:443 ESTABLISHED | ||
+ | </code></pre></html> | ||
+ | |||
+ | |||
+ | Ports en mode escolta (listening) UDP sobre IPv4. Serveis UDP de l'equip | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ sudo netstat -nlu -p -4 | ||
+ | Active Internet connections (only servers) | ||
+ | Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name | ||
+ | udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named | ||
+ | udp 0 0 127.0.0.53:53 0.0.0.0:* 667/systemd-resolve | ||
+ | udp 0 0 0.0.0.0:67 0.0.0.0:* 2243/dnsmasq | ||
+ | udp 0 0 0.0.0.0:67 0.0.0.0:* 2192/dnsmasq | ||
+ | udp 0 0 0.0.0.0:68 0.0.0.0:* 1326/dhclient | ||
+ | udp 0 0 0.0.0.0:69 0.0.0.0:* 1562/in.tftpd | ||
+ | udp 0 0 0.0.0.0:111 0.0.0.0:* 1/init | ||
+ | udp 0 0 192.168.1.255:137 0.0.0.0:* 1487/nmbd | ||
+ | udp 0 0 192.168.1.137:137 0.0.0.0:* 1487/nmbd | ||
+ | udp 0 0 0.0.0.0:137 0.0.0.0:* 1487/nmbd | ||
+ | udp 0 0 192.168.1.255:138 0.0.0.0:* 1487/nmbd | ||
+ | udp 0 0 192.168.1.137:138 0.0.0.0:* 1487/nmbd | ||
+ | udp 0 0 0.0.0.0:138 0.0.0.0:* 1487/nmbd | ||
+ | udp 0 0 0.0.0.0:631 0.0.0.0:* 1704/cups-browsed | ||
+ | udp 0 0 0.0.0.0:50077 0.0.0.0:* 705/avahi-daemon: r | ||
+ | udp 0 0 0.0.0.0:42420 0.0.0.0:* 4722/pcloud | ||
+ | udp 0 0 0.0.0.0:5353 0.0.0.0:* 705/avahi-daemon: r | ||
+ | udp 0 0 0.0.0.0:5355 0.0.0.0:* 667/systemd-resolve | ||
+ | </code></pre></html> | ||
+ | |||
+ | Estadístiques UDP sobre IPv4 | ||
+ | |||
+ | <html><pre><code class="basic"> | ||
+ | $ sudo netstat -su -4 | ||
+ | IcmpMsg: | ||
+ | InType0: 12 | ||
+ | InType3: 19 | ||
+ | InType11: 77 | ||
+ | OutType3: 2 | ||
+ | OutType8: 43 | ||
+ | Udp: | ||
+ | 623 packets received | ||
+ | 0 packets to unknown port received | ||
+ | 0 packet receive errors | ||
+ | 497 packets sent | ||
+ | 0 receive buffer errors | ||
+ | 0 send buffer errors | ||
+ | IgnoredMulti: 10 | ||
+ | UdpLite: | ||
+ | IpExt: | ||
+ | InMcastPkts: 104 | ||
+ | OutMcastPkts: 107 | ||
+ | InBcastPkts: 199 | ||
+ | OutBcastPkts: 185 | ||
+ | InOctets: 5640736 | ||
+ | OutOctets: 783409 | ||
+ | InMcastOctets: 14320 | ||
+ | OutMcastOctets: 14413 | ||
+ | InBcastOctets: 34983 | ||
+ | OutBcastOctets: 30151 | ||
+ | InNoECTPkts: 6138 | ||
+ | </code></pre></html> | ||
== Domini == | == Domini == |
Revisió del 11:56, 20 set 2024
tornar M7 - Planificació i administració de xarxes
Contingut
Eines entorns Linux
Comprovació i connectivitat
ping
Utilitza el protocol ICMP per comprovar la connectivitat amb equips remots
$ ping -c 2 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.27 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.77 ms
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.766/2.016/2.266/0.250 ms
traceroute | tracepath
Printa la ruta que segueixen els paquets fins arribar a equips remots. Utilitza el camp TTL dels paquets IP
$ traceroute -n 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 192.168.1.1 2.208 ms 1.652 ms 1.546 ms
2 10.0.3.108 1.947 ms 2.206 ms 1.345 ms
3 172.16.11.97 1.708 ms 1.505 ms 1.642 ms
4 10.220.98.238 1.822 ms 1.743 ms 1.732 ms
5 * * *
6 81.196.118.208 17.104 ms * 16.975 ms
7 91.232.81.211 17.084 ms 74.125.119.226 17.231 ms 91.232.81.211 17.062 ms
8 192.178.110.85 14.710 ms 142.250.213.243 17.113 ms 192.178.110.151 18.154 ms
9 142.250.46.165 13.865 ms 74.125.253.203 18.217 ms 74.125.37.87 13.547 ms
10 8.8.8.8 17.808 ms 14.490 ms 13.861 ms
Informació i adreçament
arp
Consulta i gestiona la taula arp de l'equip
$ sudo arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.1.21 (incomplete) enp2s0
192.168.1.1 ether 64:6e:60:25:fd:00 C enp2s0
192.168.1.20 (incomplete) enp2s0
ethtool
Consulta els paràmetres Ethernet d'una interfície
$ sudo ethtool enp2s0
Settings for enp2s0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Auto-negotiation: on
master-slave cfg: preferred slave
master-slave status: slave
Port: Twisted Pair
PHYAD: 0
Transceiver: external
MDI-X: Unknown
Supports Wake-on: pumbg
Wake-on: d
Link detected: yes
iwconfig | iw
Consulta la informació d'una interfície WiFi
$ iwconfig wlan1
$ iw dev
$ iw phy
ifconfig
Consulta i configura l'adreçament IP de les interfícies de xarxa. Es troba disponible al paquet net-tools.
$ sudo ifconfig enp2s0
enp2s0: flags=4163 mtu 1500
inet 192.168.1.137 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 2a0c:5a84:c40f:c800:4727:68bb:8d05:6999 prefixlen 64 scopeid 0x0
inet6 fe80::201:6cff:fed2:cca6 prefixlen 64 scopeid 0x20
inet6 2a0c:5a84:c40f:c800:201:6cff:fed2:cca6 prefixlen 64 scopeid 0x0
ether 00:01:6c:d2:cc:a6 txqueuelen 1000 (Ethernet)
RX packets 24945 bytes 19127846 (18.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18461 bytes 7344974 (7.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ip
route
Consulta i gestiona la taula de ruta de l'equip
$ sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp2s0
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp2s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr1
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
netstat
Consulta informació i estadístiques de les comunicacions de xarxa de l'equip
Per exemple connexions TCP sobre IPv4
$ netstat -nt -4
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.1.137:54798 87.106.143.229:443 ESTABLISHED
tcp 0 0 192.168.1.137:54554 34.107.243.93:443 ESTABLISHED
tcp 0 0 192.168.1.137:33110 74.120.9.237:443 ESTABLISHED
Ports en mode escolta (listening) UDP sobre IPv4. Serveis UDP de l'equip
$ sudo netstat -nlu -p -4
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named
udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named
udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named
udp 0 0 192.168.1.137:53 0.0.0.0:* 1485/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 1485/named
udp 0 0 127.0.0.53:53 0.0.0.0:* 667/systemd-resolve
udp 0 0 0.0.0.0:67 0.0.0.0:* 2243/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 2192/dnsmasq
udp 0 0 0.0.0.0:68 0.0.0.0:* 1326/dhclient
udp 0 0 0.0.0.0:69 0.0.0.0:* 1562/in.tftpd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1/init
udp 0 0 192.168.1.255:137 0.0.0.0:* 1487/nmbd
udp 0 0 192.168.1.137:137 0.0.0.0:* 1487/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 1487/nmbd
udp 0 0 192.168.1.255:138 0.0.0.0:* 1487/nmbd
udp 0 0 192.168.1.137:138 0.0.0.0:* 1487/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 1487/nmbd
udp 0 0 0.0.0.0:631 0.0.0.0:* 1704/cups-browsed
udp 0 0 0.0.0.0:50077 0.0.0.0:* 705/avahi-daemon: r
udp 0 0 0.0.0.0:42420 0.0.0.0:* 4722/pcloud
udp 0 0 0.0.0.0:5353 0.0.0.0:* 705/avahi-daemon: r
udp 0 0 0.0.0.0:5355 0.0.0.0:* 667/systemd-resolve
Estadístiques UDP sobre IPv4
$ sudo netstat -su -4
IcmpMsg:
InType0: 12
InType3: 19
InType11: 77
OutType3: 2
OutType8: 43
Udp:
623 packets received
0 packets to unknown port received
0 packet receive errors
497 packets sent
0 receive buffer errors
0 send buffer errors
IgnoredMulti: 10
UdpLite:
IpExt:
InMcastPkts: 104
OutMcastPkts: 107
InBcastPkts: 199
OutBcastPkts: 185
InOctets: 5640736
OutOctets: 783409
InMcastOctets: 14320
OutMcastOctets: 14413
InBcastOctets: 34983
OutBcastOctets: 30151
InNoECTPkts: 6138
Domini
nslookup
dig
Recollida de dades
tcpdump
http://www.institutmarianao.es/mediawiki/index.php?title=Tcpdump_i_WireShark_(Ethereal) tcpdump
nmap
http://www.institutmarianao.es/mediawiki/index.php?title=Nmap nmap
Accés remot i transferència d'arxius
telnet
ftp/sftp
ssh / scp
Fitxers i serveis
Gestió de xarxa sistemes Debian
/etc/network/interfaces
/etc/init.d/networking
Gestió de xarxa sistemes Red Hat
Gestió de xarxa netplan
Resolució de noms
/etc/hostname /etc/hosts /etc/resolv.conf