Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
automating the route command for a zaurus
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Seth
Apprentice
Apprentice


Joined: 25 May 2002
Posts: 156
Location: U.S.

PostPosted: Sun Apr 06, 2003 3:17 pm    Post subject: automating the route command for a zaurus Reply with quote

Hello,

I've got what I hope is a newbie, easily answered question about routes. I've got things set up so that whenever I put my zaurus in its cradle the usb0 interface goes up. Now I'd like to make sure that
Code:

route add -host 192.168.129.201 usb0

is automatically set at the same time. How do I do this?

I'm using hotplug and putting the command in usbdnet doesn't seem to do the trick.

Thanks,
Seth
Back to top
View user's profile Send private message
shadow255
Guru
Guru


Joined: 04 Apr 2003
Posts: 412

PostPosted: Sun Apr 06, 2003 5:08 pm    Post subject: Reply with quote

Using the Sharp SL-5500 here (ROM version 2.38). It was a major pain to figure this stuff out, but I think I've got a pretty simple way to make it work, with one caveat that maybe someone else can answer to. Here goes...

Edit the file /etc/conf.d/net. You need 2 entries in there:
Code:

iface_usb0="192.168.129.1 broadcast 192.168.129.255 netmask 255.255.255.0"
iface_usb0="dhcp"


Then you need to have a net.usb0 file in your /etc/init.d/ directory. I just copied net.eth0, e.g.
Code:

cp /etc/init.d/net.eth0 /etc/init.d/net.usb0


Then with Zaurus in the cradle (powered off at first) and usb cable connected, power on the Zaurus. After a few moments, check output from the following two commands:
Code:

/sbin/ifconfig -a
/sbin/route


You should see appropriate interface information and routing table entry. Now for the caveat: every time I do this, /etc/resolv.conf gets clobbered on my system, so I can't seem to use the Zaurus connection and my internet connection simultaneously. I would love to hear from someone that knows how to prevent this from happening!
_________________
Vogon poetry is of course the third worst in the Universe. -- Douglas Adams, The Hitchhiker's Guide to the Galaxy
Back to top
View user's profile Send private message
Seth
Apprentice
Apprentice


Joined: 25 May 2002
Posts: 156
Location: U.S.

PostPosted: Sun Apr 06, 2003 5:32 pm    Post subject: Reply with quote

Hi,

Yeah, adding the iface_usb0="dhcp" to /etc/conf.d/net did the trick, and screwed up my reslov.conf file too. I'd rather not do that. There must be a better way to add the route I want to the zaurus without typing it in everytime.

Tell me, when you pull your Z out of the cradle, do you need to manually bring down the usb0 interface? If I don't do that when I put my Z back in the cradle, it won't bring back up the usb0 interface.

Also, if Iwant the Z to connect to the internet I run a little script on it whenever it's docked:
Code:

route add -host 192.168.129.1 usbd0
route delete -net 192.168.129.0/24 usbd0
route add default gw 192.168.129.1


Took the code from http://www.ruault.com/Zaurus/ethernet-over-usb-howto.html



Seth
Back to top
View user's profile Send private message
shadow255
Guru
Guru


Joined: 04 Apr 2003
Posts: 412

PostPosted: Sun Apr 06, 2003 6:29 pm    Post subject: Reply with quote

Seth wrote:
Hi,

Yeah, adding the iface_usb0="dhcp" to /etc/conf.d/net did the trick, and screwed up my reslov.conf file too. I'd rather not do that. There must be a better way to add the route I want to the zaurus without typing it in everytime.

Tell me, when you pull your Z out of the cradle, do you need to manually bring down the usb0 interface? If I don't do that when I put my Z back in the cradle, it won't bring back up the usb0 interface.

Also, if Iwant the Z to connect to the internet I run a little script on it whenever it's docked:
Code:

route add -host 192.168.129.1 usbd0
route delete -net 192.168.129.0/24 usbd0
route add default gw 192.168.129.1


Took the code from http://www.ruault.com/Zaurus/ethernet-over-usb-howto.html



Seth

I have found that pulling the Z out of the cradle while powered on creates havoc with my setup. It's very picky. So my modus operandi is to power off the Z before inserting and before removing it from the cradle. That seems to make things work correctly. Right now I'm unable to get usb0 to lease the ip from the Z after having, just one time, pulled the Z out with power on. :evil:

It looks like the solution to this problem is to restart hotplug. So you could try:
Code:

/etc/init.d/hotplug restart

_________________
Vogon poetry is of course the third worst in the Universe. -- Douglas Adams, The Hitchhiker's Guide to the Galaxy
Back to top
View user's profile Send private message
Seth
Apprentice
Apprentice


Joined: 25 May 2002
Posts: 156
Location: U.S.

