1

I got two internet connections... second one doesn't work without routing changes... other thing is that one user has routing through one connection, and other through other... so I need to apply iptables rules for that every time ethernet connects... when I apply it only on start, it gets deleted when for example router is being reboot.

How do I properly run a script after interface gets connected on Raspbian Jessie? up or post-up in interfaces file doesn't seem to work (doesn't run at all) same with up.d and post-up.d scripts from /etc/network

I also tried iptables-persistant instead of manually running my script, but it doesn't seem to work... I have no idea why... ok, I got some idea... but it may be totally wrong (see comments) ... anyway, when I save rules, restart interface, reset rules to saved, it doesn't work. I need to run my script using ip command to add all records and make it work again.

My script looks like this (removed user part):

ip route add 192.168.1.0/24 dev eth0 src 192.168.1.200 table NETWORK1
ip route add 192.168.2.0/24 dev eth1 src 192.168.2.200 table NETWORK2
ip route add default via 192.168.1.1 table NETWORK1
ip route add default via 192.168.2.1 table NETWORK2
ip rule add from 192.168.1.1 table NETWORK1
ip rule add from 192.168.2.1 table NETWORK2
ip rule add to 192.168.1.1 table NETWORK1
ip rule add to 192.168.2.1 table NETWORK2
ip rule add from all lookup main suppress_prefixlength 0
ip rule add from 192.168.1.0/24 lookup NETWORK1
ip rule add from 192.168.2.0/24 lookup NETWORK2

Edit:

I also tried to put a test script into /etc/dhcp/dhclient-enter-hooks.d, but those scripts seem to not to be used at all anymore (they never run).

  • as I already wrote, this tool doesn't work... I would guess it can't encode in its format ip rule add from all lookup main suppress_prefixlength 0 because I can see nothing about it in config file it generated... – Flash Thunder Jan 30 '17 at 12:27
  • Have you tried putting the script in /etc/network/if-up.d? Sorry, it looks like you have, but I'm not sure I'm reading your post right. – anonymous2 Jan 30 '17 at 12:44
  • Yes... it doesn't run... I mean I checked it with some echo to a file... it did not run. Had 777 persmissions... but even when I put it directly into upstart script, it did not run... seems that Jessie doesn't use those files anymore at all. – Flash Thunder Jan 30 '17 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.