From: zhengquan on
Hello,
My interfaces file looks like this

auto
lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.2.4
netmask 255.255.255.0
gateway 192.168.2.1

auto wlan0
iface wlan0 inet dhcp

1 I connect the net cable and boot the computer,
I have network connection, I can ping 192.168.2.1 and I can connect to
the internet.

2 I disconnect the net cable and sudo /etc/init.d/networking restart
the system tells me that it receives a dhcp offer and got ip
192.168.2.5 for wlan0(the wireless card). After this, I try to ping
192.168.2.1(the router), I got unreachable
message. and it shows that my ip is still 192.168.2.4(static ip of
eth0).

3 I sudo ifdown eth0
and everything is ok, I can ping 192.168.2.1 and I can connect to the
internect.


What confuses me is that why do I have to ifdown eth0 to change the
computer ip to the wireless ip?

Thanks.
Zhengquan


From: Bill Marcum on
On 2008-06-30, zhengquan <zhang.zhengquan(a)gmail.com> wrote:
>
>
> Hello,
> My interfaces file looks like this
>
> auto
> lo
> iface lo inet loopback
>
> auto eth0
> iface eth0 inet static
> address 192.168.2.4
> netmask 255.255.255.0
> gateway 192.168.2.1
>
> auto wlan0
> iface wlan0 inet dhcp
>
> 1 I connect the net cable and boot the computer,
> I have network connection, I can ping 192.168.2.1 and I can connect to
> the internet.
>
> 2 I disconnect the net cable and sudo /etc/init.d/networking restart
> the system tells me that it receives a dhcp offer and got ip
> 192.168.2.5 for wlan0(the wireless card). After this, I try to ping
> 192.168.2.1(the router), I got unreachable
> message. and it shows that my ip is still 192.168.2.4(static ip of
> eth0).
>
> 3 I sudo ifdown eth0
> and everything is ok, I can ping 192.168.2.1 and I can connect to the
> internect.
>
>
> What confuses me is that why do I have to ifdown eth0 to change the
> computer ip to the wireless ip?
>
I think the problem is that you are trying to use two addresses in the
same subnet.
From: Robert Heller on
At Sun, 29 Jun 2008 21:53:54 -0700 (PDT) zhengquan <zhang.zhengquan(a)gmail.com> wrote:

>
> Hello,
> My interfaces file looks like this
>
> auto
> lo
> iface lo inet loopback
>
> auto eth0
> iface eth0 inet static
> address 192.168.2.4
> netmask 255.255.255.0
> gateway 192.168.2.1
>
> auto wlan0
> iface wlan0 inet dhcp
>
> 1 I connect the net cable and boot the computer,
> I have network connection, I can ping 192.168.2.1 and I can connect to
> the internet.
>
> 2 I disconnect the net cable and sudo /etc/init.d/networking restart
> the system tells me that it receives a dhcp offer and got ip
> 192.168.2.5 for wlan0(the wireless card). After this, I try to ping
> 192.168.2.1(the router), I got unreachable
> message. and it shows that my ip is still 192.168.2.4(static ip of
> eth0).
>
> 3 I sudo ifdown eth0
> and everything is ok, I can ping 192.168.2.1 and I can connect to the
> internect.
>
>
> What confuses me is that why do I have to ifdown eth0 to change the
> computer ip to the wireless ip?

You don't *have* to take eth0 down, what you do have to do is change
your default route. When you take eth0 down, you remove the route that
uses it, leaving the route via wlan0.

Also *conputers* don't have IP addresses -- network interfaces have IP
addresses.

>
> Thanks.
> Zhengquan
>
>
>

--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk

From: zhengquan on
On Jun 30, 6:16 am, Robert Heller <hel...(a)deepsoft.com> wrote:
> At Sun, 29 Jun 2008 21:53:54 -0700 (PDT) zhengquan <zhang.zhengq...(a)gmail.com> wrote:
>
>
>
>
>
> > Hello,
> > My interfaces file looks like this
>
> > auto
> > lo
> > iface lo inet loopback
>
> > auto eth0
> > iface eth0 inet static
> > address 192.168.2.4
> > netmask 255.255.255.0
> > gateway 192.168.2.1
>
> > auto wlan0
> > iface wlan0 inet dhcp
>
> > 1 I connect the net cable and boot the computer,
> > I have network connection, I can ping 192.168.2.1 and I can connect to
> > the internet.
>
> > 2 I disconnect the net cable and sudo /etc/init.d/networking restart
> > the system tells me that it receives a dhcp offer and got ip
> > 192.168.2.5 for wlan0(the wireless card). After this, I try to ping
> > 192.168.2.1(the router), I got unreachable
> > message. and it shows that my ip is still 192.168.2.4(static ip of
> > eth0).
>
> > 3 I sudo ifdown eth0
> > and everything is ok, I can ping 192.168.2.1 and I can connect to the
> > internect.
>
> > What confuses me is that why do I have to ifdown eth0 to change the
> > computer ip to the wireless ip?
>
> You don't *have* to take eth0 down, what you do have to do is change
> your default route. When you take eth0 down, you remove the route that
> uses it, leaving the route via wlan0.
>
> Also *conputers* don't have IP addresses -- network interfaces have IP
> addresses.
>
>
>
> > Thanks.
> > Zhengquan
>
> --
> Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
> Deepwoods Software -- Linux Installation and Administrationhttp://www.deepsoft.com/ -- Web Hosting, with CGI and Database
> hel...(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk

Thanks, Bill and Robert, So is there any automatic way to switch from
wired to wireless?

Thanks.
Zhengquan