ip link set dev eth1 up ip link set dev eth2 up ip a add 192.168.155.3/24 dev eth1 ip a add 192.168.166.5/24 dev eth2 ip r add 16.0.0.0/8 via 192.168.155.2 ip r add 48.0.0.0/8 via 192.168.166.4 ip n add 192.168.155.2 dev eth1 lladdr $0 ip n add 192.168.166.4 dev eth2 lladdr $1 echo 1 > /proc/sys/net/ipv4/ip_forward
a=(`ip a | grep ^[1-9] | awk -F: '{print $2}' | sed '1,2d'`) for ((i=0;i<2;i++)) do b[$i]=`ethtool -i ${a[$i]} |grep bus | awk -F ':' '{print $3 $4 $5}'|sed -e 's/../\0:/'` done for ((i=0;i<2;i++)) do echo ${a[$i]} ${b[$i]} done for ((i=0;i<2;i++)) do e[$i]=`ip link show ${a[$i]} |head -2|tail -1|awk '{print $2}'` done cp /root/trex/v2.81/cfg/simple_cfg.yaml /etc/trex_cfg.yaml.bak sed '4,$d' /etc/trex_cfg.yaml.bak >/etc/trex_cfg.yaml echo -e ' interfaces : ["'${b[0]}'","'${b[1]}'"]'>>/etc/trex_cfg.yaml echo -e ' port_info : # Port IPs. Change to suit your needs. In case of loopback, you can leave as is.'>>/etc/trex_cfg.yaml echo -e ' - ip : 192.168.155.2'>>/etc/trex_cfg.yaml echo -e ' default_gw : 192.168.155.3'>>/etc/trex_cfg.yaml echo -e ' - ip : 192.168.166.4'>>/etc/trex_cfg.yaml echo -e ' default_gw : 192.168.166.5'>>/etc/trex_cfg.yaml echo -e '\n\n'>>/etc/trex_cfg.yaml cd ~/trex/v2.81/ ./dpdk_setup_ports.py # cat /etc/trex_cfg.yaml cat /root/trex/v2.81/cfg/simple_cfg.yaml cat /etc/trex_cfg.yaml echo 'config success ! dont config again! if not configed please reboot your mechine and check your network sum is 2 and the last 2 network are connected.' echo -e '\n' echo ${e[0]}' '${e[1]}
run_trex.sh
1
cd /root/trex/v2.81; ./t-rex-64 -f cap2/imix_longtao_1w.yaml -m 5 -d 5