#!/bin/sh
/root/confignet

iptables -t nat -A POSTROUTING -d 192.168.111.1 -j SNAT --to-source 192.168.111.171
iptables -t nat -A PREROUTING -d  192.168.111.1 -j DNAT --to-destination 192.168.111.254

iptables -t nat -A POSTROUTING -d 192.168.111.2 -j SNAT --to-source 192.168.111.172
iptables -t nat -A PREROUTING -d  192.168.111.2 -j DNAT --to-destination 192.168.111.254

iptables -t nat -A POSTROUTING -d 192.168.111.3 -j SNAT --to-source 192.168.111.173
iptables -t nat -A PREROUTING -d  192.168.111.3 -j DNAT --to-destination 192.168.111.254

iptables -t nat -A POSTROUTING -d 192.168.111.4 -j SNAT --to-source 192.168.111.174
iptables -t nat -A PREROUTING -d  192.168.111.4 -j DNAT --to-destination 192.168.111.15

ifconfig eth0 192.168.111.254 hw ether 00:01:02:03:04:05
ifconfig eth1 192.168.111.11 hw ether 00:01:02:03:04:05
ifconfig eth2 192.168.111.12 hw ether 00:01:02:03:04:05
ifconfig eth3 192.168.111.13 hw ether 00:01:02:03:04:05
ifconfig eth4 192.168.111.14 hw ether 00:01:02:03:04:05
ifconfig eth5 192.168.111.15 hw ether 00:01:02:03:04:05


arp -s 192.168.111.171 00:01:02:03:04:05 dev eth0
arp -s 192.168.111.172 00:01:02:03:04:05 dev eth0
arp -s 192.168.111.173 00:01:02:03:04:05 dev eth0

route add -host 192.168.111.174 dev eth5
arp -s 192.168.111.174 00:01:02:03:04:05 dev eth5

route add -host 192.168.111.1 dev eth1
arp -s 192.168.111.1 00:01:02:03:04:05 dev eth1

route add -host 192.168.111.2 dev eth2
arp -s 192.168.111.2 00:01:02:03:04:05 dev eth2

route add -host 192.168.111.3 dev eth3
arp -s 192.168.111.3 00:01:02:03:04:05 dev eth3

route add -host 192.168.111.4 dev eth4
arp -s 192.168.111.4 00:01:02:03:04:05 dev eth4

route add -host 192.168.111.5 dev eth5
arp -s 192.168.111.5 00:01:02:03:04:05 dev eth5


echo 1 > /proc/sys/net/ipv4/ip_forward


echo connect eth0 with eth1 now,then press enter
read
ping -c 3 192.168.111.1

echo connect eth0 with eth2 now,then press enter
read
ping -c 3 192.168.111.2

echo connect eth0 with eth3 now,then press enter
read
ping -c 3 192.168.111.3


echo connect eth4 with eth5 now,then press enter
read
ping -c 3  192.168.111.4

echo net test done

