Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. sudo cp /etc/network/interfaces.d/eth0.cfg /etc/network/interfaces.d/eth1.cfg
  2. sudo sed -i "s/eth0/eth1/g" /etc/network/interfaces.d/eth1.cfg
  3. sudo ifdown eth1
  4. sudo ifup eth1
  5. sudo ifconfig eth1 | tee /tmp/ifconfig-eth1-output.txt
  6. sudo ifdown eth1
  7. sudo rm -f /etc/network/interfaces.d/eth1.cfg
  8. ETH0_IP=$(cat /tmp/ifconfig-eth1-output.txt | grep "inet addr:" | cut -f 2 -d':' | cut -f 1 -d' ')
  9. ETH0_NETMASK=$(cat /tmp/ifconfig-eth1-output.txt| grep "inet addr:" | cut -f 4 -d':')
  10. ETH0_GATEWAY=$(echo ${ETH0_IP} | sed "s/[0-9]*$/1/g")
  11. echo "auto eth1" > /tmp/eth1.cfg
  12. echo "iface eth1 inet static" >> /tmp/eth1.cfg
  13. echo "address ${ETH0_IP}" >> /tmp/eth1.cfg
  14. echo "netmask ${ETH0_NETMASK}" >> /tmp/eth1.cfg
  15. echo "up ip route add default via ${ETH0_GATEWAY} dev eth1 table 1 metric 10001" >> /tmp/eth1.cfg
  16. echo "up ip rule add from ${ETH0_IP}/32 table 1 priority 10001" >> /tmp/eth1.cfg
  17. echo "up ip route flush cache" >> /tmp/eth1.cfg
  18. sudo cp -f /tmp/eth1.cfg /etc/network/interfaces.d/
  19. sudo ifup eth1
  20.  
  21. curl --silent http://ipinfo.io
  22. curl --interface eth0 --silent http://ipinfo.io
  23. curl --interface eth1 --silent http://ipinfo.io
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement