Récupérer l’adresse IP locale sous Linux sans droits root

Voici 2 commandes pour récupérer votre adresse IP locale qui n’ont pas besoin des droits root :

$ hostname -I
192.168.0.3
$ ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 70:52:04:73:48:2a brd ff:ff:ff:ff:ff:ff
3: wlan0:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 5d:50:4a:46:8b:27 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.3/24 brd 192.168.0.1 scope global dynamic wlan0
       valid_lft 8014sec preferred_lft 8014sec
    inet6 fe80::5d50:4aff:fe46:8b27/64 scope link 
       valid_lft forever preferred_lft forever
$ /sbin/ifconfig 
eth0      Link encap:Ethernet  HWaddr 70:52:04:73:48:2a  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interruption:20 Mémoire:f1600000-f1620000 

lo        Link encap:Boucle locale  
          inet adr:127.0.0.1  Masque:255.0.0.0
          adr inet6: ::1/128 Scope:Hôte
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:237 errors:0 dropped:0 overruns:0 frame:0
          TX packets:237 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:0 
          RX bytes:20363 (19.8 KiB)  TX bytes:20363 (19.8 KiB)

wlan0     Link encap:Ethernet  HWaddr 5d:50:4a:46:8b:27  
          inet adr:192.168.0.3  Bcast:192.168.0.1  Masque:255.255.255.0
          adr inet6: fe80::5d50:4aff:fe46:8b27/64 Scope:Lien
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15053 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14008 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000 
          RX bytes:13286403 (12.6 MiB)  TX bytes:11979059 (11.4 MiB)
9 Comments

Add a Comment

Ce site utilise Akismet pour réduire les indésirables. Apprenez comment vos données de commentaires sont traitées.