Firewalld 규칙은 두 사용자 그룹을 OpenVPN의 다른 애플리케이션으로 라우팅합니다.

Firewalld 규칙은 두 사용자 그룹을 OpenVPN의 다른 애플리케이션으로 라우팅합니다.

CentOS 7직원과 관리자에게 https 액세스를 허용하는 동시에 관리자가 아닌 모든 사람에 대한 SSH 액세스를 차단하도록 원격 서버에서 OpenVPN을 성공적으로 구성했습니다 . 이것은 appONE이 입력된 직원에게 제공되는 경우 잘 작동합니다 https: / 10.8.0.1. suppliers하지만 VPN에 로그인하고 입력할 때 세 번째 그룹이 https 액세스를 다른 애플리케이션(appTWO라고 함)으로 라우팅할 수 있도록 방화벽에 어떤 규칙을 추가해야 합니까 https: / 10.8.0.1?

@garethTheRed의 제안에 따르면, 포트 80에서 appONE을 실행하고 포트 81에서 appTWO를 실행하는 것이 답이라고 생각합니다. 이를 위해서는 공급업체 IP 범위를 포트 81로 라우팅하는 동시에 직원 IP 범위를 포트 80으로 지정하는 방화벽 규칙만 필요합니다. 그러나 이를 달성하려면 방화벽 규칙을 어떻게 정의해야 합니까?

지금까지 내가 한 일은 다음과 같습니다.

필요한 사용자 범주, IP 범위 및 서비스를 다음과 같이 요약했습니다.

Class            Virtual IP range       Allowed Services  
employees        10.8.0.0/24            https (but only appONE)
administrator    10.8.1.0/24            ssh, https  
suppliers        10.8.2.0/24            https (but only appTWO)

다음으로 다음을 추가했습니다 /etc/openvpn/server.conf.

define the Employee IP address pool:
server 10.8.0.0 255.255.255.0

Add a route for the System Administrator IP range:
route 10.8.1.0 255.255.255.0

Add a route for the Supplier IP range:
route 10.8.2.0 255.255.255.0

Specify client configuration directory to assign a fixed IP forAdministrator:
client-config-dir ccd

/etc/openvpn/ccd/suppliers그런 다음 다음 단계에 따라 새 프로필을 만들었습니다.

nano suppliers
type the following into /etc/openvpn/ccd/suppliers:
ifconfig-push 10.8.2.1 10.8.2.2

OpenVPN 구성이 처음에 생성되었다는 점을 고려하면이 튜토리얼의 지침을 사용하세요/etc/openvpn/easy-rsasource ./vars, 다음으로 을 입력 한 후 를 입력 하여 인증서를 생성했습니다 ./build-key suppliers. (이것은 참조 튜토리얼의 두 명령입니다.) 결과를 클라이언트 시스템에 복사 suppliers.crt하고 suppliers.key다음 suppliers.ovpn파일을 생성했습니다.

client
dev tun
proto udp
remote my.SERVER.ip.addr 1194
resolv-retry infinite
nobind
persist-key
persist-tun
verb 3
ca /path/to/ca.crt
cert /path/to/suppliers.crt
key /path/to/suppliers.key

그런 다음 클라이언트 시스템의 터미널에 다음을 입력하여 클라이언트에서 VPN에 로그인을 시도했습니다 openvpn --config /path/to/suppliers.ovpn. 터미널에 인쇄된 마지막 두 줄은 다음과 같으므로 터미널의 결과는 VPN 연결이 설정된 것으로 나타납니다.

Tue Mar 10 15:39:50 2015 /usr/sbin/ip route add 10.8.0.1/32 via 10.8.2.2
Tue Mar 10 15:39:50 2015 Initialization Sequence Completed

올바른 IP에 성공적으로 연결된 것 같지만 10.8.2.2아직 연결되지 않았습니다.시도했을 때 응답을 받지 못했습니다 https : / 10.8.0.1.

OpenVPN이 작동하는지 확인하기 위해 클라이언트에 다음을 입력했고 예상대로 서버에 성공적으로 연결할 openvpn --config /path/to/administrators.ovpn수 있었습니다 .httpsssh

서버에 입력하면 firewall-cmd --list-all-zones결과의 활성 영역은 다음과 같습니다.

internal (active)
  interfaces: tun0
  sources: 
  services: dhcpv6-client https ipp-client mdns samba-client ssh
  ports: 
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 
rule family="ipv4" source NOT address="10.8.1.1" service name="ssh" reject

public (default, active)
  interfaces: enp3s0
  sources: 
  services: dhcpv6-client openvpn
  ports: 
  masquerade: yes
  forward-ports: 
  icmp-blocks: 
  rich rules: 

그렇다면 공급업체 계정은 왜 https가 될 수 없나요? 공급업체 https 요청이 하나의 포트 abc로 라우팅되고 직원 및 관리자 https 요청이 다른 포트 xyz로 라우팅되도록 방화벽 규칙을 정의하려면 어떻게 해야 합니까?


편집하다


@garethTheRed의 제안에 따라 ip routeCLIENT에 입력하고 다음과 같은 결과를 얻었습니다.

default via 10.0.0.1 dev wlp1s0  proto static  metric 1024 
10.0.0.0/24 dev wlp1s0  proto kernel  scope link  src 10.0.0.2 
10.8.0.1 via 10.8.2.2 dev tun0 
10.8.2.2 dev tun0  proto kernel  scope link  src 10.8.2.1   

서버에 결과를 입력하세요 ip route.

default via my.server.ip.1 dev enp3s0  proto static  metric 1024 
10.8.0.0/24 via 10.8.0.2 dev tun0 
10.8.0.2 dev tun0  proto kernel  scope link  src 10.8.0.1 
10.8.1.0/24 via 10.8.0.2 dev tun0 
my.server.ip.0/24 dev enp3s0  proto kernel  scope link  src my.server.ip.addr 

my.server.ip. my.server.ip.addr​전체 4블록 서버 IP 주소는 으로 표시됩니다 my.server.ip.addr. 대조적으로, 처음 3개의 블록만 으로 표시됩니다 my.server.ip.

내용은 nano /etc/openvpn/ccd/administrators단 한줄 입니다 ifconfig-push 10.8.1.1 10.8.1.2.

위에 표시된 두 개의 ccd 파일은 /etc/openvpn/ccd/administratorsccd 및 ccd 뿐입니다./etc/openvpn/ccd/suppliers


편집 #2


@garethTheRed의 지침을 따른 후 직원 IP 주소 범위는 을 입력하여 appONE에 로그인할 수 있지만 https : / 10.8.0.1관리자는 더 이상 https 액세스 권한이 없고 공급업체도 더 이상 https 액세스 권한이 없습니다. 공급자로 연결할 때 https : / 10.8.0.1:444및 를 입력하면 내 https 요청이 거부됩니다 https : / 10.8.0.1.

참고: 이 문제를 진단하기 위해 주제에서 벗어난 것처럼 보이는 것을 시도해야 했습니다. 필요한 경우 이 EDIT#2의 내용을 별도의 질문으로 게시하고 싶지만 지금은 방화벽 설정이 여전히 문제일 수 있으므로 여기에 두겠습니다. 이러한 다른 주제가 문제의 원인이라는 증거는 없습니다. 나는 단지 실사에 그들을 포함시킵니다.

공급자의 https 액세스가 부족한 것은 httpd 역방향 프록시 뒤에 있는 tomcat이 제공하는 애플리케이션 때문일 수 있다고 추측합니다. 그래서 다른 게시물의 지침에 따라 tomcat이 포트 8081을 통해 appTWO를 제공하고 포트 8080을 통해 appONE을 계속 제공하도록 했습니다. Tomcat이 두 애플리케이션을 모두 올바르게 제공하고 있는지 확인하기 위해 Firewalld의 공개 영역에서 포트 8080 및 8081을 열었습니다.

