Re: switching between ethernet and wifi
hmm, on Tue, Jul 24, 2012 at 03:47:53PM -0400, Dan Harnett said that It would be more convenient to just have trunk handle it, though. Any connections will not be disrupted and you don't have to mess around with any part of the network. You can have hotplugd(8) handle it for you. /etc/hostname.re0: up /etc/hostname.trunk0: trunkproto failover trunkport re0 dhcp NONE NONE NONE Then have hotplugd setup urtwn0 on attach. ifconfig urtwn0 nwid BLAH wpa wpakey blahblah up ifconfig trunk0 trunkport urtwn0 this seems to work great both when the nic is inserted right from boot time, or when inserted later. When you want to switch back to the wired interface, just plug the cable in, wait a few seconds for any autonegotiation, and you can safely unplug the urtwn0. now the only last question remaining: should any commands be executed before removing the usb wifi? sometimes i get this: /bsd: ehci_idone: ex=0xd1f4b000 is done! -f -- i know someone with the exact same name! really? who?
Re: switching between ethernet and wifi
On Wed, Jul 25, 2012 at 09:59:29AM +0200, frantisek holop wrote: now the only last question remaining: should any commands be executed before removing the usb wifi? sometimes i get this: /bsd: ehci_idone: ex=0xd1f4b000 is done! I don't believe you have to execute anything before removing the usb wifi. Did you receive that message previously when not using trunk?
Re: switching between ethernet and wifi
hmm, on Tue, Jul 24, 2012 at 12:25:04PM +1000, David Diggles said that I have the same interfaces on my netbook. thanks all for the trunk tip. should have been my first stop, shame on me. -f -- i am so open-minded my brain falls out.
Re: switching between ethernet and wifi
hmm, on Mon, Jul 23, 2012 at 08:10:49PM -0400, Dan Harnett said that On Tue, Jul 24, 2012 at 01:13:29AM +0200, frantisek holop wrote: what i do: insert the usb wifi (/etc/hostname.urtwn0 contains the correct network data), i disconnect the ethernet cable, route -n flush, ifconfig re0 down, sh /etc/netstart. I would recommend 'ifconfig re0 down delete', and do that before flushing the routing table. I would also make sure the dhclient process for that interface was dead. could you explain the reason behind the order? the routing table would contain a default route on a non-existing nic, no? $ sudo route -n flush default 10.10.10.1 done default 10.10.10.1 done Why do you have two default routes? I also do not see the deletion of 10.10.10.0/24 or any route containing that subnet. i just paste what the system says :] i am afraid i cannot answer this question. question: why don't the re0 lines disappear from the inet6 lines after ifconfig re0 down? Most likely because you didn't delete the addresses from the re0 interface. ok, i thought ifconfig down is something like delete as well. $ sudo sh /etc/netstart DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPACK from 10.10.10.1 (00:22:bb:aa:aa:cc) bound to 10.10.10.136 -- renewal in 604780 seconds. $ route -n show Routing tables Internet: DestinationGatewayFlags Refs Use Mtu Prio Iface default10.10.10.1 GSP46 - 8 re0 ^^^ default10.10.10.1 GS 00 - 8 re0 ^^^ You shouldn't have two default routes with the network you're describing. Make sure you don't have a /etc/mygate file laying around. the file does not exist. i am not sure what was going on, hence my email to the list :] let's say if trunk did not exist, what would be the correct way to do this? -f -- how much can i get away with and still go to heaven?
Re: switching between ethernet and wifi
On Tue, Jul 24, 2012 at 06:15:02PM +0200, frantisek holop wrote: hmm, on Mon, Jul 23, 2012 at 08:10:49PM -0400, Dan Harnett said that On Tue, Jul 24, 2012 at 01:13:29AM +0200, frantisek holop wrote: what i do: insert the usb wifi (/etc/hostname.urtwn0 contains the correct network data), i disconnect the ethernet cable, route -n flush, ifconfig re0 down, sh /etc/netstart. I would recommend 'ifconfig re0 down delete', and do that before flushing the routing table. I would also make sure the dhclient process for that interface was dead. could you explain the reason behind the order? the routing table would contain a default route on a non-existing nic, no? The order is to make sure re0 is no longer associated with anything in your routing table. The interface would be down, which makes the default gateway unreachable anyway. Considering that you're tearing down the interface manually, and changing the default route, it hardly matters that it is temporarily unreachable. let's say if trunk did not exist, what would be the correct way to do this? The way you're approaching it is alright. There are just some oddities with your setup. It would be more convenient to just have trunk handle it, though. Any connections will not be disrupted and you don't have to mess around with any part of the network. You can have hotplugd(8) handle it for you. /etc/hostname.re0: up /etc/hostname.trunk0: trunkproto failover trunkport re0 dhcp NONE NONE NONE Then have hotplugd setup urtwn0 on attach. ifconfig urtwn0 nwid BLAH wpa wpakey blahblah up ifconfig trunk0 trunkport urtwn0 When you want to switch back to the wired interface, just plug the cable in, wait a few seconds for any autonegotiation, and you can safely unplug the urtwn0.
switching between ethernet and wifi
hi there, consider a notebook with two nic's: re0 (ethernet) and urtwn0 (usb wifi). let's say, at boot time there is ethernet connection and /etc/hostname.re0 contains dhcp. urtwn0 is not plugged in. later, i want to switch to wifi. what i do: insert the usb wifi (/etc/hostname.urtwn0 contains the correct network data), i disconnect the ethernet cable, route -n flush, ifconfig re0 down, sh /etc/netstart. what i expect: network is now through wifi. what i get: urtwn0 gets an IP, but route shows that the default route is still trying to go through re0, even if i comment out dhcp from /etc/hostname.re0 how can i persuade the system to forget about re0? how is this situation different for /etc/netstart than booting up with the usb wifi inserted and an empty /etc/hostname.re0? what is the correct procedure in a case like this? $ sudo route -n flush default 10.10.10.1 done default 10.10.10.1 done 10.10.10.135 127.0.0.1done 127/0127.0.0.1done 224/0127.0.0.1done ::/128 ::1 done ::/128 ::1 done ::127.0.0.0/128 ::1 done ::224.0.0.0/128 ::1 done ::255.0.0.0/128 ::1 done :::0.0.0.0/128 ::1 done 2002::/128 ::1 done 2002:7f00::/128 ::1 done 2002:e000::/128 ::1 done 2002:ff00::/128 ::1 done fe80::/128 ::1 done fec0::/128 ::1 done ff01::/128 ::1 done ff02::/128 ::1 done $ route -n show Routing tables Internet: DestinationGatewayFlags Refs Use Mtu Prio Iface 127.0.0.1 127.0.0.1 UH 00 33196 4 lo0 Internet6: DestinationGatewayFlags Refs Use Mtu Prio Iface ::1::1UH 0 0 33196 4 lo0 fe80::%re0/64 link#1 C 0 0 - 4 re0 fe80::%lo0/64 fe80::1%lo0U 0 0 - 4 lo0 fe80::%urtwn0/64 link#5 UC 0 0 - 4 urtwn0 ff01::%re0/32 link#1 C 0 0 - 4 re0 ff01::%lo0/32 fe80::1%lo0UC 0 0 - 4 lo0 ff01::%urtwn0/32 link#5 UC 0 0 - 4 urtwn0 ff02::%re0/32 link#1 C 0 0 - 4 re0 ff02::%lo0/32 fe80::1%lo0UC 0 0 - 4 lo0 ff02::%urtwn0/32 link#5 UC 0 0 - 4 urtwn0 question: why don't the re0 lines disappear from the inet6 lines after ifconfig re0 down? $ sudo sh /etc/netstart DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPACK from 10.10.10.1 (00:22:bb:aa:aa:cc) bound to 10.10.10.136 -- renewal in 604780 seconds. $ route -n show Routing tables Internet: DestinationGatewayFlags Refs Use Mtu Prio Iface default10.10.10.1 GSP46 - 8 re0 ^^^ default10.10.10.1 GS 00 - 8 re0 ^^^ 10.10.10.136 127.0.0.1 UGHS 00 33196 8 lo0 127/8 127.0.0.1 UGRS 00 33196 8 lo0 127.0.0.1 127.0.0.1 UH 10 33196 4 lo0 224/4 127.0.0.1 URS00 33196 8 lo0 Internet6: DestinationGatewayFlags Refs Use Mtu Prio Iface ::/104 ::1UGRS 0 0 - 8 lo0 ::/96 ::1UGRS 0 0 - 8 lo0 ::1::1UH14 0 33196 4 lo0 ::127.0.0.0/104::1UGRS 0 0 - 8 lo0 ::224.0.0.0/100::1UGRS 0 0 - 8 lo0 ::255.0.0.0/104::1UGRS 0 0 - 8 lo0 :::0.0.0.0/96
Re: switching between ethernet and wifi
On Mon, Jul 23, 2012 at 5:13 PM, frantisek holop min...@obiit.org wrote: consider a notebook with two nic's: re0 (ethernet) and urtwn0 (usb wifi). let's say, at boot time there is ethernet connection and /etc/hostname.re0 contains dhcp. urtwn0 is not plugged in. later, i want to switch to wifi. what i do: insert the usb wifi (/etc/hostname.urtwn0 contains the correct network data), i disconnect the ethernet cable, route -n flush, ifconfig re0 down, sh /etc/netstart. what i expect: network is now through wifi. what i get: urtwn0 gets an IP, but route shows that the default route is still trying to go through re0, even if i comment out dhcp from /etc/hostname.re0 how can i persuade the system to forget about re0? ... what is the correct procedure in a case like this? Have you considered/is using trunk(4) an option for this? If so, there's an example in the man page.
Re: switching between ethernet and wifi
On Tue, Jul 24, 2012 at 01:13:29AM +0200, frantisek holop wrote: what i do: insert the usb wifi (/etc/hostname.urtwn0 contains the correct network data), i disconnect the ethernet cable, route -n flush, ifconfig re0 down, sh /etc/netstart. I would recommend 'ifconfig re0 down delete', and do that before flushing the routing table. I would also make sure the dhclient process for that interface was dead. $ sudo route -n flush default 10.10.10.1 done default 10.10.10.1 done Why do you have two default routes? I also do not see the deletion of 10.10.10.0/24 or any route containing that subnet. question: why don't the re0 lines disappear from the inet6 lines after ifconfig re0 down? Most likely because you didn't delete the addresses from the re0 interface. $ sudo sh /etc/netstart DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPACK from 10.10.10.1 (00:22:bb:aa:aa:cc) bound to 10.10.10.136 -- renewal in 604780 seconds. $ route -n show Routing tables Internet: DestinationGatewayFlags Refs Use Mtu Prio Iface default10.10.10.1 GSP46 - 8 re0 ^^^ default10.10.10.1 GS 00 - 8 re0 ^^^ You shouldn't have two default routes with the network you're describing. Make sure you don't have a /etc/mygate file laying around.
Re: switching between ethernet and wifi
* frantisek holop min...@obiit.org [120724 03:14]: hi there, consider a notebook with two nic's: re0 (ethernet) and urtwn0 (usb wifi). let's say, at boot time there is ethernet connection and /etc/hostname.re0 contains dhcp. urtwn0 is not plugged in. later, i want to switch to wifi. what i do: insert the usb wifi (/etc/hostname.urtwn0 contains the correct network data), i disconnect the ethernet cable, route -n flush, ifconfig re0 down, sh /etc/netstart. what i expect: network is now through wifi. what i get: urtwn0 gets an IP, but route shows that the default route is still trying to go through re0, even if i comment out dhcp from /etc/hostname.re0 how can i persuade the system to forget about re0? man ifconfig priority n Set the interface routing priority to n. This will influence the default routing priority of new static routes added to the kernel. n is in the range of 0 to 16 with smaller numbers being better.
Re: switching between ethernet and wifi
On Tue, Jul 24, 2012 at 01:13, frantisek holop wrote: consider a notebook with two nic's: re0 (ethernet) and urtwn0 (usb wifi). let's say, at boot time there is ethernet connection and /etc/hostname.re0 contains dhcp. urtwn0 is not plugged in. later, i want to switch to wifi. The best answer is probably to use trunk. Along the lines of what other people have said, your problem is two interfaces on the same subnet in the same machine. Another way to fix that is to carve the wifi network off into 10.10.20.x and use appropriate subnet masks. Then your new default route will be 10.10.20.1 and it won't try using re0. Something to consider if you ever want different policies for wired and wireless, but probably too much work just to make one laptop work.
Re: switching between ethernet and wifi
I have the same interfaces on my netbook. I use trunk in the following way. root@varis:etc:0# cat hostname.re0 up root@varis:etc:0# cat hostname.urtwn0 nwid De Gaulles \ wpakey hackme up root@varis:etc:0# cat hostname.trunk0 trunkproto failover trunkport re0 trunkport urtwn0 dhcp !/sbin/pfctl -f /etc/pf.conf The wifi and wired are different subnets, so I am reloading the pf rules with: sh /etc/netstart trunk0 It could be possible to write pf rules that do not need reloading. On Tue, Jul 24, 2012 at 01:13:29AM +0200, frantisek holop wrote: hi there, consider a notebook with two nic's: re0 (ethernet) and urtwn0 (usb wifi). let's say, at boot time there is ethernet connection and /etc/hostname.re0 contains dhcp. urtwn0 is not plugged in. later, i want to switch to wifi. what i do: insert the usb wifi (/etc/hostname.urtwn0 contains the correct network data), i disconnect the ethernet cable, route -n flush, ifconfig re0 down, sh /etc/netstart. what i expect: network is now through wifi. what i get: urtwn0 gets an IP, but route shows that the default route is still trying to go through re0, even if i comment out dhcp from /etc/hostname.re0 how can i persuade the system to forget about re0? how is this situation different for /etc/netstart than booting up with the usb wifi inserted and an empty /etc/hostname.re0? what is the correct procedure in a case like this? $ sudo route -n flush default 10.10.10.1 done default 10.10.10.1 done 10.10.10.135 127.0.0.1done 127/0127.0.0.1done 224/0127.0.0.1done ::/128 ::1 done ::/128 ::1 done ::127.0.0.0/128 ::1 done ::224.0.0.0/128 ::1 done ::255.0.0.0/128 ::1 done :::0.0.0.0/128 ::1 done 2002::/128 ::1 done 2002:7f00::/128 ::1 done 2002:e000::/128 ::1 done 2002:ff00::/128 ::1 done fe80::/128 ::1 done fec0::/128 ::1 done ff01::/128 ::1 done ff02::/128 ::1 done $ route -n show Routing tables Internet: DestinationGatewayFlags Refs Use Mtu Prio Iface 127.0.0.1 127.0.0.1 UH 00 33196 4 lo0 Internet6: DestinationGatewayFlags Refs Use Mtu Prio Iface ::1::1UH 00 33196 4 lo0 fe80::%re0/64 link#1 C 00 - 4 re0 fe80::%lo0/64 fe80::1%lo0U 00 - 4 lo0 fe80::%urtwn0/64 link#5 UC 00 - 4 urtwn0 ff01::%re0/32 link#1 C 00 - 4 re0 ff01::%lo0/32 fe80::1%lo0UC 00 - 4 lo0 ff01::%urtwn0/32 link#5 UC 00 - 4 urtwn0 ff02::%re0/32 link#1 C 00 - 4 re0 ff02::%lo0/32 fe80::1%lo0UC 00 - 4 lo0 ff02::%urtwn0/32 link#5 UC 00 - 4 urtwn0 question: why don't the re0 lines disappear from the inet6 lines after ifconfig re0 down? $ sudo sh /etc/netstart DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPREQUEST on urtwn0 to 255.255.255.255 port 67 DHCPACK from 10.10.10.1 (00:22:bb:aa:aa:cc) bound to 10.10.10.136 -- renewal in 604780 seconds. $ route -n show Routing tables Internet: DestinationGatewayFlags Refs Use Mtu Prio Iface default10.10.10.1 GSP46 - 8 re0 ^^^ default10.10.10.1 GS 00 - 8 re0 ^^^ 10.10.10.136 127.0.0.1 UGHS 00 33196 8 lo0 127/8 127.0.0.1 UGRS 00 33196 8 lo0 127.0.0.1 127.0.0.1 UH 10 33196 4 lo0 224/4 127.0.0.1 URS00 33196 8 lo0 Internet6: DestinationGatewayFlags Refs Use Mtu Prio Iface ::/104