LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   What is the difference between 'networking restart' and 'ifup ethx' (https://www.linuxquestions.org/questions/linux-networking-3/what-is-the-difference-between-networking-restart-and-ifup-ethx-727466/)

HolyJoe 05-21-2009 01:13 AM

What is the difference between 'networking restart' and 'ifup ethx'
 
Hi,

I had a D-Link 802.11g router and it connected to Internet. Other computers at my home can connected to Internet through an Ubuntu 8.04 Server squid3 box via the D-Link router. But, there is a headache :
If the D-Link router restart, for go Internet again I must execute '/etc/init.d/networking restart'. At same time, the squid3 daemon workings fine.

I don't know what's the exact problem at there and need any advice and help.


Thanks.

suga_rray 05-21-2009 02:27 AM

Re: What is the difference between 'networking restart' and 'ifup ethx'
 
When your wireless router gets restarted/power cycled, the connections on your computer also gets broken. By doing a "/etc/init.d/networking restart" you are basically re-establishing the wireless connections.

Your squid daemon will be accepting connections, but as long as the squid cannot access internet it wont be able to serve the clients.

I guess this is what is happening with you.

linusali 05-21-2009 03:09 AM

Yes, You are right suga_rray. But why is it now establishing the connection automatically? I don't know much about the Ubuntu 8.04, but if HolyJoe requires a automatic reconnect, he/she may run a cron job every minute checking the availablity of the router.

ping -c 3 192.168.0.1 -w 3 ; if [ $? != 0 ] ; then /etc/init.d/networking restart ; fi

192.168.0.1 is the router IP address.

Hope this helps

HolyJoe 05-21-2009 07:30 AM

Quote:

Originally Posted by linusali (Post 3547848)
Yes, You are right suga_rray. But why is it now establishing the connection automatically? I don't know much about the Ubuntu 8.04, but if HolyJoe requires a automatic reconnect, he/she may run a cron job every minute checking the availablity of the router.

ping -c 3 192.168.0.1 -w 3 ; if [ $? != 0 ] ; then /etc/init.d/networking restart ; fi

192.168.0.1 is the router IP address.

Hope this helps

Thanks.

Yes, I want to establish the Internet connection automatically. I can receive the replies from ping to the router, but I cannot connect to Internet and I must execute '/etc/init.d/networking restart' (does not need to restart the squid3)
What's wrong? :mad:

HolyJoe 05-21-2009 07:33 AM

Quote:

Originally Posted by suga_rray (Post 3547823)
When your wireless router gets restarted/power cycled, the connections on your computer also gets broken. By doing a "/etc/init.d/networking restart" you are basically re-establishing the wireless connections.

Your squid daemon will be accepting connections, but as long as the squid cannot access internet it wont be able to serve the clients.

I guess this is what is happening with you.

Thanks.

Yes, But how can I establish the Internet connection automatically.

syg00 05-21-2009 07:41 AM

You shouldn't need to - I reset my (home) router regularly. Ubuntu desktop, not Server mind you.
The only time I've needed to issue a network restart is when the driver hasn't loaded successfully. Always at startup, not later on though.

HolyJoe 05-21-2009 09:09 PM

Quote:

Originally Posted by syg00 (Post 3548053)
You shouldn't need to - I reset my (home) router regularly. Ubuntu desktop, not Server mind you.
The only time I've needed to issue a network restart is when the driver hasn't loaded successfully. Always at startup, not later on though.

Hi, syg00,
Thank you for your reply.

I don't like execute '/etc/init.d/networking restart' all the time after the router restart/power cycled too :scratch: May be I should let my problem more clear, make some examples to emulate the situation:
$sudo ifdown eth0 #eth0 is the public NIC of my Ubuntu 8.04 Server
$sudo ifup eth0
after above commands has been executed, I can receive ping replies from the router except other outside URL such as www.ubuntu.com.

Need your help to find the key of the headache, thank you.

linusali 05-24-2009 06:31 AM

Hi there,

I think you have to check if your the default route is up after you do sudo ifup eth0. check it using route command. you should see some thing like

default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

towards the end of the output. If it is not there issue the following command to set the default route.

route add default gw 192.168.0.1

of-course 192.168.0.1 is you router IP address.

cheers

HolyJoe 05-25-2009 02:46 AM

Quote:

Originally Posted by linusali (Post 3550966)
Hi there,

I think you have to check if your the default route is up after you do sudo ifup eth0. check it using route command. you should see some thing like

default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

towards the end of the output. If it is not there issue the following command to set the default route.

route add default gw 192.168.0.1

of-course 192.168.0.1 is you router IP address.

cheers

Hi, linusali,
Thank you for your help.

After 'ifup eth0' the 'router -n' has the following output:
Code:

Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.18.0    0.0.0.0        255.255.255.0  U    0      0        0 eth0
192.168.15.0    0.0.0.0        255.255.255.0  U    0      0        0 eth1
0.0.0.0        192.168.15.1    0.0.0.0        UG    100    0        0 eth1
0.0.0.0        192.168.18.18  0.0.0.0        UG    100    0        0 eth0
0.0.0.0        192.168.18.1    0.0.0.0        UG    100    0        0 eth0


So, I think my Ubuntu box had connected to router successful.


All times are GMT -5. The time now is 05:18 PM.