通过无线网络设置本地IP以在Ubuntu上创建本地服务器

时间:2013-08-09 01:13:52

标签: django ubuntu localhost network-protocols wireless

我正在使用GNU / Linux Ubuntu 13.04 Raring Ringtail x32位。我家里有一个无线网络连接,我希望连接的其他计算机都能看到我的本地主机。

我使用Python Django 1.4创建了一个网页,它在http://localhost:8000/中监听。我读到了它,但是,我不知道如何设置我的本地IP。

当我在终端ifconfig中写这个时,它会显示:

eth0 Link encap:Ethernet HWaddr 18:a9:05:dd:32:fc
    UP 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:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)            

eth1 Link encap:Ethernet HWaddr 90:4c:e5:3b:fe:c3
    inet addr:192.168.1.18 Bcast:192.168.1.255 Mask:255.255.255.0
    inet6 addr: fe80::924c:e5ff:fe3b:fec3/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:9880 errors:0 dropped:0 overruns:0 frame:7882
    TX packets:9386 errors:12 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:9839915 (9.8 MB) TX bytes:1643176 (1.6 MB)
    Interrupt:16 Base address:0xc000            

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:65536 Metric:1
    RX packets:1535 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1535 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:222541 (222.5 KB) TX bytes:222541 (222.5 KB)

如何设置它以使用我的无线连接在其他计算机上查看我的本地网站。

非常感谢你的帮助!

2 个答案:

答案 0 :(得分:2)

您可以将Django服务器绑定到计算机的IP地址,然后在同一LAN上的其他计算机上点击它:

$ python manage.py runserver 192.168.1.18:8000

答案 1 :(得分:1)

只需将其添加到正常的runserver命令:

python manage.py runserver 0.0.0.0:8000

然后,本地网络上的其他人可以通过以下方式访问它:

http://192.168.1.18:8000