2009-07-27 3 views
13

Come dice il titolo, in un'interfaccia Ethernet multipla con più ambienti IP, il server di test Django predefinito non è collegato alla rete a cui posso accedere dal mio PC. C'è un modo per specificare l'interfaccia che il server di prova Django dovrebbe usare?Come specificare su quale interfaccia deve essere ascoltato il server di prova Django?

- Aggiunto -

La configurazione di rete è qui. Mi sto collegando alla macchina tramite l'indirizzo 143.248.x.y dal mio PC. (Il mio PC è anche nella rete 143.248.a.b.) Ma non riesco a trovare questo indirizzo. Apache normale funziona molto bene così come altri daemon personalizzati in esecuzione su altre porte.

Colui che ha configurato questa macchina non è me, così io non ne so molto i dettagli della rete ...

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) 

- Aggiunto (2) -

Finalmente ho usato w3m (un browser web in modalità testo che gira sul terminale) per connettersi da localhost. : P

risposta

0

No. Non è come funziona. L'interfase ha un indirizzo IP, hai una rete con il server di prova e il tuo PC. Dovresti connetterti a quell'IP (possibilmente con una porta alternativa che hai specificato), e questo è tutto. Se si hanno solo questi due dispositivi nella rete, è molto probabile che entrambi debbano avere indirizzi IP statici. (o, se non c'è rete reciproca, non è possibile connettersi l'un l'altro).

2

Sì, se l'IP dell'interfaccia è per esempio 192.168.1.2 e si desidera eseguire sulla porta 8080, avviare il server di sviluppo come questo:

./manage.py runserver 192.168.1.2:8080 
34

Credo che il PO si riferisce ad avere multipla interfacce configurate sulla macchina di prova.

È possibile specificare l'indirizzo IP che Django si legherà come segue:

# python manage.py runserver 0.0.0.0:8000 

Questo legherebbe Django a tutte le interfacce sulla porta 8000. È possibile passare qualsiasi indirizzo IP attivo al posto del 0.0.0.0, quindi usa semplicemente l'indirizzo IP dell'interfaccia a cui vuoi collegarti.

Spero che questo aiuti.

+0

Non capisco perché due risposte che essenzialmente ripetute le mie siano state svalutate (mentre la mia no):/ –

+1

@sztomi: Gli altri avevano esempi che concretizzavano i punti astratti. L'utilizzo di esempi è un ottimo modo per chiarire e supportare notevolmente il lettore. – hughdbrown