listening sockets 보기.
# ss -l
모든 소켓 보기.
# ss - a
TCP 소켓 보기.
# ss - t
UDP 소켓 보기.
# ss - u
소켓 사용하는 프로세스 보기.
# ss - p
소켓 사용하는 메모리 보기.
# ss - m
참조
# ss -l
# ss - a
# ss - t
# ss - u
# ss - p
# ss - m
윈도우 방화벽을 이용해서 한국에서의 접속 IP 만 접근 가능 하도록 파워쉘로 만들었다.
특정 포트를 지정해 줘야 한다. 기존에 allow되어 있던 부분은 사용안함 처리 해야 한다.
소스는 아래와 같다.
#get-help about_signing 참조하라는 에러 발생시, #Set-ExecutionPolicy RemoteSigned 실행. #############Config################# $countryCode="KR" #차단을 하지 않을 나라의 CountryCode $geoIPcsvPath="c:\GeoIPCountryWhoisPaid.csv" #$geoIPcsvPath="\GeoIPCountryWhois.csv" #ISE에서 실행시 찾지 못함. $ruleName="allowCountry" $allowPort="3389,1433" #############Config################# $geoData=Import-Csv $geoIPcsvPath -header sIP, eIP, cc | where-object {$_.cc –eq $countryCode} $geoDataTotal=$geoData.Count $remoteIP="" ###### 룰이 있는 지 체크 ######## function ruleExistsChk ($ruleName) { $fw=New-object -comObject HNetCfg.FwPolicy2; # http://blogs.technet.com/b/jamesone/archive/2009/02/18/how-to-manage-the-windows-firewall-settings-with-powershell.aspx $RuleCHK=$fw.rules | where-object {$_.name –eq $ruleName} if(!$RuleCHK){ #$deny_rule_name + " 룰이 생성되어 있지 않습니다."; exit; #허용하는 룰 생성. netsh advfirewall firewall add rule name="$ruleName" localport="$allowPort" protocol=TCP localip=any dir=in action=allow profile="any" interfacetype="any" } } ###### 룰이 있는 지 체크 ######## $count=1 foreach ($geoIP in $geoData) { #$remoteIP+=@($geoIP.sIP+"-"+$geoIP.eIP+",") #배열로 저장. $remoteIP+=$geoIP.sIP+"-"+$geoIP.eIP+"," try { #remoteAddr가 한개의 룰에 약 300개 이상이면 등록이 안됨. 안전하게 200으로 설정. if(($count%200) -eq 0) { $makeRuleName=$ruleName+$countryCode+$count ruleExistsChk($makeRuleName) netsh advfirewall firewall set rule name=$makeRuleName new remoteip="$remoteIP" $remoteIP="" }elseif($geoDataTotal -eq $count){ $makeRuleName=$ruleName+$countryCode+$count ruleExistsChk($makeRuleName) netsh advfirewall firewall set rule name=$makeRuleName new remoteip="$remoteIP" $remoteIP="" } }catch { Write-Warning "Error occured: $_" } $count++ }
#문의는 http://blog.netchk.net/ #############Config################# $countryCode="CN" #차단할 나라의 CountryCode #$geoIPcvsPath="c:\GeoIPCountryWhois.csv" $geoIPcvsPath="\GeoIPCountryWhois.csv" $ruleName="blockCountry" #############Config################# $geoData=Import-Csv $geoIPcvsPath -header sIP, eIP, start, end, cc, cn | where-object {$_.cc –eq $countryCode} $geoDataTotal=$geoData.Count $remoteIP="" ###### 룰이 있는 지 체크 ######## function ruleExistsChk ($ruleName) { $fw=New-object -comObject HNetCfg.FwPolicy2; # http://blogs.technet.com/b/jamesone/archive/2009/02/18/how-to-manage-the-windows-firewall-settings-with-powershell.aspx $RuleCHK=$fw.rules | where-object {$_.name –eq $ruleName} if(!$RuleCHK){ #$deny_rule_name + " 룰이 생성되어 있지 않습니다."; exit; netsh advfirewall firewall add rule name="$ruleName" localip=any dir=in action=block profile="any" interfacetype="any" } } ###### 룰이 있는 지 체크 ######## $count=1 foreach ($geoIP in $geoData) { #$remoteIP+=@($geoIP.sIP+"-"+$geoIP.eIP+",") #배열로 저장. $remoteIP+=$geoIP.sIP+"-"+$geoIP.eIP+"," #remoteAddr가 한개의 룰에 약 300개 이상이면 등록이 안됨. 안전하게 200으로 설정. if(($count%200) -eq 0) { $makeRuleName=$ruleName+$countryCode+$count ruleExistsChk($makeRuleName) netsh advfirewall firewall set rule name=$makeRuleName new remoteip="$remoteIP" $remoteIP="" }elseif($geoDataTotal -eq $count){ $makeRuleName=$ruleName+$countryCode+$count ruleExistsChk($makeRuleName) netsh advfirewall firewall set rule name=$makeRuleName new remoteip="$remoteIP" $remoteIP="" } $count++ }
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in strerr.a(strerr_sys.o)
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
cat /var/log/maillog | awk '{$1="";$2="";$3="";$4="";$5="";print}' > /tmp/qmailLogTmp
cat /tmp/qmailLogTmp | /usr/local/qmailanalog/bin/matchup | /usr/local/qmailanalog/bin/zoverall > /tmp/qmailLog
matchup: fatal: unable to write fd 5: file descriptor not open
<log.1 matchup >out.1 5>pending.2
cat pending.2 log.2 | matchup >out.2 5>pending.3
cat pending.3 log.3 | matchup >out.3 5>pending.4
cat /var/log/maillog* | awk '{$1="";$2="";$3="";$4="";$5="";print}' > /tmp/qmailLogTmp
cat /tmp/qmailLogTmp | /usr/local/qmailanalog/bin/matchup | /usr/local/qmailanalog/bin/zoverall > /tmp/qmailLog
[root@mail qmailanalog-0.70]# cat /tmp/qmailLog
Basic statistics
qtime is the time spent by a message in the queue.
ddelay is the latency for a successful delivery to one recipient---the
end of successful delivery, minus the time when the message was queued.
xdelay is the latency for a delivery attempt---the time when the attempt
finished, minus the time when it started. The average concurrency is the
total xdelay for all deliveries divided by the time span; this is a good
measure of how busy the mailer is.
Completed messages: 18684
Recipients for completed messages: 24230
Total delivery attempts for completed messages: 24458
Average delivery attempts per completed message: 1.30903
Bytes in completed messages: 5.20127e+09
Bytes weighted by success: 1.00912e+10
Average message qtime (s): 15.4838
Total delivery attempts: 24458
success: 24060
failure: 170
deferral: 228
Total ddelay (s): 158313.276733
Average ddelay per success (s): 6.579937
Total xdelay (s): 169514.560113
Average xdelay per delivery attempt (s): 6.930843
Time span (days): 7.42548
Average concurrency: 0.264222