如何指定Django测试服务器应该监听哪个eth接口? [英] How to specify which eth interface Django test server should listen on?

查看:158
本文介绍了如何指定Django测试服务器应该监听哪个eth接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如标题所示,在具有多个IP环境的多个以太网接口中,默认的Django测试服务器不附加到可以从我的PC访问的网络。有没有办法指定Django测试服务器应该使用的接口?



- 添加 -



网络配置在这里。
我从我的电脑通过143.248.x.y地址连接到机器。 (我的电脑也在143.248.a.b网络。)但是我找不到这个地址。正常apache的工作原理非常好,以及在其他端口上运行的其他自定义守护程序。



配置本机的人不是我,所以我不太了解网络...

  eth0链接封装:以太网HWaddr 00:15:17:88:97:78 
inet addr:192.168.6.100 Bcast:192.168.2.255掩码:255.255.255.0
inet6 addr:fe80 :: 215:17ff:fe88:9778/64范围:链接
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric :1
RX数据包:441917680错误:0丢弃:0超支:0帧:0
TX数据包:357190979错误:0丢弃:0超支:0运营商:0
碰撞:0 txqueuelen :0
RX字节:191664873035(178.5 GB)TX字节:324846526526(302.5 GB)

eth1链接封装:以太网HWaddr 00:15:17:88:97:79
inet addr:172.10.1.100 Bcast:172.10.1.255面具:255.255.255.0
inet6 addr:fe80 :: 215:17ff:fe88:9779/64范围:链接
UP BRO ADCAST RUNNING MULTICAST MTU:1500公制:1
RX数据包:1113794891错误:0丢弃:97超支:0帧:0
TX数据包:699821135错误:0丢弃:0超支:0运营商:0
碰撞:0 txqueuelen:1000
RX字节:843942929141(785.9 GB)TX字节:838436421169(780.8 GB)
基地址:0x2000内存:b8800000-b8820000

lo Link encap:本地环回
inet addr:127.0.0.1掩码:255.0.0.0
inet6 addr :: :: 1/128范围:主机
UP LOOPBACK RUNNING MTU:16436公制:1
RX数据包:1085510396错误:0丢弃:0超支:0帧:0
TX数据包:1085510396错误:0丢弃:0超支:0运营商:0
碰撞:0 txqueuelen:0
RX字节:422100792153(393.1 GB)TX字节:422100792153(393.1 GB)

peth0链接封装:以太网HWaddr 00:15:17:88:97:78
inet6 addr :fe80 :: 215:17ff:fe88:9778/64范围:链接
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500公制:1
RX数据包:441918386错误:0丢弃:742超支:0帧:0
发送数据包:515286699错误:0丢弃:0超支:0运营商: 0
碰撞:0 txqueuelen:1000
RX字节:199626686230(185.9 GB)TX字节:337365591758(314.1 GB)
基地址:0x2020内存:b8820000-b8840000

veth0链接封装:以太网HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超限:0帧: 0
TX数据包:0错误:0丢弃:0超支:0载波:0
碰撞:0 txqueuelen:0
RX字节:0(0.0 B)TX字节:0(0.0 B )

veth1链接封装:以太网HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超支:0帧:0
TX数据包:0错误:0丢弃:0超支:0载波:0
碰撞:0 txqueuelen:0
RX字节:0(0.0 B)TX字节:0(0.0 B)

veth2链路封装:以太网HWaddr 00:00 :00:00:00:00
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超支:0帧:0
TX数据包:0错误: 0丢弃:0超支:0运营商:0
碰撞:0 txqueuelen:0
RX字节:0(0.0 B)TX字节:0(0.0 B)

veth3链接encap:以太网HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超限:0帧:0
TX数据包:0错误:0丢弃:0超支:0载波:0
冲突:0 txqueuelen:0
RX字节:0(0.0 B)TX字节:0(0.0 B)

vif0.0链接封装:以太网HWaddr fe:ff:ff:ff:ff:ff
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超支:0框:0
TX数据包:0错误:0丢弃:0超支:0载波:0
碰撞:0 txqueuelen:0
RX字节:0(0.0 B)TX字节:0(0.0 B)

vif0.1链路封装:以太网HWaddr fe:ff:ff:ff:ff:ff
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超支:0帧:0
TX数据包:0错误:0丢弃:0超支:0载体:0
碰撞:0 txqueuelen:0
RX字节:0(0.0 B)TX字节: 0(0.0 B)

vif0.2链接封装:以太网HWaddr fe:ff:ff:ff:ff:ff
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超支:0帧:0
TX数据包:0错误:0丢弃:0超支:0载体:0
碰撞:0 txqueuelen:0
RX字节:0(0.0 B)TX字节:0(0.0 B)

vif0.3链路封装:以太网HWaddr fe:ff:ff:ff:ff:ff
BROADCAST MULTICAST MTU:1500公制:1
RX数据包:0错误:0丢弃:0超支:0帧:0
TX数据包:0错误:0丢弃:0超支:0载体:0
碰撞:0 txqueuelen:0
RX字节:0(0.0 B)TX字节:0(0.0 B)

- 添加(2) -



最后我用w3m(在终端上运行的文本模式的网络浏览器)从localhost连接。 :P

解决方案

我认为OP是指在测试机上配置了多个接口。



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

 #python manage。 py runserver 0.0.0.0:8000 

这将绑定Django到端口8000上的所有接口。您可以传递任何活动IP地址代替0.0.0.0,所以只需使用要绑定的接口的IP地址。



希望这有帮助。


As the title says, in a multiple ethernet interfaces with multiple IP environment, the default Django test server is not attached to the network that I can access from my PC. Is there any way to specify the interface which Django test server should use?

-- Added --

The network configuration is here. I'm connecting to the machine via 143.248.x.y address from my PC. (My PC is also in 143.248.a.b network.) But I cannot find this address. Normal apache works very well as well as other custom daemons running on other ports.

The one who configured this machine is not me, so I don't know much details of the network...

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)

-- Added (2) --

Finally I used w3m (a text-mode web browser which runs on terminal) to connect from localhost. :P

解决方案

I think the OP is referring to having multiple interfaces configured on the test machine.

You can specify the IP address that Django will bind to as follows:

# python manage.py runserver 0.0.0.0:8000

This would bind Django to all interfaces on port 8000. You can pass any active IP address in place of 0.0.0.0, so simply use the IP address of the interface you want to bind to.

Hope this helps.

这篇关于如何指定Django测试服务器应该监听哪个eth接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