Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sudo cp /etc/network/interfaces.d/eth0.cfg /etc/network/interfaces.d/eth1.cfg
- sudo sed -i "s/eth0/eth1/g" /etc/network/interfaces.d/eth1.cfg
- sudo ifdown eth1
- sudo ifup eth1
- sudo ifconfig eth1 | tee /tmp/ifconfig-eth1-output.txt
- sudo ifdown eth1
- sudo rm -f /etc/network/interfaces.d/eth1.cfg
- ETH0_IP=$(cat /tmp/ifconfig-eth1-output.txt | grep "inet addr:" | cut -f 2 -d':' | cut -f 1 -d' ')
- ETH0_NETMASK=$(cat /tmp/ifconfig-eth1-output.txt| grep "inet addr:" | cut -f 4 -d':')
- ETH0_GATEWAY=$(echo ${ETH0_IP} | sed "s/[0-9]*$/1/g")
- echo "auto eth1" > /tmp/eth1.cfg
- echo "iface eth1 inet static" >> /tmp/eth1.cfg
- echo "address ${ETH0_IP}" >> /tmp/eth1.cfg
- echo "netmask ${ETH0_NETMASK}" >> /tmp/eth1.cfg
- echo "up ip route add default via ${ETH0_GATEWAY} dev eth1 table 1 metric 10001" >> /tmp/eth1.cfg
- echo "up ip rule add from ${ETH0_IP}/32 table 1 priority 10001" >> /tmp/eth1.cfg
- echo "up ip route flush cache" >> /tmp/eth1.cfg
- sudo cp -f /tmp/eth1.cfg /etc/network/interfaces.d/
- sudo ifup eth1
- curl --silent http://ipinfo.io
- curl --interface eth0 --silent http://ipinfo.io
- curl --interface eth1 --silent http://ipinfo.io
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement