📄 nattest
字号:
#!/bin/bash# nattest shell script# set defaults# Interfaces typically begin eth on Linux, en on Macintosh, le or hme on Solaris# type ifconfig -a or ifconfig -l to see a list of all interfacesserverint=eth0clientint=eth1serverip1=1.1.1.2serverip2=1.1.1.3servermask=255.255.255.0clientip1=192.168.0.2clientip2=192.168.0.3clientmask=255.255.255.0# print warning, get confirmationcat nattestwarning.txtread -p "Are you sure you want to run this? [yes]" confirmcase $confirm in [nN] ) exit;; [nN][oO] ) exit;;esac# off we go then....# add second IP address to each interfaceifconfig $serverint $serverip2 netmask 255.255.255.255 aliasifconfig $clientint $clientip2 netmask 255.255.255.255 alias# for Solaris, use these instead# ifconfig ${serverint}:1 $serverip2 netmask $servermask# ifconfig ${clientint}:1 $clientip2 netmask $clientmask./stund -h $serverip1 -a $serverip2 -b# verify server is running./stunner $serverip1 -i $clientip1 -i2 $clientip2# process results of stunner and print pass/failcase "$?" in 10 ) echo "[PASS] (Address) Restricted Cone NAT with Hairpinning";; 11 ) echo "[PASS] Port Restricted Cone NAT with Hairpinning";; 8 ) echo "[No NAT] You have open internet access";; 2 ) echo "[FAIL] Your (Address) Restricted Cone NAT doesn't do hairpinning";; 3 ) echo "[FAIL] Your Port Restricted Cone NAT doesn't do hairpinning";; -1 ) echo "ERROR! the STUN test program had an error";; * ) echo "[FAIL] You have a NAT or Firewall type which is NOT RECOMMENDED.";;esac# cleanupkillall -HUP stundifconfig $serverint $serverip2 -aliasifconfig $clientint $clientip2 -alias# for Solaris, use these instead# ifconfig ${serverint}:1 unplumb# ifconfig ${clientint}:1 unplumb
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -