搭建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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章