搭建django网站,局域网内其他主机无法访问问题

1.打开django网站服务器

python manage.py runserver 192.168.1.115:8000

[root@localhost test]# python manage.py runserver 192.168.1.115:8000
Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

March 28, 2016 - 13:11:57
Django version 1.9.4, using settings 'django_zll.settings'
Starting development server at http://192.168.1.115:8000/
Quit the server with CONTROL-C.




2.在局域网中另外一个pc访问网址,访问失败


3.这很有可能是因为服务器开启防火墙导致,检查服务器是否开启防火墙

[root@localhost Python-2.7.3]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         


发现开启了防火墙,执行下面命令关闭防火墙后就可以正常访问网址了

service iptables stop

ps:

防火墙相关服务开启命令如下:

CentOS Linux开启和关闭防火墙命令有两种,一种是临时的,重启即复原;另外一种是永久性的,重启不会复原。

1) 临时生效,重启后复原
开启: service iptables start
关闭: service iptables stop

2) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值