Unable to add an udev rule

asked 2017-09-02 20:49:08 +0300

ibins gravatar image

I want to use USB tethering when the phone is in WLAN mode. To do this I need NAT on WLAN and enable forwarding for the rndis0 interface. I added a new udev rule /etc/udev/rules/40-usb-tethering.rule

SUBSYSTEM=="net", ACTION=="remove", ATTR{name}=="rndis*", RUN+="/sbin/iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE"
SUBSYSTEM=="net", ACTION=="add", ATTR{name}=="rndis*", RUN+="/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE"
SUBSYSTEM=="net", ACTION=="add", ATTR{name}=="rndis*", RUN+="/bin/echo 1 > /proc/sys/net/ipv4/conf/all/forwarding"

Then I reload the rules with

udevadm control --reload

The result: Nothing happens. I tried a very simple rule like:

SUBSYSTEM=="net", RUN+="/bin/echo 1 > /tmp/asdf"

Again: nothing.

For the time being I set the forwarding and the netfilter rule permanently. The firmware is 2.1.1.26. Where is my mistake?

edit retag flag offensive close delete