2015-11-14 41 views
0

我想創建2個網絡之間使用2個路由器,我有10個主機,並且其中9個ping成功,並且1不ping(我正在配置與其他人一樣)。這裏是代碼,看看是否有人可以告訴我最新的問題。兩個網絡與特定主機之間的Netkit連接問題

lab.conf

C1[1]="A" 
C2[1]="A" 

R1[1]="A" 

R2[1]="A" 

LB1[0]="A" 
LB1[1]="B" 

LB2[0]="A" 
LB2[1]="B" 

S11[0]="B" 
S12[0]="B" 
S21[0]="B" 
S22[0]="B" 

C1.startup

ifconfig eth1 192.168.2.10 netmask 255.255.255.248 up 
route add default gw 192.168.2.11 

C2.startup

ifconfig eth1 192.168.2.13 netmask 255.255.255.248 up 
route add default gw 192.168.2.14 

R1.startup

/sbin/ifconfig eth1 192.168.2.9 netmask 255.255.255.248 broadcast 192.168.2.15 up 

R2.startup

/sbin/ifconfig eth1 192.168.2.12 netmask 255.255.255.248 broadcast 192.168.2.15 up 

LB1.startup

/sbin/ifconfig eth0 192.168.2.11 netmask 255.255.255.248 up 
/sbin/ifconfig eth1 192.168.1.11 netmask 255.255.255.248 up 

iptables --table nat --append PREROUTING --destination 192.168.2.11 --match statistic --mode nth --every 2 --jump DNAT --to-destination 192.168.1.10 
iptables --table nat --append PREROUTING --destination 192.168.2.11 --jump DNAT --to-destination 192.168.1.9 
iptables --table nat --append POSTROUTING --source 192.168.2.8/29 --destination 192.168.1.8/29 --jump MASQUERADE 

echo "watch 'iptables -t nat -vnL'" >> /root/.bashrc 

LB2.startup

/sbin/ifconfig eth0 192.168.2.14 netmask 255.255.255.248 up 
/sbin/ifconfig eth1 192.168.1.14 netmask 255.255.255.248 up 

iptables --table nat --append PREROUTING --destination 192.168.2.14 --match statistic --mode nth --every 2 --jump DNAT --to-destination 192.168.1.12 
iptables --table nat --append PREROUTING --destination 192.168.2.14 --jump DNAT --to-destination 192.168.1.13 
iptables --table nat --append POSTROUTING --source 192.168.2.8/29 --destination 192.168.1.8/29 --jump MASQUERADE 

echo "watch 'iptables -t nat -vnL'" >> /root/.bashrc 

S11.startup

ifconfig eth0 192.168.1.10 netmask 255.255.255.248 up 
route add default gw 192.168.1.11 
/etc/init.d/apache2 start 

S12.startup

ifconfig eth0 192.168.1.9 netmask 255.255.255.248 up 
route add default gw 192.168.1.11 
/etc/init.d/apache2 start 

S21.startup

ifconfig eth0 192.168.1.12 netmask 255.255.255.248 up 
route add default gw 192.168.1.14 
/etc/init.d/apache2 start 

S22.startup

ifconfig eth0 192.168.1.13 netmask 255.255.255.248 up 
route add default gw 192.168.1.14 
/etc/init.d/apache2 start 

我有問題的主機是S22。

謝謝!

回答

0

問題是,在最後lab.conf沒有一個或兩個,idk正好,因爲我只是插入它兩次,並開始認識到S22!