PostPosted: Mon Apr 07, 2003 12:20 am    Post subject: Reply with quote

shadow255 wrote:

I have found that pulling the Z out of the cradle while powered on creates havoc with my setup. It's very picky. So my modus operandi is to power off the Z before inserting and before removing it from the cradle. That seems to make things work correctly. Right now I'm unable to get usb0 to lease the ip from the Z after having, just one time, pulled the Z out with power on. :evil:

It looks like the solution to this problem is to restart hotplug. So you could try:
Code:

/etc/init.d/hotplug restart


Here's what I've done so far. I put the following line in net.usb0:
Code:

route add -host 192.168.129.201 usb0

right at the end of the section that brings up the non-dhcp usb0 interface.

This doesn't solve everything. When I pull the Z from its cradle, I still need to run /etc/init.d/net.usb0 stop, even though ifconfig and ifconfig -a don't find the usb0 interface. If I don't, the next time I put the Z back in the cradle usb0 will not come up at all.

Next thing I need to work on is automating the routing instructions on the Z so that it sees the pc as its internet gateway.

Seth
Back to top
View user's profile Send private message
ozric100
Tux's lil' helper
Tux's lil' helper


Joined: 23 Apr 2002
Posts: 136

PostPosted: Mon Apr 07, 2003 5:01 pm    Post subject: Reply with quote

I have had my Z for about 2 weeks. I have it all set up on my XP work laptop with ICS from the USB port. I just finished setting it up on my home Gentoo system. it works fine so far. I have not setup any sync software yet, but I dont know if I want to. BTW I am running OpenZaurus 3.2 on my Z. Here is a quick run down.

1. patch kernel with usbnet patch (no need for usbdnet) setup iptables. Build
2. cp /etc/init.d/net.eth0 /etc/init.d/net.usb0 ( no need to start this)
3. edit /etc/conf.d and add iface_usb0 information
3. emerge and start iptables ( add to default runlevel)
4. add nat POSTROUTING SNAT for eth0 (iptables-save)
5. check hotplug setup and make sure its ok (should start net.usb0 for you)
6. unsuspend Z and plug in to cradle
7. fix any network files on the Z
8. test - connect / disconnect
9. enjoy

That is a quick list of how I did it. If you need more let me know.
Back to top
View user's profile Send private message
Seth
Apprentice
Apprentice


Joined: 25 May 2002
Posts: 156
Location: U.S.

PostPosted: Mon Apr 07, 2003 7:02 pm    Post subject: Reply with quote

ozric100 wrote:
I have had my Z for about 2 weeks. I have it all set up on my XP work laptop with ICS from the USB port. I just finished setting it up on my home Gentoo system. it works fine so far. I have not setup any sync software yet, but I dont know if I want to. BTW I am running OpenZaurus 3.2 on my Z. Here is a quick run down.

1. patch kernel with usbnet patch (no need for usbdnet) setup iptables. Build
2. cp /etc/init.d/net.eth0 /etc/init.d/net.usb0 ( no need to start this)
3. edit /etc/conf.d and add iface_usb0 information
3. emerge and start iptables ( add to default runlevel)
4. add nat POSTROUTING SNAT for eth0 (iptables-save)
5. check hotplug setup and make sure its ok (should start net.usb0 for you)
6. unsuspend Z and plug in to cradle
7. fix any network files on the Z
8. test - connect / disconnect
9. enjoy


Hi ozric,

I've got it mostly working now, including number 9, enjoy. Hotplug on the Z is set to add the proper routes whenever I plug in. I first tried to put the routing commands in /etc/hotplug/usbdnet, but that had no effect. I don't think it's called when I plug the Z into the cradle. Instead, a script called /etc/hotplug/net.agent is run. I put the routing commands there and everything on the Z side is working great.

The only thing that's still annoying is having to run /etc/init.d/net.usb0 stop on the pc every time I pull the Z out of its cradle. If I don't then when I plug the Z back in hotplug can't bring usb0 up. Apparantly the line in the pc's hotplug's net.agent script
Code:

exec /etc/init.d/net.$INTERFACE stop

has no effect, and I have to run it by hand.

What's three-times strange about this situation is that

1. net.agent can successully bring up the usb0 interface.
2. when I pull the Z out of the cradle and run net.usb0 stop by hand, I get the following message:
Code:

* Bringing usb0 down...
usb0: unknown interface: No such device                                   [ ok ]

3. and /var/log/everything/current tells me:
Code:

Apr  7 14:47:42 [/etc/hotplug/net.agent] invoke /etc/init.d/net.usb0 stop
Apr  7 14:47:42 [modprobe] modprobe: Can't locate module usb0


Why is modprobe looking for module usb0?

Thanks,

Seth
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum