gpt4 book ai didi

python - 如何指定 Django 测试服务器应该监听哪个 eth 接口(interface)?

转载 作者:太空狗 更新时间:2023-10-29 17:10:28 24 4
gpt4 key购买 nike

正如标题所说,在具有多个 IP 环境的多个以太网接口(interface)中,默认的 Django 测试服务器未连接到我可以从我的 PC 访问的网络。有什么方法可以指定 Django 测试服务器应该使用的接口(interface)吗?

-- 添加了 --

网络配置在这里。我从我的电脑通过 143.248.x.y 地址连接到机器。 (我的电脑也在143.248.a.b网络。)但是我找不到这个地址。普通的 apache 与在其他端口上运行的其他自定义守护进程一样运行良好。

配置这台机器的不是我,所以我不太了解网络的细节...

eth0      Link encap:Ethernet  HWaddr 00:15:17:88:97:78
inet addr:192.168.6.100 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:fe88:9778/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:441917680 errors:0 dropped:0 overruns:0 frame:0
TX packets:357190979 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:191664873035 (178.5 GB) TX bytes:324846526526 (302.5 GB)

eth1 Link encap:Ethernet HWaddr 00:15:17:88:97:79
inet addr:172.10.1.100 Bcast:172.10.1.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:fe88:9779/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1113794891 errors:0 dropped:97 overruns:0 frame:0
TX packets:699821135 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:843942929141 (785.9 GB) TX bytes:838436421169 (780.8 GB)
Base address:0x2000 Memory:b8800000-b8820000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1085510396 errors:0 dropped:0 overruns:0 frame:0
TX packets:1085510396 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:422100792153 (393.1 GB) TX bytes:422100792153 (393.1 GB)

peth0 Link encap:Ethernet HWaddr 00:15:17:88:97:78
inet6 addr: fe80::215:17ff:fe88:9778/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:441918386 errors:0 dropped:742 overruns:0 frame:0
TX packets:515286699 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:199626686230 (185.9 GB) TX bytes:337365591758 (314.1 GB)
Base address:0x2020 Memory:b8820000-b8840000

veth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

veth1 Link encap:Ethernet HWaddr 00:00:00:00:00:00
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

veth2 Link encap:Ethernet HWaddr 00:00:00:00:00:00
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

veth3 Link encap:Ethernet HWaddr 00:00:00:00:00:00
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

vif0.0 Link encap:Ethernet HWaddr fe:ff:ff:ff:ff:ff
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

vif0.1 Link encap:Ethernet HWaddr fe:ff:ff:ff:ff:ff
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

vif0.2 Link encap:Ethernet HWaddr fe:ff:ff:ff:ff:ff
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

vif0.3 Link encap:Ethernet HWaddr fe:ff:ff:ff:ff:ff
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 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

-- 新增(2)--

最后,我使用 w3m(一种在终端上运行的文本模式 Web 浏览器)从本地主机进行连接。 :P

最佳答案

我认为OP指的是在测试机上配置多个接口(interface)。

您可以指定 Django 将绑定(bind)到的 IP 地址,如下所示:

# python manage.py runserver 0.0.0.0:8000

这会将 Django 绑定(bind)到端口 8000 上的所有接口(interface)。您可以传递任何事件 IP 地址来代替 0.0.0.0,因此只需使用您要绑定(bind)到的接口(interface)的 IP 地址即可。

希望这对您有所帮助。

关于python - 如何指定 Django 测试服务器应该监听哪个 eth 接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1188205/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com