Я хочу разрешить трафик только для httpd(nginx), порта 2710 и ssh.
Я попробовал следующее, но это не сработало и, по-видимому, весь httpd, трафик был заблокирован, и я не мог получить доступ к ssh. Там не было никакой ошибки.
# Generated by iptables-save v1.4.7 on Sun Dec 29 01:18:59 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1670:508953]
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2710 -j ACCEPT
-A INPUT -j DROP
COMMIT
# Completed on Sun Dec 29 01:18:59 2013
iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:22
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:webcache
ACCEPT tcp -- anywhere anywhere tcp dpt:sso-service
DROP all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain ISPMGR (0 references)
target prot opt source destination
iptables -xnvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
52 3808 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
1876 260008 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
737 44220 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
1495 181034 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:2710
1439 91560 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 4859 packets, 330086 bytes)
pkts bytes target prot opt in out source destination
маршрут -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
x.x.x.x 0.0.0.0 255.255.255.0 U 0 0 0 eth0
x.x.x.x 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
0.0.0.0 x.x.x.x 0.0.0.0 UG 0 0 0 eth0
nmap -p 80 xxxx
Starting Nmap 5.51 ( http://nmap.org ) at 2013-12-29 02:14 EET
Nmap scan report for myhost.com (x.x.x.x)
Host is up (0.000038s latency).
PORT STATE SERVICE
80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
tcpdump -i eth0
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
^C
1 packets captured
3165 packets received by filter
3134 packets dropped by kernel