0

I made setup where laptop/ubuntu detects phone/android being attached to usb:

/etc/udev/rules.d/99-input.rules 

SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="6863", RUN+="/root/usb.sh", MODE="0666" # samsung

Then usb.sh is run. It executes commands for reverse tethering.

sudo ifconfig usb0 10.42.0.1 netmask 255.255.255.0 >>/root/log    2>>/root/log_err
echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -F                           >>/root/log     2>>/root/log_err
sudo iptables -t nat -A POSTROUTING -j MASQUERADE >>/root/log      2>>/root/log_err

Log shows that operation went fine and usb0 IP being correct:

inet addr:10.42.0.1

BUT when I check it manually by executing 'ifconfig', it says that IP for usb0 is:

inet addr:192.168.x.x

WHY is the setting not preserved?

(On raspberry Pi it works correctly. Why not on laptop/Ubuntu? )

user690954
  • 313
  • 2
  • 9

1 Answers1

0

I am not sure, but isn't that ATTRS{idVendor}=="####:####" format where ####:#### comes from $ lsusb

Michael D.
  • 1,795
  • 2
  • 18
  • 25
  • Yes that's what I thought too, first.
    – user690954 Nov 18 '13 at 08:16
  • ..But found out that it didn't work on ubuntu or raspbian. I'm not specialist in defining those udev commands. Latter part of the "####:####" apparently differs between phone models of Samsung. But original question remains. Why ifconfig settings disappear. Should I create daemon, signal it, and do config from there. Instead of direct shell invocation? – user690954 Nov 18 '13 at 08:32
  • I used this guide: http://forum.xda-developers.com/showthread.php?t=921169 and check that devices table here: http://developer.android.com/tools/device.html – Michael D. Nov 19 '13 at 23:49
  • as a quick fix if usb.sh is working. just copy and save the contents into /etc/rc.local and all should work fine on each boot – Michael D. Nov 20 '13 at 04:00