I set apache in puppy linux and can see files in localhost.However,when I opened port80 and tried to connect apache from iphone but it failed. I could see just a white page.Maybe it wassn't 404 because it didn't show 404 error.(before I opened the port, i saw 404.)
I have configured apache.conf to Allow from all.
The access log and error logs showed nothing.
this is iptables-L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:domain
ACCEPT udp -- anywhere anywhere state NEW udp dpt:domain
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:finger
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:www
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:pop3
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:auth
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:imap2
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:443
ACCEPT udp -- anywhere anywhere state NEW udp dpt:syslog
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:printer
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:993
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:995
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:www
ACCEPT udp -- anywhere anywhere state NEW udp dpt:www
A CCEPT all -- anywhere anywhere state NEW
TRUSTED all -- anywhere anywhere state NEW
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DROP icmp -- anywhere anywhere state INVALID
Chain TRUSTED (1 references)
target prot opt source destination
ACCEPT icmp -- anywhere anywhere icmp echo-request
DROP icmp -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-port- unreachable
Netstat
tcp 0 0 192.168.100.100:80 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
How do i solve this problem?
tcp 0 0 192.168.100.100:80
The problem is right here. The server is listening at a specific, local, IP address, rather than 0.0.0.0.
Related
The gist of the issue is that if I create and run a docker container (from any image, I tried many) the container does not have network access beyond the default bridge Docker creates; even when using IP addresses (not URLs/names).
I.e.
docker run --rm -it busybox ping 8.8.8.8 hangs/fails for not having accessing the network
docker run --rm -it busybox ping 172.17.0.1 also fails (note that 172.17.0.1 is docker0's IP on the host and also the gateway set by docker in the container)
if I create two containers I can ping either one from the other fine
N.B:
I have two Ubuntu hosts (same version) both running Docker 19.03.6. On one of them (dev machine) I don't have the issue (it works just fine), on the other one I do. Which means it is most likely not an OS and/or Docker version issue but some sort of misconfiguration.
It is not the DNS issue asked in most questions I could find. In fact, it is not a DNS issue at all. It presents itself when I use direct IP addresses as well as with URLs.
I use iptables on the host; these are the rules on the one where it does not work (they are different on the dev machine where networking works fine but I cannot set the here the same):
Chain INPUT (policy DROP)
target prot opt source destination
f2b-postfix-sasl tcp -- anywhere anywhere multiport dports smtp,urd,submission,imap3,imaps,pop3,pop3s
f2b-sshd tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:ntp state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:imap2 state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:urd state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:urd state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:submission state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp state NEW,ESTABLISHED
Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:ntp state NEW,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spt:imap2 state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spt:imaps state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:urd state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spt:smtp state ESTABLISHED
Chain DOCKER (1 references)
target prot opt source destination
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain f2b-postfix-sasl (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain f2b-sshd (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere
RETURN all -- anywhere anywhere
I am not sure what else to add for clarification.
What should I do?
I have a Node.js express website that was listening on port 9000, the thing which was fine until I changed the port to 80, now it accepts only connection from local:
wget http://127.0.0.1/ -O -
curl 127.0.0.1:80
Locally it's working fine and they return the html page. But it does not accept remote connections from browser, either using the external IP address or the domain name.
# iptables
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
Well, i have figured the issue, it was my iptables rules forwarding remote connections from outside to another port.
I am new to ssh and Centos 6.4 and I want to run nodejs on port 80. But couldn't make it to work external.
When I type netstat -anp | grep 8080 I can see that my node listening.
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 7976/node
But it is not going external.
I tried to add settings to iptables and result is same again. It is not working.
[root#culturalinfluences ~]# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http /* node.js port */
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:webcache /* node.js port */
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Here is my nodejs
var port = 8080;
app.listen(port, "0.0.0.0" ,function() {
console.log("Listening on " + port);
});
Thank you four understand cause I am really new into linux and its iptables system. I am sure people like me will search the same issue and I hope they will find answer from this question.
Thank you for your helps.
You have a
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
right before the "http" ports you're allowing, so those rules will never be reached. Move the REJECT all rule to the bottom of the list instead.
Additionally you may want to use -n on the iptables command line to make sure the port numbers are right and aren't 80 instead of 8080 for example.
I have the following iptable rules and need help removing it if possible?
iptables -t nat -I PREROUTING -p tcp --dport 12348 -j DNAT --to-destination 192.168.0.5:12348
iptables -t nat -I PREROUTING -p tcp --dport 7778 -j DNAT --to-destination 192.168.0.5:7778
i know -D stands for delete rule but i cant figure out where in my command im meant to put it,
Cheers in advance
Updated ==>
Output of iptables -L -t nat:
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere anywhere tcp dpt:interwise to:192.168.0.5:7778
DNAT tcp -- anywhere anywhere tcp dpt:12348 to:192.168.0.5:12348
DNAT tcp -- anywhere anywhere tcp dpt:7772 to:192.168.0.5:7772
DNAT tcp -- anywhere anywhere tcp dpt:12342 to:192.168.0.5:12342
DNAT tcp -- anywhere anywhere tcp dpt:interwise to:192.168.0.5:7778
DNAT tcp -- anywhere anywhere tcp dpt:12348 to:192.168.0.5:12348
DNAT tcp -- anywhere anywhere tcp dpt:12348 to:192.168.0.5:12348
DNAT tcp -- anywhere anywhere tcp dpt:12342 to:192.168.0.5:12342
DNAT tcp -- anywhere anywhere tcp dpt:7772 to:192.168.0.5:7772
DNAT tcp -- anywhere anywhere tcp dpt:interwise to:192.168.0.5:7778
DNAT tcp -- anywhere anywhere tcp dpt:vstat to:192.168.0.5:7779
DNAT tcp -- anywhere anywhere tcp dpt:12349 to:192.168.0.5:12349
DNAT tcp -- anywhere anywhere tcp dpt:imtc-map to:192.168.0.2:22
DNAT tcp -- anywhere anywhere tcp dpt:b2-runtime to:192.168.0.3:22
DNAT tcp -- anywhere anywhere tcp dpt:b2-license to:192.168.0.4:22
DNAT tcp -- anywhere anywhere tcp dpt:jps to:192.168.0.5:22
DNAT tcp -- anywhere anywhere tcp dpt:hpocbus to:192.168.0.6:22
DNAT tcp -- anywhere anywhere tcp dpt:hpssd to:192.168.0.7:22
DNAT tcp -- anywhere anywhere tcp dpt:hpiod to:192.168.0.8:22
DNAT tcp -- anywhere anywhere tcp dpt:rimf-ps to:192.168.0.9:22
DNAT tcp -- anywhere anywhere tcp dpt:http to:192.168.0.6:80
DNAT tcp -- anywhere anywhere tcp dpt:ica to:192.168.0.6:1494
DNAT tcp -- anywhere anywhere tcp dpt:shell to:192.168.0.2:514
DNAT tcp -- anywhere anywhere tcp dpt:avt-profile-2 to:192.168.0.5:5005
DNAT tcp -- anywhere anywhere tcp dpt:wsm-server to:192.168.0.5:5006
DNAT tcp -- anywhere anywhere tcp dpt:wsm-server-ssl to:192.168.0.5:5007
DNAT tcp -- anywhere anywhere tcp dpt:synapsis-edge to:192.168.0.5:5008
DNAT tcp -- anywhere anywhere tcp dpt:winfs to:192.168.0.5:5009
DNAT tcp -- anywhere anywhere tcp dpt:telelpathstart to:192.168.0.5:5010
DNAT tcp -- anywhere anywhere tcp dpt:50000 to:192.168.0.5:50000
DNAT tcp -- anywhere anywhere tcp dpt:50005 to:192.168.0.5:50005
DNAT tcp -- anywhere anywhere tcp dpt:50009 to:192.168.0.5:50009
DNAT tcp -- anywhere anywhere tcp dpt:50010 to:192.168.0.5:50010
DNAT tcp -- anywhere anywhere tcp dpt:50011 to:192.168.0.5:50011
DNAT tcp -- anywhere anywhere tcp dpt:50012 to:192.168.0.5:50012
DNAT tcp -- anywhere anywhere tcp dpt:50013 to:192.168.0.5:50013
DNAT tcp -- anywhere anywhere tcp dpt:50014 to:192.168.0.5:50014
DNAT tcp -- anywhere anywhere tcp dpt:50184 to:192.168.0.5:50184
DNAT tcp -- anywhere anywhere tcp dpt:50185 to:192.168.0.5:50185
DNAT tcp -- anywhere anywhere tcp dpt:50186 to:192.168.0.5:50186
DNAT tcp -- anywhere anywhere tcp dpt:50187 to:192.168.0.5:50187
DNAT tcp -- anywhere anywhere tcp dpt:50188 to:192.168.0.5:50188
DNAT tcp -- anywhere anywhere tcp dpt:50189 to:192.168.0.5:50189
DNAT tcp -- anywhere anywhere tcp dpt:50000 to:192.168.0.5:50000
DNAT tcp -- anywhere anywhere tcp dpt:50005 to:192.168.0.5:50005
DNAT tcp -- anywhere anywhere tcp dpt:50009 to:192.168.0.5:50009
DNAT tcp -- anywhere anywhere tcp dpts:50010:50014 to:192.168.0.5:50010-50014
DNAT tcp -- anywhere anywhere tcp dpts:50184:50189 to:192.168.0.5:50184-50189
DNAT tcp -- anywhere anywhere tcp dpt:binderysupport to:192.168.0.2:23
DNAT tcp -- anywhere anywhere tcp dpt:proxy-gateway to:192.168.0.3:23
DNAT tcp -- anywhere anywhere tcp dpt:attachmate-uts to:192.168.0.4:23
DNAT tcp -- anywhere anywhere tcp dpt:mt-scaleserver to:192.168.0.5:23
DNAT tcp -- anywhere anywhere tcp dpt:tappi-boxnet to:192.168.0.6:23
DNAT tcp -- anywhere anywhere tcp dpts:checkoutdb:5510 to:192.168.0.5:5505-5510
DNAT tcp -- anywhere anywhere tcp dpt:gotodevice to:192.168.0.17:22
DNAT tcp -- anywhere anywhere tcp dpt:foliocorp to:192.168.0.42:22
DNAT tcp -- anywhere anywhere tcp dpt:magicom to:192.168.0.43:22
DNAT tcp -- anywhere anywhere tcp dpt:nmsserver to:192.168.0.44:22
DNAT tcp -- anywhere anywhere tcp dpt:hao to:192.168.0.45:22
DNAT tcp -- anywhere anywhere tcp dpt:pc-mta-addrmap to:192.168.0.46:22
DNAT tcp -- anywhere anywhere tcp dpt:antidotemgrsvr to:192.168.0.47:22
DNAT tcp -- anywhere anywhere tcp dpt:remote-collab to:192.168.0.50:22
DNAT tcp -- anywhere anywhere tcp dpt:dif-port to:192.168.0.51:22
DNAT tcp -- anywhere anywhere tcp dpt:lnvalarm to:192.168.0.82:22
Using iptables -F PREROUNTING you can delete all rules for chain PREROUNTING.
Using iptables -D PREROUTING 1 you can delete a single first rule from chain PREROUTING. So to delete above two rules you will have to use the same command twice.
Use iptables -t nat -D PREROUTING -p tcp --dport 12348 -j DNAT --to-destination 192.168.0.5:12348 and iptables -t nat -D PREROUTING -p tcp --dport 7778 -j DNAT --to-destination 192.168.0.5:7778 to delete these two specific rules.
Just replacing -I with -D.
I'm struggling to understand why I can't open port 61616 by adding IPTABLES rule. Here is the listing of all rules, obtained via IPTABLES -L command.
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:61616
ACCEPT udp -- anywhere anywhere udp dpt:cslistener
ACCEPT tcp -- anywhere anywhere tcp dpt:cslistener
ACCEPT tcp -- anywhere anywhere tcp dpt:webcache
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:61616
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
As much as I'm ignorant about IPTABLES, what confuses me is that http port is visible from the outside, yet port 61616 still isn't. For me, the rules look the same. Anyways, all help's appreciated.
Best
Maybe you try to open port for host in the network behind the CentOS host (CentOS host is firewall for network)?
If so, you must add rule for chain FORWARD of table filter, and you should
add rule for DNAT to some IP in network x.x.x.x
iptables -A FORWARD -p tcp --dport 61616 -j ACCEPT
iptables -A PREROUTING -t nat -p tcp --dport 61616 -j DNAT --to-destinanion x.x.x.x