简体   繁体   English

如何从Linux访问树莓派localhost?

[英]How to access a raspberry pi localhost from a linux?

I set up a php file in my raspberry pi so that I can access some files on it from my local network. 我在树莓派中设置了一个php文件,以便可以从本地网络访问其中的一些文件。

Within raspbian, it works well in any browser using localhost/test . 在raspbian中,它可以在任何使用localhost/test浏览器中正常运行。 I tested it also in a Windows and a Mac computer in the same network, using my.local.ip.address/test in my browsers and it also worked fine. 我还在浏览器中使用my.local.ip.address/test在同一网络中的Windows和Mac计算机上对其进行了my.local.ip.address/test ,并且效果也很好。

Now here is the problem: in my linux computer, it does not work. 现在是问题所在:在我的linux计算机上,它不起作用。 It simply says that "the site cannot be reached". 它只是说“无法到达该站点”。 I already tried disabling the firewall (UFW) but it doesn't change anything. 我已经尝试禁用防火墙(UFW),但它没有任何改变。

I also tried several browsers in linux and the result is the same. 我还在Linux中尝试了几种浏览器,结果是相同的。

I think I am overseeing something obvious but I cannot see it. 我认为我正在监督一些显而易见的事情,但我看不到它。

Could someone give me a pointer on what might be wrong? 有人可以给我指出什么地方出问题了吗?

ifconfig -a output (Linux machine) ifconfig -a输出(Linux机器)

在此处输入图片说明

ifconfig -a output (Raspberry Pi machine) ifconfig -a输出(Raspberry Pi机器)

在此处输入图片说明

It's possible that your Ubuntu machine is not in the same network. 您的Ubuntu计算机可能不在同一网络中。 You can try theses steps to confirm : 您可以尝试这些步骤来确认:

Ping

Go on your ubuntu machine and type : 在您的ubuntu机器上输入:

ping <rasp.pi.local.ip.address>

Go on your Raspberry Pi and type : 继续使用Raspberry Pi并输入:

ping <ubuntu.local.ip.address>

If the ping request do not succeed your machines are probably in different networks. 如果ping请求不成功,则您的计算机可能位于不同的网络中。 Your can use this command to watch the path used by packets between your ubuntu machine and your Raspberry Pi : 您可以使用此命令来观察ubuntu机器和Raspberry Pi之间的数据包所使用的路径:

traceroute <rasp.pi.local.ip.address>

Change network card settings 更改网卡设置

Before this step, check if your are able to connect your machines togather (switch, router, vlan...). 在执行此步骤之前,请检查您是否能够将计算机连接到一起(交换机,路由器,VLAN ...)。

ifconfig <interface> down    
ifconfig <interface> <ip.network> netmask <netmask.network>
ifconfig <interface> up

After completing theses steps try to ping again and access to your website. 完成这些步骤后,请尝试再次ping通并访问您的网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM