{"id":197302,"date":"2013-10-12T23:32:03","date_gmt":"2013-10-12T19:32:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=197302"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=197302","title":{"rendered":"<span class=\"post_title\">\u041a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Firewall \u0434\u043b\u044f VPN-\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441 \u0434\u0432\u0443\u043c\u044f IP<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/e70\/5af\/6e1\/e705af6e17651501e4bcee2e26e5ec27.gif\" alt=\"image\"\/><\/p>\n<p>  \u042f \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0437\u0430\u0432\u0451\u043b \u0441\u0435\u0431\u0435 \u0441\u0435\u0440\u0432\u0435\u0440. \u041d\u0430 \u043d\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0441\u0430\u0439\u0442 \u0441\u0432\u043e\u0435\u0439 \u00ab\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438\u00bb, \u0430 \u043f\u043e\u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u0443 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u043d\u044f\u0442\u044c VPN. \u0414\u043b\u044f \u0435\u0442\u043e\u0433\u043e \u0431\u044b\u043b \u0437\u0430\u043a\u0430\u0437\u0430\u043d \u0432\u0442\u043e\u0440\u043e\u0439 IP. \u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0431\u0443\u0434\u0435\u0442 web, mail, ssh \u0430 \u0441 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0434\u0438\u0442\u044c VPN \u0442\u0440\u0430\u0444\u0438\u043a. \u0417\u0430\u0434\u0443\u043c\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c, \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Shorewall \u0447\u0442\u043e\u0431\u044b VPN \u0442\u0440\u0430\u0444\u0438\u043a \u0448\u0435\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0438 \u043d\u0435 \u043c\u043e\u0433 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0441\u043e\u0441\u0435\u043d\u0434\u0438\u0439 IP.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u0435\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0445\u043e\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u043e\u043a\u0443\u0441 \u043d\u0435 \u043d\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0435\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u0430 \u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 firewall-a \u0434\u043b\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0443 \u043d\u0430\u0441 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0435. \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f firewall-\u043e\u043c \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442 Shorewall. \u041d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0443 shorewall-a \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u043e \u043e\u043d\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u043d\u044b\u043c\u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u043c\u0438 \u043a\u0430\u0440\u0442\u0430\u043c\u0438, \u0438 \u043f\u043e\u0434\u0441\u0435\u0442\u044f\u043c\u0438 \u043b\u0435\u0436\u0430\u0448\u0438\u043c\u0438 \u0437\u0430 \u043d\u0438\u043c\u0438.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 ifconfig. \u0422\u0430\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0434\u0432\u0430 \u043d\u0430\u0448\u0438\u0445 IP-\u0448\u043d\u0438\u043a\u0430, \u00ab1.1.1.1\u00bb \u0438 \u00ab2.2.2.2\u00bb. \u041e\u043d\u0438 \u043e\u0431\u0430 \u0438\u0434\u0443\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0438 \u00ab\u0431\u043b\u0438\u0437\u043d\u0435\u0446\u044b\u00bb, \u0442\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u043d \u0438 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c IP.<\/p>\n<pre><code class=\"bash\"># ifconfig eth0      Link encap:Ethernet  HWaddr \u0445\u0445:\u0445\u0445:\u0445\u0445:\u0445\u0445:\u0445\u0445:\u0445\u0445           inet addr:1.1.1.1  Bcast:1.1.1.255  Mask:255.255.255.0           inet6 addr: fe80::\u0445\u0445\u0445:\u0445\u0445\u0445\u0445:\u0445\u0445\u0445\u0445:\u0445\u0445\u0445\u0445\/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:417428 errors:0 dropped:230 overruns:0 frame:0           TX packets:17595 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           RX bytes:28249193 (28.2 MB)  TX bytes:4653027 (4.6 MB)  eth0:0    Link encap:Ethernet  HWaddr \u0445\u0445:\u0445\u0445:\u0445\u0445:\u0445\u0445:\u0445\u0445:\u0445\u0445           inet addr:2.2.2.2  Bcast:2.2.2.255  Mask:255.255.255.0           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  lo        Link encap:Local Loopback           inet addr:127.0.0.1  Mask:255.0.0.0           inet6 addr: ::1\/128 Scope:Host           UP LOOPBACK RUNNING  MTU:16436  Metric:1           RX packets:507 errors:0 dropped:0 overruns:0 frame:0           TX packets:507 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:0           RX bytes:44121 (44.1 KB)  TX bytes:44121 (44.1 KB) <\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0442\u043e \u0434\u0435\u043b\u043e \u043f\u0440\u0438\u043a\u0440\u043e\u0435\u043c, \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b 1.1.1.1 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u043b \u043d\u0430 web, email, ssh, \u0430 2.2.2.2 \u0441\u043b\u0443\u0448\u0430\u043b vpn. \u0412\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f:<\/p>\n<pre><code class=\"bash\"># cat \/etc\/shorewall\/interfaces #ZONE   INTERFACE       BROADCAST       OPTIONS net4    eth0            detect          tcpflags,logmartians,nosmurfs  # cat \/etc\/shorewall\/zones #ZONE   TYPE            OPTIONS         IN                      OUT fw      firewall net4    ipv4  # cat \/etc\/shorewall\/policy #SOURCE DEST    POLICY          LOG     LIMIT:          CONNLIMIT: $FW     net4    ACCEPT net4    $FW     DROP            info net4    all     DROP            info # The FOLLOWING POLICY MUST BE LAST all     all     REJECT          info  # cat \/etc\/shorewall\/rules #ACTION         SOURCE          DEST            PROTO   DEST    SOURCE SECTION NEW # ------------------------- INTERNET -------------------------------- ACCEPT          net4            $FW:1.1.1.1      tcp     22 ACCEPT          net4            $FW:1.1.1.1      tcp     25 ACCEPT          net4            $FW:1.1.1.1      tcp     80 # ------------------------- VPN ------------------------------------- ACCEPT          net4            $FW:2.2.2.2      udp     1194 <\/code><\/pre>\n<p>  \u0415\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u0441 \u043d\u0430\u0448\u0435\u0433\u043e VPS-a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0430 \u043d\u0430\u0437\u0430\u0434 \u043d\u0435 \u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 rules. \u041f\u043e\u0434 \u0437\u043e\u043d\u043e\u0439 $FW, \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0431\u0430 IP, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e eth0 (\u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0443 2.2.2.2 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0451 \u0438\u043c\u044f eth0:0). \u0414\u043b\u044f \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u043e\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0442\u0438\u043f\u0430: $FW:[ip]. \u0412\u0440\u043e\u0434\u0435 \u0432\u0441\u0451 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u0422\u043e\u0433\u0434\u0430, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c VPN \u0441\u0435\u0440\u0432\u0435\u0440, \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c ifconfig. \u041f\u043e\u043c\u0438\u043c\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0442\u0430\u043c \u0443\u0436\u0435 \u0431\u044b\u043b\u043e, \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 interface tun0:<\/p>\n<pre><code class=\"bash\">tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00           inet addr:10.8.0.1  P-t-P:10.1.0.2  Mask:255.255.255.255           UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1           RX packets:3261 errors:0 dropped:0 overruns:0 frame:0           TX packets:2624 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:100           RX bytes:351155 (351.1 KB)  TX bytes:1043254 (1.0 MB) <\/code><\/pre>\n<p>  \u0437\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 tun0 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u0431\u043b\u0438\u0437\u043d\u0435\u0446\u043e\u043c\u00bb \u0441 eth0, \u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0444\u0435\u0439\u0441. \u0417\u0430 \u0435\u0442\u043e\u0439 \u043f\u043e\u0434\u0441\u0435\u0442\u044c\u044e \u0431\u0443\u0434\u0443\u0442 \u0441\u0438\u0434\u0435\u0442\u044c VPN \u043a\u043b\u0438\u0435\u043d\u0442\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0438\u0447\u0430\u0441. \u041d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u043a\u043e\u043c\u043f\u0435: \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e, \u0441\u043e\u0435\u0434\u0435\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e, \u0438\u0434\u0435\u043c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0438 \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430\u0448\u0435\u043c\u0443 vpn gateway (10.8.0.1) \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0447\u0442\u0443, \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u043d\u0433\u043e\u0432\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u043f\u0438\u043d\u0433\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f (\u0441\u043c. \/etc\/sysctl.conf).<\/p>\n<pre><code class=\"bash\">$telnet 10.8.0.1 25 $sudo tail \/var\/log\/syslog ... Shorewall:INPUT:REJECT:IN=tun0 OUT= MAC= SRC=10.8.0.6 DST=10.8.0.1 ... PROTO=TCP SPT=36879 DPT=25 ... <\/code><\/pre>\n<p>  \u041d\u0430\u0448\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 mail \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u044b\u043b\u0430 \u043e\u0442\u0432\u0435\u0440\u0433\u043d\u0443\u0442\u0430, \u0438\u0437 \u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e, \u043d\u0435 \u044f\u0432\u043b\u044f\u0441\u044c \u00ab\u0431\u043b\u0438\u0437\u043d\u0435\u0446\u043e\u043c\u00bb eth0, tun0 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0441 eth0 (\u0438 eth0:0) \u0438\u0437 \u0437\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<pre><code class=\"bash\">all     all     REJECT          info <\/code><\/pre>\n<p>  \u0432 \u043a\u043e\u043d\u0446\u0435 \/etc\/shorewall\/policy. \u041f\u043e\u043a\u0430 \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0422\u043e\u0433\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c tun0 \u0432 shorewall.<br \/>  \u041d\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f:<\/p>\n<pre><code class=\"bash\"># cat \/etc\/shorewall\/interfaces #ZONE   INTERFACE       BROADCAST       OPTIONS net4    eth0            detect          tcpflags,logmartians,nosmurfs vpn4    tun0            detect          tcpflags,logmartians,nosmurfs              #NEW  # cat \/etc\/shorewall\/zones #ZONE   TYPE            OPTIONS         IN                      OUT fw      firewall net4    ipv4 vpn4    ipv4         #NEW  # cat \/etc\/shorewall\/policy #SOURCE DEST    POLICY          LOG     LIMIT:          CONNLIMIT: $FW     net4    ACCEPT vpn4    $FW     ACCEPT            #NEW vpn4    net4     ACCEPT            #NEW net4    $FW     DROP            info net4    all     DROP            info # The FOLLOWING POLICY MUST BE LAST all     all     REJECT          info  # cat \/etc\/shorewall\/rules #ACTION         SOURCE          DEST            PROTO   DEST    SOURCE SECTION NEW # ------------------------- INTERNET -------------------------------- ACCEPT          net4            $FW:1.1.1.1      tcp     22 ACCEPT          net4            $FW:1.1.1.1      tcp     25 ACCEPT          net4            $FW:1.1.1.1      tcp     80 # ------------------------- VPN ------------------------------------- ACCEPT          net4            $FW:2.2.2.2      udp     1194  # SNAT, for access to internet -- NEW # cat \/etc\/shorewall\/masq #INTERFACE              SOURCE          ADDRESS         PROTO   PORT(S) IPSEC   MARK eth0                   10.8.0.0\/24     2.2.2.2 <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c? \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0437\u043e\u043d\u0443 \u043f\u043e\u0434 \u0438\u043c\u0435\u043d\u0435\u043c vpn4 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 tun0. \u041c\u044b \u0434\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 vpn4 \u043a\u0430\u043a IPv4. \u041c\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b\u0438 \u0442\u0440\u0430\u0444\u0438\u043a\u0443 \u0438\u0437 tun0 \u0434\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e firewall-\u0430, \u0438 \u0434\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 (eth0\/net4). \u041a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u0435\u043b\u044c\u0437\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e firewall-a, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u0441\u0443\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0448\u0435\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443 $fw -&gt; net4. \u041d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0435\u0442\u043e SNAT (source address translation, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 \u0441\u043c\u043e\u0442\u0440\u044f\u0448\u0438\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 2.2.2.2). \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b masq \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u043c \u0442\u0430\u043c \u0437\u0430\u043c\u0435\u043d\u044b \u0432\u0441\u0435\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 10.8.0.\u0445 \u043d\u0430 2.2.2.2 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 eth0 (\u0438 eth0:0).<\/p>\n<p>  \u041f\u0440\u043e\u0431\u0443\u0435\u043c\u2026 \u0412\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442! \u0414\u0430\u0436\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c\u2026 \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0438\u0437 10.8.0.\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 1.1.1.1:1194, \u0447\u0435\u0433\u043e \u043c\u044b \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0445\u043e\u0442\u0438\u043c. \u041c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0447\u0442\u043e\u0431\u044b vpn \u0442\u0440\u0430\u0444\u0438\u043a \u0441\u043f\u0435\u0440\u0432\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u043b \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0430 \u043f\u043e\u0442\u043e\u043c \u0431\u0438\u043b\u0441\u044f \u043d\u0430\u0437\u0430\u0434 \u0447\u0435\u0440\u0435\u0437 firewall. \u0412\u043c\u0435\u0441\u0442\u043e \u0435\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c vpn \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0438\u0434\u043e\u043c \u0441\u0437\u0430\u0434\u0438. \u041f\u043e\u0447\u0435\u043c\u0443? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b\u0438 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430:<\/p>\n<pre><code class=\"bash\"># \/etc\/shorewall\/policy: vpn4    $FW     ACCEPT            #NEW <\/code><\/pre>\n<p>  \u043c\u044b \u043d\u0435 \u0443\u0442\u043e\u0447\u043d\u0438\u043b\u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0438\u043c\u0435\u043d\u043d\u043e IP, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0434 $FW \u0438\u0445 \u0434\u0432\u0430 (1.1.1.1 \u0438 2.2.2.2). \u041d\u0443 \u043b\u0430\u0434\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c. \u0410\u043d-\u043d\u0435\u0442, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0442\u0438\u043f\u0430: $FW:[ip] \u0432 \u0444\u0430\u0439\u043b\u0435 policy \u043d\u0435 \u043f\u0440\u0438\u043d\u0435\u043c\u0430\u0435\u0442\u0441\u044f. \u041d\u0430 \u0435\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u044f \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u0438 \u043f\u043e\u0447\u0442\u0438 \u0431\u0440\u043e\u0441\u0438\u043b \u0437\u0430\u0442\u0435\u044e \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u0430\u043a \u0435\u0441\u0442\u044c. \u0425\u043e\u0442\u044f \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043f\u0443\u0442\u0438 \u0431\u044b\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e. \u0418\u0442\u0430\u043a, \u043e\u0437\u0430\u0440\u0435\u043d\u0438\u0435: \u0432\u0441\u0435 \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 policy \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 rules, \u0430 \u0432 rules \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 IP \u043d\u0430 firewall-e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f:<\/p>\n<pre><code class=\"bash\"># cat \/etc\/shorewall\/interfaces #ZONE   INTERFACE       BROADCAST       OPTIONS net4    eth0            detect          tcpflags,logmartians,nosmurfs vpn4    tun0            detect          tcpflags,logmartians,nosmurfs  # cat \/etc\/shorewall\/zones #ZONE   TYPE            OPTIONS         IN                      OUT fw      firewall net4    ipv4 vpn4    ipv4  # cat \/etc\/shorewall\/policy #SOURCE DEST    POLICY          LOG     LIMIT:          CONNLIMIT: $FW     net4    ACCEPT #vpn4    $FW     ACCEPT            #NEW #vpn4    net4     ACCEPT            #NEW net4    $FW     DROP            info net4    all     DROP            info # The FOLLOWING POLICY MUST BE LAST all     all     REJECT          info  # cat \/etc\/shorewall\/rules #ACTION         SOURCE          DEST            PROTO   DEST    SOURCE SECTION NEW # ------------------------- INTERNET -------------------------------- ACCEPT          net4            $FW:1.1.1.1      tcp     22 ACCEPT          net4            $FW:1.1.1.1      tcp     25 ACCEPT          net4            $FW:1.1.1.1      tcp     80 # ------------------------- VPN ------------------------------------- ACCEPT          net4            $FW:2.2.2.2      udp     1194 # ------------------------- NEW ------------------------------------- ACCEPT          vpn4            net4 ACCEPT          vpn4            $FW:1.1.1.1      tcp     22 ACCEPT          vpn4            $FW:1.1.1.1      tcp     25 ACCEPT          vpn4            $FW:1.1.1.1      tcp     80  # cat \/etc\/shorewall\/masq #INTERFACE              SOURCE          ADDRESS         PROTO   PORT(S) IPSEC   MARK eth0                   10.8.0.0\/24     2.2.2.2 <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438: \u0443\u0431\u0440\u0430\u043b\u0438 \u0441\u0442\u0430\u0440\u044b\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438\u0437 policy, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 rules. \u041c\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0432\u0435\u0441\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u0438\u0437 vpn \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0438 \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 1.1.1.1. \u0410 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0437\u0430\u0445\u043e\u0434\u044b \u043d\u0430 1.1.1.1 \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f? \u041d\u0435\u0442, \u043a\u0430\u043a \u0431\u044b \u043d\u0430\u043c \u043d\u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0434\u0442\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043f\u043e\u0435\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435\u0435 \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c, \u0435\u0442\u043e \u043f\u0440\u043e\u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0434\u043b\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 vpn -&gt; 1.1.1.1. \u0410 \u043a\u0430\u043a \u0436\u0435 \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0430 2.2.2.2? \u0415\u0442\u043e\u0442 \u0442\u0440\u0430\u0444\u0438\u043a \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0432\u0435\u043d\u043d\u043e \u0438 \u0435\u0441\u0442\u044c vpn \u0442\u0440\u0430\u0444\u0438\u043a, \u0438 \u043e\u043d \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0437\u043d\u0443\u0442\u0440\u0438 (\u0435\u0442\u043e \u043e\u0431\u0441\u0435\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f route-\u043e\u043c \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435). \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u043a\u043b\u0438\u0435\u043d\u0442 vpn-a \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0435\u0442 \u0442\u0440\u0430\u0444\u0438\u043a \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e 10.8.0.1(vpn4) -&gt; 2.2.2.2($fw:2.2.2.2).<\/p>\n<p>  \u041d\u0443 \u0432\u043e\u0442 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0438 \u0432\u0441\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0431\u0440\u0430\u0443\u0437\u0438\u0442\u044c \u0441 \u00ab\u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e\u00bb VPN-a \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f IP-\u0448\u043d\u0438\u043a\u0430 \u0432\u0435\u0434\u0443\u0448\u0435\u0433\u043e \u043d\u0430 \u00ab\u043a\u043e\u043c\u043f\u0430\u043d\u0435\u0439\u0441\u043a\u0438\u0439\u00bb \u0441\u0430\u0439\u0442, \u0438 \u043d\u0435 \u0431\u043e\u044f\u0442\u0441\u044f \u0437\u0430 \u043e\u0431\u0445\u043e\u0434 firewall-a \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 vpn \u044e\u0437\u0435\u0440\u0430\u043c\u0438. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/197302\/\"> http:\/\/habrahabr.ru\/post\/197302\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/e70\/5af\/6e1\/e705af6e17651501e4bcee2e26e5ec27.gif\" alt=\"image\"\/><\/p>\n<p>  \u042f \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0437\u0430\u0432\u0451\u043b \u0441\u0435\u0431\u0435 \u0441\u0435\u0440\u0432\u0435\u0440. \u041d\u0430 \u043d\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0441\u0430\u0439\u0442 \u0441\u0432\u043e\u0435\u0439 \u00ab\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438\u00bb, \u0430 \u043f\u043e\u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u0443 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u043d\u044f\u0442\u044c VPN. \u0414\u043b\u044f \u0435\u0442\u043e\u0433\u043e \u0431\u044b\u043b \u0437\u0430\u043a\u0430\u0437\u0430\u043d \u0432\u0442\u043e\u0440\u043e\u0439 IP. \u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0431\u0443\u0434\u0435\u0442 web, mail, ssh \u0430 \u0441 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0434\u0438\u0442\u044c VPN \u0442\u0440\u0430\u0444\u0438\u043a. \u0417\u0430\u0434\u0443\u043c\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c, \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c Shorewall \u0447\u0442\u043e\u0431\u044b VPN \u0442\u0440\u0430\u0444\u0438\u043a \u0448\u0435\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u0438 \u043d\u0435 \u043c\u043e\u0433 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0441\u043e\u0441\u0435\u043d\u0434\u0438\u0439 IP.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-197302","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=197302"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/197302\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=197302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=197302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=197302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}