Re: [gentoo-user] Automatic network configuration for USB connected device
On Saturday 06 September 2008, Dan Johansson wrote: 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 The above worked like a charm on my desktop but on my notebook it fails to autoaticly bring up the usb0 interface. If I do '/etc/init.d/net.usb0 start' on the notebook everything works as expected (this I don't have to do on the desktop). Any suggestions where to look? -- Dan Johansson, http://www.dmj.nu *** This message is printed on 100% recycled electrons! *** smime.p7s Description: S/MIME cryptographic signature
[gentoo-user] Automatic network configuration for USB connected device
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, -- Dan Johansson, http://www.dmj.nu *** This message is printed on 100% recycled electrons! *** smime.p7s Description: S/MIME cryptographic signature
Re: [gentoo-user] Automatic network configuration for USB connected device
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
Re: [gentoo-user] Automatic network configuration for USB connected device
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 :-)
Re: [gentoo-user] Automatic network configuration for USB connected device
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
Re: [gentoo-user] Automatic network configuration for USB connected device
Le Saturday 06 September 2008 15:52:57 Dan Johansson, vous avez écrit : 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 You can also use /etc/init.d/iptables script for saving iptables rules and restoring it at startup, and /etc/sysctl.conf for net.ipv4.ip_forward ;) Regards. Xavier Parizet signature.asc Description: This is a digitally signed message part.
Re: [gentoo-user] Automatic network configuration for USB connected device
On Sat, 6 Sep 2008 18:15:04 +0200, Xav' wrote: You can also use /etc/init.d/iptables script for saving iptables rules and restoring it at startup, and /etc/sysctl.conf for net.ipv4.ip_forward ;) Yes, but by putting them in the preup/down functions, the rules are only active when the devices is attached. -- Neil Bothwick In a classified ad: Tired of cleaning yourself? Let me do it. signature.asc Description: PGP signature