ãããã®èšäºã§ã¯ãè€æ°ã®äŒç€Ÿã®ãªãã£ã¹ã«æ¥ç¶ãããããã¯ãŒã¯ãžã®å¶éãããã¢ã¯ã»ã¹ããã©ãã£ãã¯ã®åªå é äœä»ãïŒQoSïŒãããã³2ã€ã®ãããã€ããŒéã®ãã£ãã«äºçŽã«ããåçŽãªè² è·åæ£ãå¯èœã«ããLinuxã§ã®ã€ã³ã¿ãŒãããã²ãŒããŠã§ã€ã®æ§ç¯ãæ€èšããŸãã
ç¹ã«ãã®éšåã§ã¯ïŒ
- Shorewallã®ãã詳现ãªã»ããã¢ãã
- æããŠç解ã§ããªãQoS
- è² è·åæ£ãšåé·æ§
ãããŠã åã®éšåã§æ€èšããŸããïŒ
- æãã·ã³ãã«ãªShorewallã»ããã¢ãã
- éåžžã«è€éãªdnsmasqã»ããã¢ãã
- ããã»ã©è€éã§ã¯ãªãOpenVPNã»ããã¢ãã
- ãããŠãå€ãã®ç¶ç¶çãªç®¡çè ã«ãšã£ãŠãéå®åã®åçã«ãŒãã£ã³ã°ãäŸãã°OSPF
第äžéšã§ã¯ ïŒ
- Shorewallã§ã®QoS
- Shorewallã®ãã詳现ãªã»ããã¢ãã
- ãããã³ã«ã«åŸã£ãŠãã£ãã«ãä»ããŠãã©ãã£ãã¯ãæ¡æ£ãã
- æŸèæãããããªãã§ãã©ãã«ã
4çªç®ã®éšåã§ã¯ ïŒ
- èªåã€ãã³ã
- ãã¯ã
以äžã«èª¬æãããã¹ãŠã¯CentOS 7.1ã«åœãŠã¯ãŸããŸãïŒäžèšã§ã¯ã6çªç®ã®ã·ãªãŒãºãé©ããŠããŸããããã€ããŒãªæ©èœããããŸãïŒ
é«åºŠãªã·ã§ã¢ãŠã©ãŒã«ã®ã»ããã¢ãã
ååãããªãã ãŸãããããåå§çãªåäœã¢ãŒããèšå®ãããšããä»åºŠã¯å°ãå¥å šãªãã©ãã€ã¢ããªã³ã«ããŸãã
ããã¯é£ãããããŸããããã¡ã€ã«ã«å€æŽãå ããŸãããã
æ¿ç
# # Shorewall -- /etc/shorewall/policy # # For information about entries in this file, type "man shorewall-policy" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-policy.html # ############################################################################### #SOURCE DEST POLICY LOG LIMIT: CONNLIMIT: # LEVEL BURST MASK $FW all REJECT grn all REJECT tun all REJECT red all DROP
æ°ããæ§æã¯ããç°¡åã«ãªããŸããããã«ãŒã«ãã¡ã€ã«ã¯æ©æã«åã¶ããã«ãªããå€§å¹ ã«æ¡åŒµãããŸãã
/ etc / shorewall /ã«ãŒã«
# # Shorewall -- /etc/shorewall/rules # # For information on the settings in this file, type "man shorewall-rules" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-rules.html # ###################################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER # PORT(S) PORT(S) DEST LIMIT GROUP ?SECTION ALL ?SECTION ESTABLISHED ?SECTION RELATED ?SECTION INVALID ?SECTION UNTRACKED ?SECTION NEW INCLUDE rules.fw INCLUDE rules.grn INCLUDE rules.red INCLUDE rules.red-dnat INCLUDE rules.tun
ãããŠãINCLUDEãã£ã¬ã¯ãã£ãã䜿çšããŠãã«ãŒã«ãè€æ°ã®ãã¡ã€ã«ã«åæ£ããŸãã
rules.fw
# # Shorewall -- /etc/shorewall/rules.fw # # For information on the settings in this file, type "man shorewall-rules" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-rules.html # ###################################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER # PORT(S) PORT(S) DEST LIMIT GROUP DNS(ACCEPT) $FW red Web(ACCEPT) $FW red FTP(ACCEPT) $FW red OpenVPN(ACCEPT) $FW red Ping(ACCEPT) $FW all OSPF(ACCEPT) $FW tun SSH(ACCEPT) $FW all
rules.grn
# # Shorewall -- /etc/shorewall/rules.grn # # For information on the settings in this file, type "man shorewall-rules" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-rules.html # ###################################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER # PORT(S) PORT(S) DEST LIMIT GROUP DNS(ACCEPT) grn $FW Web(ACCEPT) grn red FTP(ACCEPT) grn red Ping(ACCEPT) grn all SSH(ACCEPT) grn all - - - - s:3/min #, , SIP ( ) ACCEPT grn red udp 5060 - - - - - - - - sip
rules.red
# # Shorewall -- /etc/shorewall/rules.red # # For information on the settings in this file, type "man shorewall-rules" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-rules.html # ###################################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER # PORT(S) PORT(S) DEST LIMIT GROUP OpenVPN(ACCEPT) red $FW SSH(ACCEPT) red $FW - - - - s:3/min SIP(ACCEPT) red grn
rules.tun
# # Shorewall -- /etc/shorewall/rules.tun # # For information on the settings in this file, type "man shorewall-rules" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-rules.html # ###################################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER # PORT(S) PORT(S) DEST LIMIT GROUP Ping(ACCEPT) tun $FW OSPF(ACCEPT) tun $FW SSH(ACCEPT) tun $FW - - - - s:3/min SSH(ACCEPT) tun grn - - - - s:3/min
ããã§ããã¹ãŠã®ãã©ãã£ãã¯ãå¶åŸ¡ãããå¿ èŠãªãããã³ã«ã®ã¿ãèš±å¯ãããŸãã SSHã®ã«ãŒã«ã«æ³šæããŠãã ãããåIPãœãŒã¹ããã®æ¥ç¶é »åºŠã1åããã3åã«å¶éããŠããŸãã ãã ããsïŒãŸãã¯dïŒããŒã誀ã£ãŠæå®ãããšããã®ãã©ã¡ãŒã¿ãŒã«éåžžã«æ³šæããå¿ èŠããããŸãããµãŒãã¹ãDDoSæ»æã®åœ±é¿ãåããããããããšãã§ããŸãã ãŸããWebãã©ãã£ãã¯ïŒããã³å®éã®ãã©ãã£ãã¯ïŒã®å Žåãå€ãã®æœåšçãªã¯ã©ã€ã¢ã³ããNATã®èåŸã«åº§ã£ãŠãæ¥ç¶ã®ãœãŒã¹ã§ãã1ã€ã®IPãããªãã®æ°ã®æ¥ç¶ãçæã§ããããšã«çæããå¿ èŠããããŸãã
SIPããã³FTPãããã³ã«ã§ã®ç®¡çæ¹æ³ã«æ³šæããŠãã ããã ã¡ããã©ããããç»é²ããShorewallã¯ãã¯ãã䜿çšããŠãnf_nat_ *ããã³nf_conntrack_ *ã¢ãžã¥ãŒã«ãæäœãããã¹ãŠã®è€éããé ããŸããïŒå¯Ÿå¿ããã¢ãžã¥ãŒã«ãªãã§ãã³ãã³ãæ¥ç¶ã¯å¥ãšããŠïŒãŸãã¯RPCãªã©ã®ãã¹ãŠã®ããŒããåçã«ïŒãæªç¥ã®ããŒãã®ã»ã«ã³ããªãiptablesã®ãããªShorewallã¯ããããã®æ¥ç¶ã®ããã«ããŒããåçã«éãããšãã§ããŸããïŒã SIPã®äŸã§ã¯ã䜿çšãããããã³ã«ãããŒãããã«ããŒãæå®ããŠãã»ãŒæåã®æ§æã䜿çšããŸããã
ãã«ããŒã䜿çšãããšãShorewallã¯ãããã³ã«ãæ€åºããããšããã«ïŒãããç¡å¹ã«ãªã£ãŠããªãå ŽåïŒããŸãã¯ãã«ããŒã«ã©ã ãæ瀺çã«äœ¿çšãããšã察å¿ããã¢ãžã¥ãŒã«ãããŒãããŸãã ããç¥ãããŠããã·ã§ã¢ãŠã©ãŒã«ã¢ãžã¥ãŒã«ãšãã®èšå®ã¯ããã¡ã€ã«/ usr / share / shorewall / helpersã§ç¢ºèªã§ããŸãã ããããå€æŽããå¿ èŠãããå Žåããã¡ã€ã«ã/ etc / shorewallã«ã³ããŒãããšããã®ã³ããŒãæšæºãã¡ã€ã«ãäžæžãããŸãã
ããŒããå éšãµãŒããŒã«è»¢éããå¿ èŠãããå Žåãããã¯é£ãããããŸããã
rules.red-dnat
# # Shorewall -- /etc/shorewall/rules.red-dnat # # For information on the settings in this file, type "man shorewall-rules" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-rules.html # ###################################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER # PORT(S) PORT(S) DEST LIMIT GROUP Web(DNAT) red grn:172.16.0.2 #, , DNAT : #Web(DNAT) red grn:172.16.0.2 - - - 192.168.10.37 #, : #DNAT red grn:172.16.0.2 tcp 80,443 #DNAT red grn:172.16.0.2 tcp 80,443 - 192.168.10.37 # : #DNAT red grn:172.16.0.2:80 tcp 8080
ããã«ãShorewallã¯ipsetsïŒããã±ãŒãžãã€ã³ã¹ããŒã«ãããŠããããšã確èªããŸãïŒyum install ipsetïŒããµããŒãããŸããããã¯åã«ååä»ãã¢ãã¬ã¹ãªã¹ãã§ãã ãµããããã«çµåã§ããªããã¹ãã®ã°ã«ãŒãã«ç¹å®ã®ã«ãŒã«ãèšå®ããå¿ èŠãããå Žåã«åœ¹ç«ã¡ãŸãã
æ§æã§ãããã䜿çšããããšã¯é£ãããããŸãããã¢ãã¬ã¹ãŸãã¯ãµããããã䜿çšããããã¹ãŠã®å Žæã«+ <ipsets nameãæžã蟌ãã ãã§ååã§ãã
åèµ·åäžã«Shorewallã«ipsetãä¿åããã³åŸ©å ããããå Žåãshorewall.confã§SAVE_IPSETS = Yesãèšå®ããå¿ èŠããããŸãã
ipsetsã䜿çšããå Žåãšäœ¿çšããªãå Žåã®æ§æã¯æ¬¡ã®ãšããã§ãã
ã«ãŒã«
# # Shorewall -- /etc/shorewall/rules # # For information on the settings in this file, type "man shorewall-rules" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-rules.html # ###################################################################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER # PORT(S) PORT(S) DEST LIMIT GROUP # ipsets OpenVPN(ACCEPT) red:192.168.10.4,192.168.23.2 $FW # ipsets OpenVPN(ACCEPT) red:+ovpn_allow $FW
æåã«ãipsetã宣èšããŸãã
# iphash ( , man ipset ) ipset -N ovpn_allow iphash # ipset -A ovpn_allow 192.168.10.4 ipset -A ovpn_allow 192.168.23.2
以äžã§ãèšé²ããå 容ã確èªã§ããŸããipset-L
Name: ovpn_allow Type: hash:ip Revision: 1 Header: family inet hashsize 1024 maxelem 65536 Size in memory: 16560 References: 0 Members: 192.168.23.2 192.168.10.4
Shorewallã®ã·ã³ãã«ãªè² è·åæ£ãšåé·æ§
ããã«èšããšããã©ã³ã·ã³ã°ãšåé·æ§ã¯Shorewallã䜿çšããŠã®ã¿èšå®ãããããèªäœã¯ãã£ãã«æ倱ãå®éã®è² è·ã®åæ£ãæ€åºããæ©èœãæäŸããŸããã
èšå®å šäœã¯ãåäžã®ãã¡ã€ã«ã®ç·šéã«ãªããŸãã
ãããã€ããŒ
# # Shorewall -- /etc/shorewall/providers # # For information about entries in this file, type "man shorewall-providers" # # For additional information, see http://shorewall.net/MultiISP.html # ############################################################################################ #NAME NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS COPY pr1 1 0x10000 - $IF_RED1 $GW_RED1 track,fallback=1 pr2 2 0x20000 - $IF_RED2 $GW_RED2 track,fallback=4
誰ããèŠããŠãããªããååã®èšäºã«ã¯ãShorewall.confãã®ã»ã¯ã·ã§ã³ããããŸããã ãã±ããã®ã©ãã«ä»ããæ§æãããããã€ããŒãšé£æºããããã ãã«å¿ èŠã§ãã ããã§ããã±ããã©ãã«ã®ã©ã®ãããããããã€ããŒIDãæå®ããããã©ã®ã©ãã«ãåçŽãïŒãŸã ã©ãã«ã䜿çšããŠããŸããããShorewallã¯èªåã®ããŒãºã«åãããŠäœ¿çšââããŸãïŒãããã³æ¥ç¶ã远跡ãããã®ãèšå®ããŸãã
ããã§ã¯ã2ã€ã®ãããã€ããŒã«ã€ããŠèª¬æãããããã«ããã±ãŒãžãããŒã¯ããæ¹æ³ãåã€ã³ã¿ãŒãã§ã€ã¹ã眮ãããŠããã€ã³ã¿ãŒãã§ã€ã¹ãããã³ã²ãŒããŠã§ã€ãåããŠããã€ã³ã¿ãŒãã§ã€ã¹ã«ã€ããŠèª¬æããŸããã
ãããOPTIONSåã§ããå°ã説æãå¿ èŠã§ãã ããã§ãfallbakããŒã¯ããã©ã³ã·ã³ã°ã«ãŒã«ããã±ãããåŠçã§ããªãå ŽåïŒããšãã°ãã€ã³ã¿ãŒãã§ã€ã¹ãã¬ã€ããŠã³ããå ŽåïŒã«è¿œå ã®ã«ãŒãã£ã³ã°ã«ãŒã«ãçæããããšã匷å¶ããæ°åã¯ã€ã³ã¿ãŒãã§ã€ã¹ã®éã¿ãèšå®ããŸãã trackãã©ã¡ãŒã¿ãŒã¯ãæ¥ç¶ãã©ã®ãããã€ããŒã«è¡ã£ãããç£èŠãããã®æ¥ç¶ãã次ã®ãã±ãããåããããã€ããŒã«éä¿¡ããå¿ èŠãããããšã瀺ããŸãïŒshorewall.confã§TRACK_PROVIDERS = Yesãèšå®ãããŠããå Žåããã®ãªãã·ã§ã³ã¯ãã¹ãŠã®ãããã€ããŒã«èªåçã«ç»é²ãããŸãïŒã ãããé »ç¹ã«æ°ããæ¥ç¶ãã€ã³ã¿ãŒãã§ã€ã¹ã«å±ããŸãïŒãã®çµæãçžå¯Ÿçãªéã¿ã䜿çšãããéã¿ã®å²åãé«ããªãããã©ãã£ãã¯ãå¢ããŸãã倧ããªéã¿å€ã®èšå®ã¯æšå¥šãããŸããïŒã ãã©ã³ã·ã³ã°ã¯ãã«ãŒãã«èªäœã«ãã£ãŠæ¢ã«ã©ãŠã³ãããã³æ¹åŒã«åŸã£ãŠè¡ãããã¯ã©ã€ã¢ã³ããšãµãŒããŒã®ã«ãŒãã«æ²¿ã£ãŠæ¥ç¶ã確ç«ãããšããäºå®ã«åºã¥ããŠããŸãïŒã¯ã©ã€ã¢ã³ããšããŠã®ã«ãŒã¿ãŒãšããµãŒããŒã¯ãããããªã¢ãŒããµãŒããŒã§ãïŒã ãã®å Žåãã«ãŒãã¯ãã°ãããã£ãã·ã¥ããããã®å¹æãåŸãããŸãïŒLANå ã®èª°ãããããšãã°ç¹å®ã®ãµã€ãïŒ1ã€ã®IPãããïŒã«ç»ãããã©ãã£ãã¯ããããã€ããŒ1ãééããä»ã®èª°ããããã«ç»ãããã©ãã£ãã¯ãå®è¡ãããŸãåã³ãããã€ããŒ1ã䜿çšããŸãïŒãã£ãã·ã¥ããªã»ããããæéããªãã£ãå ŽåïŒã ãŸããäŸã®ããã«å¯Ÿç§°ãããã€ããŒããªãããã幞éãªããšã«ãæåã®ãããã€ããŒã«æ¥ç¶ãã4ã€ããšã®æ¥ç¶ãæããé£ãããããšãããããŸããããããåé¿ãããã£ãã®ã§ã...ç°¡åãªè§£æ±ºçã¯ãããŸãããããã¯äœã®å©ãã«ããªããŸããã
ãããããã¹ãŠãããã»ã©æªããªãããã§ã¯ãªããããã§ãåšå³ããã£ãŠæ©èœããŸãïŒã¡ãªã¿ã«ãã»ãšãã©ã®ãœãªã¥ãŒã·ã§ã³ã§æ©èœããŸãããæ£çŽãªããã©ã³ã¹ããšãããã«ãéåžžã«é£ãããœãªã¥ãŒã·ã§ã³ã䜿çšãããŸãã
æ¡åŒµå€æ°ãã¡ã€ã«ïŒ
params
# # Shorewall -- /etc/shorewall/params # # Assign any variables that you need here. # # It is suggested that variable names begin with an upper case letter # to distinguish them from variables used internally within the # Shorewall programs # # Example: # # NET_IF=eth0 # NET_BCAST=130.252.100.255 # NET_OPTIONS=routefilter,norfc1918 # # Example (/etc/shorewall/interfaces record): # # net $NET_IF $NET_BCAST $NET_OPTIONS # # The result will be the same as if the record had been written # # net eth0 130.252.100.255 routefilter,norfc1918 # ############################################################################### IF_RED1=eth0 GW_RED1=192.168.10.1 IF_RED2=eth2 GW_RED2=detect IF_GRN=eth1 NET_GRN=172.16.0.0/23 IF_TUN=tap+ #LAST LINE -- DO NOT REMOVE
2çªç®ã®ãããã€ããŒã®ã²ãŒããŠã§ã€ããdetectãããŒã¯ãŒããšããŠæå®ãããŠããããšã«æ°ä»ãå ŽåããããŸããããã¯ãåçã¢ãã¬ã¹æå®ã䜿çšããæ¥ç¶ã§æ©èœããŸãã å Žåã«ãã£ãŠã¯ïŒPPtPãªã©ïŒãShorewallèªäœãã²ãŒããŠã§ã€ãæ£ããå€æã§ããªããããè£å©ã¹ã¯ãªããä»ãã®ãã¡ã€ã«ã䜿çšãããŸãã
findgw
# # Shorewall version 4 - Findgw File # # /etc/shorewall/findgw # # The code in this file is executed when Shorewall is trying to detect the # gateway through an interface in /etc/shorewall/providers that has GATEWAY # specified as 'detect'. # # The function should echo the IP address of the gateway if it knows what # it is; the name of the interface is in $1. # # See http://shorewall.net/shorewall_extension_scripts.htm for additional # information. # ############################################################################### LANG='C' nmcli --terse --fields IP6.GATEWAY device show ${1} | cut -f2- -d':' #IPv6 LANG='C' nmcli --terse --fields IP4.GATEWAY device show ${1} | cut -f2- -d':' #IPv4
ãããŠéèŠãªããšãšããŠãããããã¹ãŠãæ£ãããã¹ã¯ããå¿ èŠããããŸãã
ãã¹ã¯
# # Shorewall -- /etc/shorewall/masq # # For information about entries in this file, type "man shorewall-masq" # # The manpage is also online at # http://www.shorewall.net/manpages/shorewall-masq.html # ################################################################################################################################### #INTERFACE:DEST SOURCE ADDRESS PROTO PORT(S) IPSEC MARK USER/ SWITCH ORIGINAL PROBABILITY # GROUP DEST $IF_RED1 $NET_GRN detect $IF_RED2 $NET_GRN detect
ADDRESSåã®æ€åºãã©ã¡ãŒã¿ãŒã䜿çšãããšãSNATã®ã€ã³ã¿ãŒãã§ãŒã¹äžã®çºä¿¡ã¢ãã¬ã¹ãå€å¥ã§ããŸãïŒè€æ°ã®ãããã€ããŒã§å¿ èŠã«ãªããŸãïŒã
NetworkManagerã®ã¹ã¯ãªããã¯ããããã¹ãŠè£å®ããŸãïŒããåçŽãªããŒãžã§ã³ã¯ååã®èšäºã«ãããŸããããã€ã³ã¿ãŒãã§ãŒã¹ãäžããåŸãShorewallãã«ãŒãã£ã³ã°ããªã·ãŒãåžžã«æ£ããæ§ç¯ããããã§ã¯ãªãããšãèæ ®ããŠããªãã£ããããåçŽã«ãã®ãããªã€ã³ã¿ãŒãã§ãŒã¹ã«å¯ŸããŠåèµ·åããŸãïŒã
/etc/NetworkManager/dispatcher.d/30-shorewall.sh
#!/bin/bash IF=$1 # , STATUS=$2 # function check_prov() { PARAM=$(grep -v '^#' /etc/shorewall/params | grep $1 | cut -d '=' -f 1) if [ -z "$PARAM" ]; then grep -v '^#' /etc/shorewall/providers | grep -q $1 [[ $? == 0 ]] && shorewall restart else grep -v '^#' /etc/shorewall/providers | grep -q $PARAM [[ $? == 0 ]] && shorewall restart fi } case $STATUS in up) # shorewall enable $IF shorewall6 enable $IF check_prov $IF ;; down) # shorewall disable $IF shorewall6 disable $IF check_prov $IF ;; esac
ã·ã§ã¢ãŠã©ãŒã«ã®åèµ·ååŸãã³ãã³ããäžããåŸïŒ
shorewall show routing
çµã¿èŸŒã¿ã®ã«ãŒãã£ã³ã°ã¹ããŒã ã確èªã§ããŸãã
ã«ãŒãã£ã³ã°ã®äŸ
Shorewall 5.0.2.1 Routing at cent1.domain.local - 8 23:41:30 MSK 2016 Routing Rules 0: from all lookup local 999: from all lookup main 10000: from all fwmark 0x10000/0xff0000 lookup pr1 10001: from all fwmark 0x20000/0xff0000 lookup pr2 20000: from 192.168.10.37 lookup pr1 20000: from 192.168.10.36 lookup pr2 32765: from all lookup balance 32767: from all lookup default Table balance: Table default: default nexthop via 192.168.10.1 dev eth0 weight 1 nexthop via 192.168.10.1 dev eth2 weight 1 Table local: local 192.168.10.37 dev eth0 proto kernel scope host src 192.168.10.37 local 192.168.10.36 dev eth2 proto kernel scope host src 192.168.10.36 local 172.16.3.1 dev tap0 proto kernel scope host src 172.16.3.1 local 172.16.3.129 dev tap1 proto kernel scope host src 172.16.3.129 local 172.16.248.1 dev lo proto kernel scope host src 172.16.248.1 local 172.16.0.1 dev eth1 proto kernel scope host src 172.16.0.1 local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1 broadcast 192.168.10.255 dev eth2 proto kernel scope link src 192.168.10.36 broadcast 192.168.10.255 dev eth0 proto kernel scope link src 192.168.10.37 broadcast 192.168.10.0 dev eth2 proto kernel scope link src 192.168.10.36 broadcast 192.168.10.0 dev eth0 proto kernel scope link src 192.168.10.37 broadcast 172.16.3.255 dev tap1 proto kernel scope link src 172.16.3.129 broadcast 172.16.3.128 dev tap1 proto kernel scope link src 172.16.3.129 broadcast 172.16.3.127 dev tap0 proto kernel scope link src 172.16.3.1 broadcast 172.16.3.0 dev tap0 proto kernel scope link src 172.16.3.1 broadcast 172.16.248.1 dev lo proto kernel scope link src 172.16.248.1 broadcast 172.16.1.255 dev eth1 proto kernel scope link src 172.16.0.1 broadcast 172.16.0.0 dev eth1 proto kernel scope link src 172.16.0.1 broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1 broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1 local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1 Table main: 192.168.10.1 dev eth2 scope link src 192.168.10.36 172.16.3.1 dev tap0 proto zebra 172.16.3.129 dev tap1 proto zebra 172.16.248.2 via 172.16.3.2 dev tap0 proto zebra metric 13 172.16.12.129 via 172.16.3.2 dev tap0 proto zebra metric 3 172.16.11.1 via 172.16.3.2 dev tap0 proto zebra metric 3 172.16.3.128/25 dev tap1 proto kernel scope link src 172.16.3.129 172.16.3.0/25 dev tap0 proto kernel scope link src 172.16.3.1 192.168.10.0/24 dev eth2 proto kernel scope link src 192.168.10.36 metric 101 192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.37 metric 100 172.16.8.0/23 via 172.16.3.2 dev tap0 proto zebra metric 13 172.16.0.0/23 dev eth1 proto kernel scope link src 172.16.0.1 metric 100 Table pr1: 192.168.10.1 dev eth0 scope link src 192.168.10.37 default via 192.168.10.1 dev eth0 src 192.168.10.37 Table pr2: 192.168.10.1 dev eth2 scope link src 192.168.10.36 default via 192.168.10.1 dev eth2 src 192.168.10.36
ããããç¹å®ã®ãããã€ããŒã«ãã©ãã£ãã¯ãèªå°ããããšã¯å¯èœã§ããïŒ ã¯ããçããŠãã ããïŒ
ãã³ã°ã«
# # Shorewall -- /etc/shorewall/mangle # # For information about entries in this file, type "man shorewall-mangle" # # See http://shorewall.net/traffic_shaping.htm for additional information. # For usage in selecting among multiple ISPs, see # http://shorewall.net/MultiISP.html # # See http://shorewall.net/PacketMarking.html for a detailed description of # the Netfilter/Shorewall packet marking mechanism. # #################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP # PORT(S) PORT(S) MARK(0x20000):P 172.16.0.4 0.0.0.0/0!172.16.0.0/12
ããã§ã¯ã172.16.0.4ããã172.16.0.0 / 12ãé€ãä»»æã®ãããã¯ãŒã¯ãžã®ãã¹ãŠã®ãã©ãã£ãã¯ã«ã2çªç®ã®ãããã€ããŒã®ã©ãã«ãä»ããŸããã æ¡ä»¶ã¯ããè€éã«ãªãå¯èœæ§ããããŸããã²ãŒããŠã§ã€ã§çæããããã©ãã£ãã¯ã«ã€ããŠã¯ãã«ãŒã«ãããïŒPããåé€ããå¿ èŠããããŸãã
æããŠã²ã©ãQoS
ããã«èª¬æããå¿ èŠãããã®ã¯ãéä¿¡æã®é床ã®èª¿æŽã®ã¿ã§ãã å ¥ã£ãŠãããã©ãã£ãã¯ã¯ãã§ã«ã€ã³ã¿ãŒãã§ã€ã¹ã«å°éããŠããããã¹ãŠã®ããã«ããã¯ããã€ãã¹ãããã¥ãŒã«å ¥ãããšã§ãããã«ã¢ã¯ã»ã¹ã§ããŸãã
ãããã絶æããã®ã¯ææå°æ©ã§ãããç§ãã¡ãæãã»ã©ãšã¬ã¬ã³ãã§ä¿¡é Œæ§ã®äœãã¡ã«ããºã ããããŸããããã®åé¡ã解決ããŸãã ãããã³ã«ã®IPãã¡ããªã«åºã¥ããããã¯ãŒã¯ã§ã¯ãããã¯æ¬¡ã®ããã«è§£æ±ºãããŸãã
éä¿¡å ã¯ãé ä¿¡å¿çïŒTCPãããã³ã«ã®ACKãã±ããïŒãéåžžå°çããããéåžžã®é 延ã§å°çãããŸã§ãéä¿¡é床ãã¹ã ãŒãºã«äžããŸãã æ倱ãããããACKé 延ãå¢å ãããšãé床ã¯äœäžããŸãã ãã®åŸãäžå®ã®æéã®åŸã圌ãã¯åã³é床ãäžããããšããŸãã ãããŠãããã¯è»¢éã®çµäºåã«èµ·ãããŸãã
ããããUDPã¯ã©ãã§ããïŒ ãããŠã圌ã«ãšã£ãŠã¯ãã¹ãŠãã·ã³ãã«ã§ãé é管çãé çããããŸããã éä¿¡æžã¿ã§OKïŒåä¿¡è ã«è¢«å®³ãäžããŸãïŒã
ãã¡ããããã®çŽç²ãªåœ¢åŒã§ã¯ãUDPã¯éåžžãè€éãªããŒã¿è»¢éã¿ã¹ã¯ã§ã¯äœ¿çšãããŸããã ãã®ãããã³ã«ã¯éåžžãç¬èªã®ããŒãžã§ã³ã®é ä¿¡å¶åŸ¡ãå®è£ ããéã®åºç€ãšããŠäœ¿çšãããŸãïŒæšæºãé©åããªãå Žåãç¬èªã®TCPå®è£ ãšèšããŸãïŒã ãããã£ãŠãUDPäžã§å®è¡ãããå€ãã®ãããã³ã«ã§ã¯ãé ä¿¡å¶åŸ¡ããããŸãã ããã¯ããã«ãã¯ãŒã§UDPã®é£ç¶ã¹ããªãŒã ãéä¿¡ããæ©èœãç¡å¹ã«ãããã¿ãŒã²ããïŒåãããŒãžã§ã³ã®DDoSïŒã®éä¿¡ãã£ãã«ãè©°ãŸãããŸãã
çä¿¡ãã©ãã£ãã¯ã®ãã©ãã£ãã¯ã®åªå é äœä»ããšåž¯åå¹ å²ãåœãŠãæŽçããã«ã¯ã©ãããã°ããã§ããïŒ çãã¯äžã«ãããŸãïŒããªãã®åŽã§ã®åä¿¡ã®é 延ïŒçµæãšããŠãACKã®çæã®é 延ïŒãäœæããããé 延ãé床ã«å€§ããå Žåããã±ãããããããããŸãã
Linuxã§ã¯ãIFBæ¬äŒŒã€ã³ã¿ãŒãã§ã€ã¹ãäœæããããšã§å®è£ ãããŸããIFBã¯ãç©çã€ã³ã¿ãŒãã§ã€ã¹ãšã²ãŒããŠã§ã€èªäœã®éã«äœçœ®ããçä¿¡ãã©ãã£ãã¯ãééãããŸãã ãã©ãã£ãã¯ã¯ç©çã€ã³ã¿ãŒãã§ã€ã¹ã«å ¥ãïŒæ¢ã«åãå ¥ããããŠããŸãïŒãIFBã«é²ã¿ãŸããIFBã¯ããã®ãã©ãã£ãã¯ãã¹ãããããïŒãŸãã¯å®å šã«ããããããïŒé床ãšé åºããã§ã«å¶åŸ¡ããŠããŸãã
Shorewallã¯èšå®ãæ¯æŽããŸãïŒ/etc/modprobe.dã«æžã蟌ãããšãã§ããŸãïŒïŒ
/ etc / shorewall / init
# # Shorewall -- /etc/shorewall/init # # Add commands below that you want to be executed at the beginning of # a "shorewall start", "shorewall-reload" or "shorewall restart" command. # # For additional information, see # http://shorewall.net/shorewall_extension_scripts.htm # ############################################################################### modprobe ifb numifbs=3 ip link set ifb0 up ip link set ifb1 up ip link set ifb2 up
ããã§ã¯ç°¡åã§ãã3ã€ã®æ¬äŒŒIFBã€ã³ã¿ãŒãã§ã€ã¹ãäœæããããããäœæããŸããã
次ã«ããã©ãã£ãã¯ã調æŽããã€ã³ã¿ãŒãã§ã€ã¹ã«ã€ããŠèª¬æããŸãã
tcdevices
# # Shorewall -- /etc/shorewall/tcdevices # # For information about entries in this file, type "man shorewall-tcdevices" # # See http://shorewall.net/traffic_shaping.htm for additional information. # ############################################################################### #NUMBER: IN-BANDWITH OUT-BANDWIDTH OPTIONS REDIRECTED #INTERFACE INTERFACES 1:$IF_GRN - 1000mbit hfsc,classify 2:ifb1 - 1000mbit hfsc,classify $IF_GRN 3:$IF_RED1 - 10mbit hfsc,classify 4:ifb0 - 10mbit hfsc,classify $IF_RED1 5:$IF_RED2 - 10mbit hfsc,classify 6:ifb2 - 10mbit hfsc,classify $IF_RED2
ããã§ã¯ã䜿çšãããã€ã³ã¿ãŒãã§ã€ã¹ã®çªå·ãæ瀺çã«èšå®ãïŒæå®ãããŠããªãå ŽåãShorewallã¯ãã¡ã€ã«å®£èšã®é ã«çªå·ãä»ããŸãïŒãIFBãå®éã®ã€ã³ã¿ãŒãã§ã€ã¹ã«é¢é£ä»ããæ倧çºä¿¡é床ãèšå®ããŸãïŒå¶åŸ¡ããã ãã§ãifbã¯åºæ¬çã«çä¿¡ã§ãïŒè¡ïŒã䜿çšããŠãåé¡èŠåãšã©ã®ãã©ãã£ãã¯ãæ£ç¢ºã«åé¡ããããèšå®ããŸãã
éèŠïŒ é床ã¯ããããã€ããŒãæäŸããé床ãããããã«äœãèšå®ããå¿ èŠããããŸãã ãããã€ããŒãæäŸããé床ãããæäœé床ãéãå Žåã垯åå¹ ã®å¶éããã®åŽã§çºçããŸããã€ãŸããåé¡ãªã©ã®è©Šè¡ããã¹ãŠè¡ãããŸãã ïŒå®å šã§ã¯ãããŸãããã倧éšåã¯ïŒç¡é§ã«ãªããŸãã 垯åå¹ ãå¯å€ã®ãã£ãã«ã§ã¯ããã¹ãŠã®äœæ¥ããŒã«ããããããQoSãå®è¡ããã®ã¯éåžžã«å°é£ã§ãã貎éãªãã©ãã£ãã¯ããã£ãã«ãã¯ããŒã«ããããšãæåŸ ããŠããã±ããã®é åºãå€æŽããã ãã§ãïŒç¡ç·ãã£ãã«ã®è¢«çœè ã¯æ²ãããã«ããæ¯ãã€ããŸãïŒã
ã¯ã©ã¹ãã®ãã®ã«ã€ããŠèª¬æããŸãããã
tcclasses
# # Shorewall -- /etc/shorewall/tcclasses # # For information about entries in this file, type "man shorewall-tcclasses" # # See http://shorewall.net/traffic_shaping.htm for additional information. # ############################################################################### #INTERFACE:CLASS MARK RATE: CEIL PRIORITY OPTIONS # DMAX:UMAX 1:1:2 - 1mbit 3mbit 2 default 1:1:3 - 256kbit full 1 2:1:2 - 1mbit 3mbit 2 default 2:1:3 - 256kbit full 1 3:1:2 - 1mbit 3mbit 2 default 3:1:3 - 256kbit full 1 4:1:2 - 1mbit 3mbit 2 default 4:1:3 - 256kbit full 1 5:1:2 - 1mbit 3mbit 2 default 5:1:3 - 256kbit full 1 6:1:2 - 1mbit 3mbit 2 default 6:1:3 - 256kbit full 1
è€éãªããšã¯äžåè¡ããïŒãããã£ãŠãèå³æ·±ãæçšã§ãïŒã2ã€ã®ã¯ã©ã¹ãåã€ã³ã¿ãŒãã§ã€ã¹ïŒIFBãå«ãïŒã«ãã€ã³ãããŸãã
æåã®åã§ã¯ãã€ã³ã¿ãŒãã§ã€ã¹ãã¯ã©ã¹ã«é¢é£ä»ããŸãã <ã€ã³ã¿ãŒãã§ã€ã¹çªå·>ïŒ<芪ã¯ã©ã¹çªå·>ïŒ<èšè¿°ãããã¯ã©ã¹çªå·>ã
ã€ã³ã¿ãŒãã§ã€ã¹ã«ã¯åžžã«ã¯ã©ã¹1ããããŸããããã«ã€ããŠã¯ãåºæ¬çã«tcdevicesã§èª¬æããŸããã
ããã«ããã±ãããããŒã¯ããªãã£ãããããã®åã䜿çšããããã®ã¯ã©ã¹ã§æãèå³æ·±ããæå°éã«ä¿èšŒããã垯åå¹ ãããã³å¯èœãªæ倧ïŒèŠªã¯ã©ã¹ã®åž¯åå¹ ä»¥äžïŒã䜿çšãããŸãã åªå é äœã¯ãç©è°ãéžãç¶æ³ã解決ããããã®é åºãèšå®ããŸãïŒä¿èšŒãããã¹ããªããã®éè·¯ãè¶ ããŠããã§ã«ä»ã®èª°ãã«ãã£ãŠå®å šã«å æãããŠããå Žåãããå°ãªããã®ãæåã«è¡ããŸãïŒã çµè«ãšããŠããªãã·ã§ã³ããããŸããããã©ã«ãã§ã¯ããã£ã«ã¿ãŒã§äœãèŠã€ãããªãå ŽåïŒããã±ãŒãžãã¯ã©ã¹ã«å²ãåœãŠãããŠããªãå ŽåïŒãããã©ã«ãã®ã¯ã©ã¹ãå²ãåœãŠãŸãã
ããã«ãå®éã«ã¯ãå®éã®ã€ã³ã¿ãŒãã§ã€ã¹ã®åé¡ã«ãŒã«ããã¡ã€ã«ã«å«ãŸããŠããããšãæŽå²çã«èµ·ãããŸããã
ãã³ã°ã«
# # Shorewall -- /etc/shorewall/mangle # # For information about entries in this file, type "man shorewall-mangle" # # See http://shorewall.net/traffic_shaping.htm for additional information. # For usage in selecting among multiple ISPs, see # http://shorewall.net/MultiISP.html # # See http://shorewall.net/PacketMarking.html for a detailed description of # the Netfilter/Shorewall packet marking mechanism. # #################################################################################################################################################### #ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP # PORT(S) PORT(S) CLASSIFY(1:3) 0.0.0.0/0 0.0.0.0/0 tcp - 80,443 CLASSIFY(3:3) 0.0.0.0/0 0.0.0.0/0 tcp 80,443
ãããŠã次ã®ä»®æ³IFBã®å ŽåïŒ
tcfilters
# # Shorewall -- /etc/shorewall/tcfilters # # For information about entries in this file, type "man shorewall-tcfilters" # # See http://shorewall.net/traffic_shaping.htm for additional information. # ######################################################################################################## #INTERFACE: SOURCE DEST PROTO DEST SOURCE TOS LENGTH PRIORITY #CLASS PORT(S) PORT(S) 2:3 0.0.0.0/0 0.0.0.0/0 tcp - 80,443 4:3 0.0.0.0/0 0.0.0.0/0 tcp 80,443
äžèšã®äŸã§ã¯ãHTTPïŒSïŒãµãŒããŒããã®çä¿¡ãã©ãã£ãã¯ãç©çã€ã³ã¿ãŒãã§ã€ã¹ãšããã«é¢é£ä»ããããä»®æ³ã€ã³ã¿ãŒãã§ã€ã¹ã®ã¯ã©ã¹çªå·3ã«é 眮ããçºä¿¡ã¯åãããšãè¡ããŸãããããããŒãã®ãããã€ããè¡ããŸããã æ¥ç¶ã¯å€ãã®å Žååæ¹åã§ãããã¯ã©ã€ã¢ã³ããŸãã¯ãµãŒããŒãéå§ãããŠãŒã¶ãŒã«é¢ä¿ãªããåæ¹åã«åé¡ãåå¥ã«ãã€ã³ãããå¿ èŠãããããšã«æ³šæããŠãã ããã
å±æ ¹ãå²ãå§ããã®ã¯ããã§ãã ç解ããããã«ãç»åã圹ç«ã¡ãŸãïŒç¹ã«ããã¯ããªãããã«ãé¡ãããŸããVisioã§ã¯ãå®éã«åäœããæ¹æ³ãããããŸããïŒã
ãã®çµæã1ã€ã®ãããã€ããŒããããã²ãŒããŠã§ã€èªäœããã©ãã£ãã¯ãåãå ¥ããªãå ŽåïŒåä¿¡è ã§ã¯ãªãå ŽåïŒãIFBã䜿çšããã«ç°ãªããšãªã¢ã§ãã©ãã£ãã¯ãã«ããã§ããŸãã ãããã€ããŒãããã«ãããã²ãŒããŠã§ã€èªäœããã©ãã£ãã¯ãã¢ã¯ãã£ãã«åãå ¥ããå ŽåïŒããšãã°ãVPNã«ãµãŒãã¹ãæäŸããå ŽåïŒãIFBããªããã°ãç°¡åã«åºãããŸããã
PS
次ã®èšäºã§ã¯ãç¹ã«VoIPãã¯ãããžãŒã®æ®åãèæ ®ããŠãQoSã«ããã«çŠç¹ãåœãŠãäºå®ã§ãã ãããã¯ã¯å€§ããããã¹ãŠãæ éã«èšç»ããå¿ èŠããããŸãã ç¹å®ã®åŽé¢ã«ããã«èå³ãããå Žåã¯ãã³ã¡ã³ãã«ãªã¯ãšã¹ããæžããŠãã ããã次ã®èšäºã§ãã®èŠæãèæ ®ããŸãã