Active Topics

 


Reply
Thread Tools
Posts: 25 | Thanked: 12 times | Joined on Mar 2008 @ Warsaw, Poland
#1
I've made myself a script that enables internet connection tethering over usbnet (1) (yes, i don't like ppp) and made my laptop connect to the internet automatically when i connect the N900 over usb cable (2).
The problem is, that the iptables rule gets multiplied when i connect and disconnect from my N900. I tried finding a signal that'd get emited when the usb cable is unplugged, to remove the iptables rule there, but there appears to be none (tried watching "initctl events").
Any ideas? i wouldn't want to create dozens of useless iptables rules.

(1) File /etc/event.d/usbtether, the "G_NOKIA_READY" signal only gets actually emitted when one selects "pc suite mode", but that's not a problem.
Code:
start on G_NOKIA_READY

console output

script 
        ifconfig usb0 up 192.168.99.1/24
        modprobe ipt_MASQUERADE
        iptables -A POSTROUTING -t nat -o gprs0 -j MASQUERADE
        echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
end script
(2) File /etc/conf.d/net, topic relevant parts start with "if [[ "${IFACE}" = "usb0" ]]; then"
Code:
config_lan0=( "dhcp" )
config_usb0=( "noop" "noop" )
dhcpcd_lan0="-q -t 10"

modules_wlan0=( "wpa_supplicant" "iproute2" "!plug" )
dhcpcd_wlan0="-q -t 15"

config_ferret="dhcp"
config_nibylandia="dhcp"
config_avantis_wifi="dhcp"
#config_arach="10.0.4.10/24"
config_arach="dhcp"

preup() {
    if [[ "${IFACE}" = "lan0" ]]; then
        if [[ $(/sbin/iwconfig wlan0|awk '/ESSID:/ { gsub(/.*ESSID:/, ""); print $1 }') = "\"arach\"" ]]; then
	    eselect rc stop net.wlan0
	fi
    fi
    if [[ "${IFACE}" = "usb0" ]]; then
        /etc/init.d/net.lan0 status 2> /dev/null > /dev/null || \
            /etc/init.d/net.wlan0 status 2> /dev/null > /dev/null
        if [[ ! $? -eq 0 ]]; then
            ifconfig usb0 up 192.168.99.100/24
            route add default gw 192.168.99.1
            echo nameserver 8.8.8.8 > /etc/resolv.conf
            /usr/bin/sleep 5
            su - arachnist -c "ssh 192.168.99.1 dbus-send --type=method_call \
                --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect \
                \"'string:Plus GSM INTERNET GPRS'\" uint32:0"
        fi
    fi
}


predown() {
    if [[ "${IFACE}" = "lan0" ]]; then
        /etc/init.d/net.wlan0 status > /dev/null 2>&1 || \
	    eselect rc start net.wlan0
    fi
}

Last edited by arachnist; 2010-03-13 at 15:01.
 

The Following 2 Users Say Thank You to arachnist For This Useful Post:
Posts: 155 | Thanked: 61 times | Joined on Nov 2009
#2
You can simply do

Code:
iptables -D <rule> 2>/dev/null || true
iptables -A <rule>
Will make sure not to double the rules up.
 

The Following 2 Users Say Thank You to phedders For This Useful Post:
Posts: 25 | Thanked: 12 times | Joined on Mar 2008 @ Warsaw, Poland
#3
Originally Posted by phedders View Post
You can simply do
Will make sure not to double the rules up.
Thanks, didn't think about that
 
Posts: 1 | Thanked: 0 times | Joined on May 2010 @ Żarki
#4
Originally Posted by phedders View Post
You can simply do

Code:
iptables -D <rule> 2>/dev/null || true
iptables -A <rule>
Will make sure not to double the rules up.
Hello,

I also do not like to use PPP and yesterday I attempted to set up my N900 as a tether over USB cable.

I use Slackware 13 on my ACER. I set up the laptop's USB0 adapter to 192.168.2.14 address and it worked at once. I was able to ping both ways, ssh worked too.

Then I connected the phone to 3G network. I corrected the default route and the net worked from N900 console. I was also able to ping my laptop too. So, both interfaces gprs0 and usb0 are working at the same time.

However, the net did not work on the laptop. I set the gateway to N900 IP address, put correct DNS addresses and still no net. Apparently, my N900 is not routing the packets from my laptop. I checked if IP forwarding on N900 is on and it was set 1.

You make references to iptables on N900, but I was unable to find iptables on my N900. Where to get the iptables for N900?

Arachnist, can you write me some intructions how to make N900 route packets incoming from USB0 to GPRS0? Where is the script that sets the firewall?

I'd really appreciate any help, since I am new to N900, though I am a Linux veteran ;-)

Oliwer
 
Reply


 
Forum Jump


All times are GMT. The time now is 07:13.