3

I run raspberry with a strating webbrowser in kiosk mode and want to display the local ip-adress of my raspberry.

How can I do this? I Use PHP (httpd) I tried with

<?php print_r($SERVER); ?>

but this will give me only 127.0.0.1

I want the same output like

sudo ip addr show 

output:

eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:7c:ce:18 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.28/24 brd 192.168.0.255 scope global eth0

Any ideas?

  • I tried this and it works! <?php $host = gethostname(); $ip = gethostbyname($host); echo $ip; ?> – s3bi Nov 2 '13 at 18:38
  • 2
    feel free to answer your own question! – Tom Prats Nov 2 '13 at 18:44
  • i cant answer my own question during the first hours.... – s3bi Nov 2 '13 at 22:28
  • by the way, my problem isn´t solved. I get the IP 127.0.0.1 - too bad! – s3bi Nov 2 '13 at 22:29
4

This works for me

<?php system("hostname -I"); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.