上一篇里面遇到了只能靜態上網的問題,動態不行。所以再接再勵,問題總是要解決的,偷懶的下場就是一直停留在菜鳥的水平。
首先分析下問題,要動態上網,首先我要明確不是動態獲取不了IP,是獲取了,上不了外網。那么問題就不會在lan口的配置上了,肯定是wan口,再來看我們的wan口配置。都一樣,ifconfig|more,看了一下,eth1,eth2,eth3居然HWaddr都是00:A0:C9:00:00:00,不知道這樣會不會影響上外網,但是肯定不對吧,所以我改了下:
config interface wan option ifname eth1 option proto dhcp option macaddr 00:A0:C9:00:00:0A config interface wan option ifname eth1 option proto dhcp option macaddr 00:A0:C9:00:00:0B config interface wan option ifname eth1 option proto dhcp option macaddr 00:A0:C9:00:00:0C
沒別的就是各加了個mac地址。
那么再試一下,果然都有自己的IP地址了,雖然我的lan口還是不能上外網。
那么主機ping一下,這里的主機其實就是我們的CPU,之前一直以為是網卡在ping。主機ping通外網了。動態獲取了IP了,那么問題肯定在數據流向了。他到了我們主機這里,而且主機可以上外網了,那么肯定就是lan口和wan口數據不通了,一頓百度和谷歌,覺得有可能是firewall的問題,而且我們這里有3個wan口,那么后面的配置肯定還和multiwan有關,那么就去看/etc/config目錄下firewall和multiwan這兩個文件。
首先我發現之前第一篇的wan配置是不是有點麻煩,每個口都寫zone和forwarding,看到網上其他人不用這么麻煩,所以精簡成下面這樣,試了一下,發現不影響,后來把forward那個reject編程ACCEPT,平板上網了。
config zone option name wan option network ‘wan wan1 wan2’ option input REJECT option output ACCEPT option forward ACCEPT option masq 1 option mtu_fix 1
不過我還改了multiwan,但是我不認為multiwan是讓我可以上網的原因。
那么multiwan是干什么的呢,初步分析認為,他是用來進行多wan口上網時進行流量均衡和wan口切換用的。我的配置了下,發現達到網上某些人說的多wan了,看了下3個wan口還真是都在走流量。在總的status里面MultiWAN-Status,3個wan,wan1,wan2都綠了,但是我試了,我把wan口拔掉,然后上網,不行,得重新啟動下網絡,防火牆和multiwan,/etc/init.d/network(firewall,multiwan) restart,然后才又可以上網,這明顯不是multiwan的作用。至於怎么配置,繼續探索一下。
這里記錄下整個multiwan文件:
config 'multiwan' 'config' option 'default_route' 'balancer' # health_monitor below is defaulted to parallel, and can be set to # serial to save system resources. # option 'health_monitor' 'serial' # option 'debug' '1' config 'interface' 'wan' option 'weight' '1' option 'health_interval' '10' option 'icmp_hosts' 'gateway' # icmp_count is defaulted to 1, and can be increased to reduce # false positives. # option 'icmp_count' '3' option 'timeout' '3' option 'health_fail_retries' '3' option 'health_recovery_retries' '5' option 'failover_to' 'wan1' option 'dns' 'auto' config 'interface' 'wan1' option 'weight' '1' option 'health_interval' '10' option 'icmp_hosts' 'gateway' option 'timeout' '3' option 'health_fail_retries' '3' option 'health_recovery_retries' '5' option 'failover_to' 'wan2' option 'dns' 'auto' config 'interface' 'wan2' option 'weight' '1' option 'health_interval' '10' option 'icmp_hosts' 'gateway' option 'timeout' '3' option 'health_fail_retries' '3' option 'health_recovery_retries' '5' option 'failover_to' 'wan' option 'dns' 'auto' #config 'mwanfw' # option 'src' '192.168.1.0/24' # option 'dst' 'ftp.netlab7.com' # option 'proto' 'tcp' # option 'ports' '21' # option 'wanrule' 'lan' # VoIP traffic goes through wan # config 'mwanfw' # option 'src' '192.168.1.0/24' # option 'proto' 'udp' # option 'port_type' 'source-ports' # option 'ports' '5060,16384:16482' # option 'wanrule' 'wan' config 'mwanfw' # option 'src' '192.168.0.3' # option 'proto' 'icmp' option 'wanrule' 'balancer' config 'mwanfw' # option 'dst' 'www.whatismyip.com' option 'wanrule' 'fastbalancer'