tip: auto network configuration on host

Mattes Sarcander info at risom.de
Tue Jul 13 08:42:45 EDT 2010


Thomas Karpiniec <tk at 1.21jiggawatts.net> wrote:

> Hi folks,
> 
> I have a tip here which is totally not ground-breaking but might save
> some time. If you're running debian or a similiar distro on your host
> PC you can put the following in /etc/network/interfaces
> 
> allow-hotplug usb0
> iface usb0 inet static
>       address 192.168.1.200
>       netmask 255.255.255.0
>       up echo "1" > /proc/sys/net/ipv4/ip_forward; \
>            /sbin/iptables -t nat -F; \
>            /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
> 
> and when you plug in the USB cable you'll automatically get an IP and
> set up masquerading for internet access. Make sure you choose the
> appropriate IP -- 192.168.254.100 is the usual one for openwrt/the
> official image.
> 
> Then on your nano you just need to make sure the gateway gets set. On
> Jlime I put "route add default gw 192.168.1.200" in
> /etc/muffinman-extras/final.sh. On openwrt, "option gateway
> 192.168.254.100" in /etc/config/network should do it.
> 
> I hope that helps someone. :)
> 
> Cheers,
> Tom


Hi Tom,
thanks for this howto :) While it worked fine on my notebook running
kernel 2.6.26, I had problems with the forwarding part on my desktop
machine running 2.6.32 (both debian). A friend more networking-savvy
than me came to the rescue: newer kernels seem to use the sys
filesystem only, so the proper entry for kernels 2.6.32 and higher
looks like this: 


allow-hotplug usb0
iface usb0 inet static
      address 192.168.1.200
      netmask 255.255.255.0
      up sysctl -w net.ipv4.conf.usb0.forwarding=1; \
	   sysctl -w net.ipv4.conf.eth0.forwarding=1; \
           /sbin/iptables -t nat -F; \
           /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

cheers,
Mattes


-- 

http://risom.de
http://cryptocd.org




More information about the discussion mailing list


interactive