Router
Aus Vosp.info
simpler router
wlan0 ist die schnittstelle die ins internet geht ip: 1.2.3.4 eth0 geht ins intranet
ifconfig eth0 down ifconfig wlan0 down dhclient wlan0 #route add -net default gw 1.2.3.4 dev wlan0 ifconfig eth0 192.168.1.1 up iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE echo 1 > /proc/sys/net/ipv4/ip_forward
static netzwerk router
router.sh
ifconfig eth0 192.168.1.50
ifconfig wwan0 192.168.0.50
route add -net default gw 192.168.0.1
iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
automatisches starten
startet automatisch wenn kabel eingesteckt wird (ruft einfach nur router.sh auf, sollte noch optimiert werden)
apt-get install netplug
/etc/netplug/netplugd.conf
eth0 wwan0
/etc/netplug/netplug
PATH=/usr/bin:/bin:/usr/sbin:/sbin
export PATH
dev="$1"
action="$2"
case "$action" in
in)
echo "netplug $dev $action" >> /var/log/netplug.log
/home/pi/router.sh >> /var/log/netplug.log
if [ -x /sbin/ifup ]; then
exec /sbin/ifup "$dev"
else
echo "Please teach me how to plug in an interface!" 1>&2
exit 1
fi
;;
out)
echo "netplug $dev $action" >> /var/log/netplug.log
if [ -x /sbin/ifdown ]; then
# At least on Fedora Core 1, the call to ip addr flush infloops
# /sbin/ifdown $dev && exec /sbin/ip addr flush $dev
exec /sbin/ifdown "$dev"
else
echo "Please teach me how to unplug an interface!" 1>&2
exit 1
fi
;;
probe)
echo "netplug $dev $action" >> /var/log/netplug.log
exec /sbin/ip link set "$dev" up >/dev/null 2>&1
;;
*)
echo "netplug $dev $action" >> /var/log/netplug.log
echo "I have been called with a funny action of '%s'!" 1>&2
exit 1
;;
esac