On Saturday 06 September 2008, Daniel Pielmeier wrote: > Hong Hao schrieb am 06.09.2008 15:29: > > Dan Johansson wrote: > >> I have bought me a new toy - an Openmoko Freerunner. > >> Each time I connect it to my Gentoo-box I must configure the usb0 > >> device on the Gentoo-box as follows: > >> ifconfig usb0 192.168.0.200 netmask 255.255.255.248 After that I can > >> without problem ssh to the Freerunner. Now I want the above to be > >> automatically done when I connect the Freerunner. I have found the the > >> following description for Ubunto: > >> > >> Add the following lines to your /etc/network/interfaces : > >> allow-hotplug usb0 > >> auto usb0 > >> iface usb0 inet static > >> address 192.168.0.200 > >> netmask 255.255.255.0 > >> network 192.168.0.0 > >> up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 & > >> up echo 1 > /proc/sys/net/ipv4/ip_forward & > >> up iptables -P FORWARD ACCEPT & > >> down iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 > >> > >> What would be the corresponding file(s) on Gentoo? > >> Regards, > > > > /etc/conf.d/network > > I would try this: /etc/conf.d/net :-) Thanks, I should have done some googling before I ask.... I added the following to /etc/conf.d/net:
config_usb0=( "192.168.0.200 netmask 255.255.255.248" ) routes_usb0=( "192.168.0.202/32 via 192.168.0.200" ) preup() { if [ ${IFACE} = "usb0" ] then echo 1 > /proc/sys/net/ipv4/ip_forward iptables -I INPUT 1 -s 192.168.0.202 -j ACCEPT iptables -I OUTPUT 1 -s 192.168.0.200 -j ACCEPT iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 fi return 0 } postdown() { if [ ${IFACE} = "usb0" ] then echo 0 > /proc/sys/net/ipv4/ip_forward iptables -D INPUT -s 192.168.0.202 -j ACCEPT iptables -D OUTPUT -s 192.168.0.200 -j ACCEPT iptables -D POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 fi return 0 } and linked /etc/init.d/net.lo to /etc/init.d/net.usb0 -- Dan Johansson, <http://www.dmj.nu> *************************************************** This message is printed on 100% recycled electrons! ***************************************************
smime.p7s
Description: S/MIME cryptographic signature