Router: Unterschied zwischen den Versionen
Aus Vosp.info
F (Diskussion | Beiträge) |
F (Diskussion | Beiträge) (→lte netzwerk router) |
||
Zeile 13: | Zeile 13: | ||
− | == | + | == static netzwerk router == |
+ | '''router.sh''' | ||
<source lang="bash"> | <source lang="bash"> | ||
ifconfig eth0 192.168.1.50 | ifconfig eth0 192.168.1.50 | ||
Zeile 21: | Zeile 22: | ||
echo 1 > /proc/sys/net/ipv4/ip_forward | echo 1 > /proc/sys/net/ipv4/ip_forward | ||
</source> | </source> | ||
+ | |||
+ | == automatisches starten == | ||
+ | startet automatisch wenn kabel eingesteckt wird (ruft einfach nur router.sh auf, sollte noch optimiert werden) | ||
+ | <source lang="bash"> | ||
+ | apt-get install netplug | ||
+ | </source> | ||
+ | |||
+ | '''/etc/netplug/netplugd.conf''' | ||
+ | eth0 | ||
+ | wwan0 | ||
+ | |||
+ | '''/etc/netplug/netplug''' | ||
+ | <source lang="bash"> | ||
+ | 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 | ||
+ | |||
+ | </source> | ||
+ | |||
+ | |||
+ | http://superuser.com/questions/332968/how-to-configure-eth0-to-retry-dhclient-when-unplugged-and-replugged |
Version vom 15. Oktober 2014, 20:26 Uhr
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