그런 다음 httpd와 tomcat을 연결하는 역방향 프록시의 코드를 확인했습니다.

역방향 프록시는 /etc/httpd/conf.d/mydomain.com.conf다음 내용을 포함하는 다음 파일에 의해 httpd에 정의됩니다.

<VirtualHost *:443>
  ServerName www.mydomain.com
  ServerAlias mydomain.com
  ErrorLog /path/to/mydomain_com_error.log
  CustomLog /path/to/mydomain_com_requests.log combined
  SSLEngine on
  SSLProxyEngine on
  SSLCertificateFile /path/to/localhost.crt
  SSLCertificateKeyFile /path/to/localhost.key
  ProxyPass / ajp://my.server.ip.addr:8009/
  ProxyPassReverse / ajp://my.server.ip.addr:8009/
</VirtualHost>

mydomain.com은 컴퓨터의 호스트 이름이지만 https 및 http가 공개 영역에서 닫혀 있기 때문에 인터넷에서 mydomain.com에 도달하는 트래픽이 없습니다. OpenVPN 사용자만 웹 애플리케이션에 액세스할 수 있으며 내부 영역에서만 가능합니다.

Tomcat의 server.xml은 역방향 프록시를 정의합니다 <Connector port="8090" protocol="AJP/1.3" redirectPort="8443" />.

/etc/httpd/conf.d/mydomain.com.conf포트 444에서 appTWO에 대한 별도의 역방향 프록시를 실험하기 위해 위의 코드 섹션 뒤에 다음을 추가했습니다.

#I added this entire following section as a test for this question
<VirtualHost *:444>
  ServerName www.mydomain.com
  ServerAlias mydomain.com
  ErrorLog /path/to/mydomain_com_error.log
  CustomLog /path/to/mydomain_com_requests.log combined
  SSLEngine on
  SSLProxyEngine on
  SSLCertificateFile /path/to/localhost.crt
  SSLCertificateKeyFile /path/to/localhost.key
  ProxyPass / ajp://my.server.ip.addr:8009/
  ProxyPassReverse / ajp://my.server.ip.addr:8009/
</VirtualHost>

이것이 server.xml의 두 서비스 모두에 정의되어 있는지 확인했지만 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />OpenVPN에 공급자로 로그인할 때 여전히 https를 사용할 수 없습니다.

그런 다음 server.xml에서 포트 8010을 시도했지만 /etc/httpd/conf.d/mydomain.com.conf여전히 공급자로서 https 액세스를 얻을 수 없습니다.

마침내 나는 시도했다.

[root@mydomain ]# telnet localhost 8010
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
[root@mydomain ]# telnet localhost 8009
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

포트 8010이 역방향 프록시에 대해 열려 있지 않아서 공급자가 appTWO에 액세스하지 못하는 것이 문제인지 궁금합니다.

그러나 httpd.conf에서 다음 항목의 주석 처리를 제거하고 https : / 10.8.0.1:444다시 시도했지만 여전히 거부되어 방화벽에 문제가 있는 것인지 궁금합니다.

<Directory "/var/www">
  AllowOverride None
  # Allow open access:
  Require all granted
</Directory>

참고: httpd.service를 다시 시작하지 않았습니다.

최소한 공급업체가 https를 통해 정적 HTML을 제공하도록 할 수 있다면 방화벽 문제는 해결된 것으로 간주할 수 있으며 필요한 경우 역방향 프록시 문제를 별도로 게시할 수 있습니다.


편집 #3


@garethTheRed의 편집에 따라 내부 영역에서 및 를 제거했습니다 https. 내부 영역에 대한 풍부한 규칙 https-app2도 제거했습니다 . reject새로운 강화 규칙을 추가했지만 accept관리자에게 https및 을(를) 볼 수 있는 권한을 부여했습니다 https-app2. 이것을 입력하면 결과는 다음과 같습니다 firewall-cmd --list-all --zone=internal.

