IP에서 포트 열기

IP에서 포트 열기

나는 이것을 찾기 위해 하루 종일 보냈지 만 운이 좋지 않았습니다.

따라서 이 IP 범위가 있고 해당 IP에서 포트를 열고 xxx.xxx.xxx.xxx/27싶지만 다른 모든 포트에서는 포트를 닫은 다음 IP에서 포트를 열고 // 마지막으로 포트에서 포트를 엽니다.22xxx.xxx.xxx.6622804434567xxx.xxx.xxx.9025565xxx.xxx.xxx.(70|80)

지금까지 시도한 내용은 다음과 같습니다.

# Generated by iptables-save v1.4.7 on Mon Sep 14 07:23:06 2015
*filter
:INPUT ACCEPT [4:240]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [31:3004]
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT 

# Allow HTTP/HTTPS connections from anywhere (normal ports for websites and SSL)
-A INPUT -s xxx.xxx.xxx.90 -p tcp --dport 80 -j ACCEPT
-A OUTPUT -d xxx.xxx.xxx.90 -p tcp --dport 80 -j ACCEPT
-A INPUT -s xxx.xxx.xxx.90 -p tcp --dport 443 -j ACCEPT
-A OUTPUT -d xxx.xxx.xxx.90 -p tcp --dport 443 -j ACCEPT

# Lets allow some TS3 server ports, they'll be running on xxx.xxx.xxx.89
-A INPUT -p tcp --dport 10011 -j ACCEPT
-A OUTPUT -p tcp --dport 10011 -j ACCEPT
-A INPUT -p tcp --dport 30033 -j ACCEPT 
-A OUTPUT -p tcp --dport 30033 -j ACCEPT 
-A INPUT -p udp --dport 9987 -j ACCEPT 
-A OUTPUT -p udp --dport 9987 -j ACCEPT 

# Lets allow NodeBB to use this machine..
# Well run it on 45.35.58.66 as no one **should** be finding out this IP.
-A INPUT -s xxx.xxx.xxx.66 -p tcp --dport 4567 -j ACCEPT 
-A OUTPUT -d xxx.xxx.xxx.66 -p tcp --dport 4567 -j ACCEPT 

# We're going to block icmp on all other IPs, but all it on our main IP.
-A INPUT -s 45.35.58.66 -p icmp -j ACCEPT 
-A INPUT -p icmp -j REJECT 

# Drop all other inbound - default deny unless explicitly allowed policy
-A INPUT -j DROP
-A FORWARD -j DROP

COMMIT

모든 도움에 감사드립니다.

답변1

iptables

iptables다음 구문을 사용할 수 있습니다

iptables -A INPUT -s [source IP] -p [protocol] --dport [destination port] -j [ACTION]

당신은해야합니다수용하다특정 IP로부터의 연결줄이다모든 트래픽에 적용됩니다.

예를 들어

$ sudo iptables -A INPUT -s XXX.XXXX.XXX.66 -p tcp --dport 22 -j ACCEPT
$ sudo iptables -A INPUT -p tcp --dport 22 -j DROP

익숙해지려면 iptables다음을 확인해 보세요.여기

관련 정보