Accessing website from other computer on LAN

General support questions
Post Reply
itdev
Posts: 18
Joined: 2015/09/04 10:02:35

Accessing website from other computer on LAN

Post by itdev » 2015/09/04 10:10:51

Hi,
I am new to centos. I have a php project which has to be hosted on centos 6.5. but I am not able to access the site from other computer using url (http://server ip address/sitename). Please some on give me the procedure so that anyone on my LAN can visit the site from their computer by typing url. Please help me. :?

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Accessing website from other computer on LAN

Post by TrevorH » 2015/09/04 10:40:24

You will need to open the port in the iptables firewall. Look in /etc/sysconfig/iptables and you should find that port 22 is already allowed so duplicate that line and change port 22 to 80 (if you are using 80).

You should not be using CentOS 6.5. Please run yum update to get yourself current - 6.7 at the moment. There are unfixed security vulnerabilities in previous releases and 6.5 is about 2 years old so really needs it.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

itdev
Posts: 18
Joined: 2015/09/04 10:02:35

Re: Accessing website from other computer on LAN

Post by itdev » 2015/09/04 11:34:35

Thanks for replying.
Below is the content of iptables file of my system. my php project folder name is krish and IP is 192.168.0.41. I want to view the site from other computer by entering http://192.168.0.41/krish. Please check the iptables content below and kindly suggest how to proceed.

IPTABLES FILE CONTENT
-------------------------------------------

# Generated by iptables-save v1.4.7 on Fri Sep 4 14:33:09 2015
*nat
:PREROUTING ACCEPT [1351:149877]
:POSTROUTING ACCEPT [1774:110859]
:OUTPUT ACCEPT [1774:110859]
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE
COMMIT
# Completed on Fri Sep 4 14:33:09 2015
# Generated by iptables-save v1.4.7 on Fri Sep 4 14:33:09 2015
*mangle
:PREROUTING ACCEPT [29244:28371842]
:INPUT ACCEPT [28945:28355509]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [24100:6195301]
:POSTROUTING ACCEPT [24100:6195301]
-A POSTROUTING -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT
# Completed on Fri Sep 4 14:33:09 2015
# Generated by iptables-save v1.4.7 on Fri Sep 4 14:33:09 2015
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [39:4385]
-A INPUT -i virbr0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -i virbr0 -p udp -m udp --dport 67 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 67 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A FORWARD -d 192.168.122.0/24 -o virbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 192.168.122.0/24 -i virbr0 -j ACCEPT
-A FORWARD -i virbr0 -o virbr0 -j ACCEPT
-A FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Fri Sep 4 14:33:09 2015

markkuk
Posts: 739
Joined: 2007/09/07 10:56:28
Location: Finland

Re: Accessing website from other computer on LAN

Post by markkuk » 2015/09/04 11:37:37

itdev wrote:

Code: Select all

-A INPUT -j REJECT --reject-with icmp-host-prohibited 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT 
Iptables rules are applied in order, that's why any rules added below the REJECT rule will be ignored. Move the rules to accept HTTP packets above the REJECT.

itdev
Posts: 18
Joined: 2015/09/04 10:02:35

Re: Accessing website from other computer on LAN

Post by itdev » 2015/09/04 11:52:50

THANKS A LOT Markkuk......

ITS WORKING!!! :)

Post Reply