internal (active)
  interfaces: tun0
  sources: 
  services: dhcpv6-client ipp-client mdns samba-client ssh
  ports: 
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 
    rule family="ipv4" source address="10.8.1.0" service name="https" accept
    rule family="ipv4" source address="10.8.1.0" service name="https-app2" accept
    rule family="ipv4" source address="10.8.2.0" service name="https-app2" accept
    rule family="ipv4" source NOT address="10.8.1.1" service name="ssh" reject
    rule family="ipv4" source address="10.8.0.0" service name="https" accept

<VirtualHost *:444>그 부분 도 /etc/httpd/conf.d/mydomain.com.conf사진처럼 유지했어요편집 #2이상. 그러나 아래에 설명된 테스트를 수행하기 전에 해당 정보를 입력했습니다 systemctl stop httpd.service.systemctl start https.service

하지만 이제 어떤 계정에서도 https 또는 https-app2로 로그인할 수 없습니다.

예를 들어 를 입력하면 openvpn --config /path/to/employees.ovpn터미널이 다음과 같이 응답합니다.

Thu Mar 12 09:46:22 2015 /usr/sbin/ip route add 10.8.0.1/32 via 10.8.0.9
Thu Mar 12 09:46:22 2015 Initialization Sequence Completed

로그인한 것 같지만 https : / 10.8.0.1둘 다 https : / 10.8.0.1:444Firefox에서 "연결할 수 없음" 오류가 발생합니다.

마찬가지로 입력 openvpn --config /path/to/suppliers.ovpn결과는 다음과 같습니다.

Thu Mar 12 09:45:19 2015 /usr/sbin/ip route add 10.8.0.1/32 via 10.8.2.2
Thu Mar 12 09:45:19 2015 Initialization Sequence Completed

그러나 https : / 10.8.0.1계속해서 https : / 10.8.0.1:444Firefox에서 "연결할 수 없습니다" 오류가 발생했습니다.

또한 입력 openvpn --config /etc/openvpn/administrators.ovpn결과는 다음과 같습니다.

Thu Mar 12 09:15:36 2015 /usr/sbin/ip route add 10.8.0.1/32 via 10.8.1.2
Thu Mar 12 09:15:36 2015 Initialization Sequence Completed

하지만 https : / 10.8.0.1이후에도 https : / 10.8.0.1:444Firefox에 "연결할 수 없음" 오류가 발생합니다.

OpenVPN에 관리자로 연결할 때 가능하므로 손상되었습니다. ssh [email protected]httpshttps-app2

답변1

기본 https포트(443)에서 app1을 실행하고 다른 포트(444)에서 app2를 실행합니다. SNPP를 사용하지 않는 한, 이 경우 다른 무료 포트를 선택해야 합니다.

https.xml에 있는 파일을 /usr/lib/firewalld/services에 복제 /etc/firewalld/services하고 이름을 로 바꿉니다(예: ) https-app2.xml.

이 새 파일을 편집하고 포트를 444.

https(및 https-app2)이 제거되었는지 확인하십시오 internal zone.

달리기:

firewall-cmd --zone=internal --add-rich-rule='rule family="ipv4" source address="10.8.0.0/24" service name="https" accept'
firewall-cmd --zone=internal --add-rich-rule='rule family="ipv4" source address="10.8.0.0/24" service name="https-app2" accept'
firewall-cmd --zone=internal --add-rich-rule='rule family="ipv4" source address="10.8.1.0/24" service name="https" accept'
firewall-cmd --zone=internal --add-rich-rule='rule family="ipv4" source address="10.8.2.0/24" service name="https-app2" accept'

이는 영구적이지 않으므로 작동하는 경우 다시 실행하고 --permanent연결해야 합니다.

관련 정보