自己写了一个服务(
10.20.30.10:9000),另一台机器访问的时候访问不到。
2. sudo service iptables stop
curl :
(7) couldn't connect to host
wget:
Connecting to 10.20.30.10:9000... failed: No route to host.
python:
IOError: [Errno socket error] [Errno 113] No route to host
------------
经了解,是centos 防火墙的原因。解决方法:
sudo vi /etc/sysconfig/iptables
加上一句:
-A INPUT -p tcp -m tcp --dport 9000 -j ACCEPT 或者
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9000 -j ACCEPT
保存退出后,
sudo service iptables restart
1. sudo service iptables start
3. sudo service iptables restart
[zhangzhipeng@localhost test]$ sudo service iptables restart
iptables: Setting chains to policy ACCEPT: filter
[
OK
]
iptables: Flushing firewall rules:
[
OK
]
iptables: Unloading modules:
[
OK
]
iptables: Applying firewall rules:
[
OK
]
4. sudo service iptables status
[zhangzhipeng@localhost test]$ sudo service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num
target
prot opt source
destination
1
ACCEPT
tcp
--
0.0.0.0/0
0.0.0.0/0
tcp dpt:9000
2
ACCEPT
all
--
0.0.0.0/0
0.0.0.0/0
state RELATED,ESTABLISHED
3
ACCEPT
icmp --
0.0.0.0/0
0.0.0.0/0
4
ACCEPT
all
--
0.0.0.0/0
0.0.0.0/0
5
ACCEPT
tcp
--
0.0.0.0/0
0.0.0.0/0
state NEW tcp dpt:22
6
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