Re: Connexion OpenMoko et perte du resolv.conf
Le 14581ième jour après Epoch,
Kevin Hinault écrivait:
> # freerunner SHR
> allow-hotplug eth1
> allow-auto eth1
> iface eth1 inet static
> address 192.168.0.200
> netmask 255.255.255.192
> up iptables -A POSTROUTING -t nat -s 192.168.0.0/24 -j MASQUERADE
> up echo 1 > /proc/sys/net/ipv4/ip_forward
> down iptables -D POSTROUTING -t nat -s 192.168.0.0/24 -j MASQUERADE
> down echo 0 > /proc/sys/net/ipv4/ip_forwa
Perso, mon interface était usb0, et il n'y avait pas de
allow-auto. D'autre part, j'utilisais le script joint avec dans
/etc/network/interfaces les choses suivantes:
# The Usb interface
allow-hotplug usb0
iface usb0 inet static
address 192.168.0.200
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
post-up /etc/network/freerunner start
pre-down /etc/network/freerunner stop
HTH.
#!/bin/sh
#
# configures the freerunner for internet
#
#
DEVICE=usb0
IPADDR=192.168.0.200
REMOTE_IPADDR=192.168.0.202
# get first ip for dns
DNSIP=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }' | head -n 1 )
case "$1" in
start)
iptables -A POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR
iptables -A PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
iptables -A PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then
echo "temoprarely allow ip_forward for openmoko" > /var/run/openmoko.ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward
fi
# We can try to set date/time now...
sudo -u neo ssh root@freerunner "date -s $(date +%m%d%H%M%Y.%S)"
# sudo -u neo ssh root@freerunner "echo nameserver 192.168.0.200 > /etc/resolv.conf"
;;
stop)
iptables -D POSTROUTING -t nat -j MASQUERADE -s $REMOTE_IPADDR
iptables -D PREROUTING -t nat -p tcp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
iptables -D PREROUTING -t nat -p udp -s $REMOTE_IPADDR -d $IPADDR --dport domain -j DNAT --to-destination $DNSIP
if [ -f /var/run/openmoko.ip_forward ]; then
rm /var/run/openmoko.ip_forward
echo 0 > /proc/sys/net/ipv4/ip_forward
fi
;;
esac
Reply to: