---
title: "iptables场景一（中）"
author: "cakin24"
date: "2017-10-06T06:46:08Z"
tags: []
categories: ["操作系统"]
slug: "iptables"
draft: false
lastmod: "2017-10-06T06:53:00Z"
id: 2395388
url: "https://cakin24.iteye.com/blog/2395388"
---

一 解决本机无法访问本机

1、问题现象

\[root@localhost ~]# telnet 127.0.0.1 22

Trying 127.0.0.1...

无响应

2、解决方法

\[root@localhost ~]# iptables -I INPUT -i lo -j ACCEPT

\[root@localhost ~]# telnet 127.0.0.1 22

Trying 127.0.0.1...

Connected to 127.0.0.1.

Escape character is '^]'.

SSH-2.0-OpenSSH\_6.6.1

 

二 解决本机无法访问其他主机

1、问题现象

\[root@localhost ~]# curl [http://www.imooc.com](http://www.imooc.com)

无响应

 

2、解决方法

\[root@localhost ~]# iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

\[root@localhost ~]# curl -I http://www.imooc.com

HTTP/1.1 200 OK

Server: nginx

Date: Sat, 19 Aug 2017 01:11:30 GMT

Content-Type: text/html; charset=utf-8

Connection: keep-alive

Vary: Accept-Encoding

Vary: Accept-Encoding

Set-Cookie: PHPSESSID=kri810qlngk8a1sn261mrmun12; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

 

Set-Cookie: imooc\_uuid=1481b96a-a1dc-4337-bdde-57c2e74c8b40; expires=Sun, 19-Aug-2018 01:11:29 GMT; path=/; domain=.imooc.com