PDA

View Full Version : [ubuntu] ifdown eth0; ifup eth0; after reboot to get internet access



Iced
December 4th, 2008, 07:36 AM
Hi Guys,

I recently upgraded my ubuntu-server from 8.04 to 8.10. (I've also done apt-get update; apt-get upgrade; as of the time of this post)

eth0 (external network/internet)
eth1 (internal network)

After a reboot, i have to ifdown eth0; ifup eth0; in order to get access to internet. I do have access to my internal network immediately after a reboot and don't have to ifdown eth1; ifup eth1;. eth0 is dhcp and eth1 is static.

I'm not sure if it's possibly a due to lag on dhcp getting IP address from my provider? (I guess i'd want eth0 to come up first before eth1 in order for the route table to be correct?) I'm only guessing a routing issue.

I'll paste some relevant information (with some XX/YY/NN replacing actual values):


root@box-ubuntu:/etc# cat lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.10
DISTRIB_CODENAME=intrepid
DISTRIB_DESCRIPTION="Ubuntu 8.10"


root@box-ubuntu:/var/log# lspci | grep Ethernet
00:13.0 Bridge: nVidia Corporation CK804 Ethernet Controller (rev a3)
02:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8053 PCI-E Gigabit Ethernet Controller (rev 15)


root@box-ubuntu:/var/log# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.

# PCI device 0x11ab:0x4362 (sky2)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="YY:YY:YY:YY:YY:YY", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x10de:0x0057 (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:XX:XX:XX:XX:XX", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

I don't know if this is related or not, I guess I should test out.


/* Immediately after a reboot and BEFORE I have to ifdown eth0 */
root@box-ubuntu:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
96.NN.NN.0 * 255.255.252.0 U 0 0 0 eth0
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
default 96.NN.NN.1 0.0.0.0 UG 100 0 0 eth0


/* AFTER I have ifdown eth0;ifup eth0 */
root@box-ubuntu:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
96.NN.NN.0 * 255.255.252.0 U 0 0 0 eth0
default 96.NN.NN.1 0.0.0.0 UG 100 0 0 eth0
default box-ubuntu.XXXX 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.XXXX 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.XXXX 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.XXXX 0.0.0.0 UG 100 0 0 eth1


root@box-ubuntu:/var/log# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Shaw Cable Internet
auto eth0
iface eth0 inet dhcp

# Internal Network XXXX
auto eth1
iface eth1 inet static
address 192.168.0.1
network 192.168.0.0
broadcast 192.168.0.255
netmask 255.255.255.0
gateway 192.168.0.1

# nameserver 1
auto eth1:10
iface eth1:10 inet static
address 192.168.0.10
network 192.168.0.0
broadcast 192.168.0.255
netmask 255.255.255.0
gateway 192.168.0.1

# nameserver 2
auto eth1:11
iface eth1:11 inet static
address 192.168.0.11
network 192.168.0.0
broadcast 192.168.0.255
netmask 255.255.255.0
gateway 192.168.0.1

# router/gateway
auto eth1:254
iface eth1:254 inet static
address 192.168.0.254
network 192.168.0.0
broadcast 192.168.0.255
netmask 255.255.255.0
gateway 192.168.0.1

Hoping you guys can help me sort this out as I don't want to have to restart my eth0 interface after a reboot all the time. (And especially if I'm remote and need access to my box externally).

Preferably a solution better than just adding ifdown eth0; ifup eth0 to the startup script. It was working perfectly fine in 8.04

Any other info required?

Iced
December 4th, 2008, 08:16 AM
Some additional information:


root@box-ubuntu:~# cat /etc/resolv.conf
domain xxxxxxxxxxx.xxx
search xxxxxxxxxxx.xxx
nameserver 192.168.0.10
nameserver 192.168.0.11
nameserver 64.NN.NN.N8
nameserver 64.NN.NN.N9

I think the limit is 3 nameservers in /etc/resolv.conf above


root@box-ubuntu:~# ping 64.NN.NN.18
PING 64.NN.NN.N8 (64.NN.NN.N8) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
^C
--- 64.NN.NN.18 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4034ms

root@box-ubuntu:~# /etc/init.d/ufw stop
* Stopping firewall: ufw... [ OK ]

root@box-ubuntu:~# ping 64.NN.NN.N8
PING 64.NN.NN.N8 (64.NN.NN.N8) 56(84) bytes of data.
From 192.168.0.1 icmp_seq=1 Destination Host Unreachable
From 192.168.0.1 icmp_seq=2 Destination Host Unreachable
From 192.168.0.1 icmp_seq=3 Destination Host Unreachable

root@box-ubuntu:~# ifdown eth0; ifup eth0
There is already a pid file /var/run/dhclient.eth0.pid with pid 4460
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.1.1
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/eth0/00:XX:XX:XX:XX:XX
Sending on LPF/eth0/00:XX:XX:XX:XX:XX
Sending on Socket/fallback
DHCPRELEASE on eth0 to 64.NN.NN.N0 port 67
Internet Systems Consortium DHCP Client V3.1.1
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

<SNIP>
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPOFFER of 96.NN.NN.7 from 96.NN.NN.1
DHCPREQUEST of 96.NN.NN.7 on eth0 to 255.255.255.255 port 67
DHCPACK of 96.NN.NN.7 from 96.NN.NN.1
bound to 96.NN.NN.7 -- renewal in 64026 seconds.
* Stopping NTP server ntpd
...done.
root@box-ubuntu:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
96.NN.NN.0 * 255.255.252.0 U 0 0 0 eth0
default 96.NN.NN.1 0.0.0.0 UG 100 0 0 eth0
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
default box-ubuntu.unde 0.0.0.0 UG 100 0 0 eth1
root@box-ubuntu:~# * Starting NTP server ntpd
...done.
/etc/init.d/ufw staping 64.NN.NN.N8
PING 64.NN.NN.18 (64.NN.NN.18) 56(84) bytes of data.
64 bytes from 64.NN.NN.N8: icmp_seq=1 ttl=62 time=8.12 ms
64 bytes from 64.NN.NN.N8: icmp_seq=2 ttl=62 time=7.83 ms
^C
--- 64.NN.NN.N8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1012ms
rtt min/avg/max/mdev = 7.831/7.978/8.126/0.172 ms

superprash2003
December 4th, 2008, 05:28 PM
how about setting a static ip for eth0 as well

DaveVato
December 4th, 2008, 05:41 PM
I am having the same issue after going to 8.10. I have set the statics in /network/interfaces and I still have to ifup eth0 after every reboot.

Iced
December 5th, 2008, 03:45 AM
how about setting a static ip for eth0 as well

You mean as a test? I can try that just to test if it comes up... But ultimately, I can't use a static IP from my provider (unless I pay more of course).

Iced
December 5th, 2008, 07:10 AM
I disabled ufw at startup and still have the same problem ruling out a firewall issue


root@box-ubuntu:~# cat /etc/ufw/ufw.conf
# /etc/ufw/ufw.conf
#

# set to yes to start on boot
ENABLED=no

kevdog
December 5th, 2008, 01:13 PM
In your /etc/network/interfaces file, in whatever interface you would like to bring up at boot, put a statement such as

pre-up sleep 10

Iced
December 6th, 2008, 08:23 AM
kevdog, unfortunately didn't work :(

I did notice the 10s delay when 'configuring network interfaces'...

kevdog
December 6th, 2008, 01:53 PM
Ok just two choices here:

increase 10 to something like 20 or something

or with the /etc/rc.local file before the exit statement at the bottom, put

/etc/init.d/networking restart

or just put your

ifup ....
ifdown ....

statements

Your networking stack is dependent on a driver that isn't being loaded prior to bringing up the network. Hence the reason for the delay to allow the driver to load or simply restarting it at the end of the boot process

Anagonda
December 6th, 2008, 02:01 PM
I'm having this same issue. But my problem is a bit different.
My network worked fine until I added second ip(static and as eth0:1). Eth0 is on dhcp.
I'm running a clean install of 8.10 64bit altrenate. On first boot network was fine. Then I modified /etc/network/interfaces and after that my network won't work before ifdown ifup on both eth0 and eth0:1.

After boot my network seems to be ok by ifconfig(it has gotten ip from dhcp etc). But it doesn't work.

Any help? This system is going to run as a NAS. So network should work automaticly after boot.

EDIT: oh, I forgot that my "network configurator" that gui network thing doesn't work either anymore. If I try to edit eth0 or eth0:1 I get a error that says something like: "Updating connection failed: nm-ifupdown-connection.c.82 - connection update not supported (read-only).."
I tried to run network configurator as root, but same screen appears.

Iced
December 6th, 2008, 08:37 PM
I am having the same issue after going to 8.10. I have set the statics in /network/interfaces and I still have to ifup eth0 after every reboot.

Hi DaveVato, do you have auto eth0 above each iface declaration?

example:

auto eth0
iface eth0 inet dhcp

DaveVato
December 7th, 2008, 10:36 PM
[QUOTE=Iced;6320288]Hi DaveVato, do you have auto eth0 above each iface declaration?

This is what I have in my interfaces.


auto lo
iface lo inet loopback
iface eth0 inet static
address 10.56.8.113
netmask 255.255.255.0
gateway 10.56.8.1

Iced
December 8th, 2008, 06:47 AM
DaveVato, I believe you need:

[code]
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.56.8.113
netmask 255.255.255.0
gateway 10.56.8.1

kevdog
December 8th, 2008, 06:56 AM
Did you ever find a solution to this problem?

Iced
December 8th, 2008, 07:14 AM
Hey kevdog, I hadn't had a chance to try the suggestions until now. I tried changing pre-up sleep to 20..and even 45 but still didn't work. I'm assuming your ifdown/ifup at the end of startup script would work but I kind of wanted to know what the problem was instead of trying to work around it since it was perfectly find in 8.04?

I'll try putting at the end of the startup script just to be sure.

Iced
December 8th, 2008, 07:20 AM
ifdown eth0; ifup eth0; confirmed works in /etc/rc.local

(see bottom my first post preferring reason other than the startup script solution... Sorry, I'm the kind of guy that needs to figure out why it's not working.) Can u think of any other reason what would have changed? I don't think any of the service priorities changed?

dmizer
December 8th, 2008, 07:27 AM
DaveVato, I believe you need:



auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.56.8.113
netmask 255.255.255.0
gateway 10.56.8.1

This is probably a better solution.

Basically, your network interface was not configured to come on automatically, thus requiring ifdown, ifup. You should probably make the above change and remove the changes to /etc/rc.local and then you'll be fine. That way you're not relying on two processes to engage your network adapter.

kevdog
December 8th, 2008, 07:30 AM
A driver is not loading either in the correct order, or its being started (but takes awhile to load) and another process that is started after the first completes before the first.

I used to have this same problem way back in Feisty after I installed/upgraded a bunch of packages. Something broke. I reinstalled Feisty and the problem went away. I never found the explanation although I looked for days for the solution. I was happy at least I could find a script solution.

rc.local is the last process to run during the boot process, that is why the rc.local solution works. All the processes are up and running by the time execution of these commands occur.

I wish you luck in coming up or finding the exact solution. In the end it really wont matter that much. If you end up installing Jaunty from scratch, it will not be a problem in the future.

DaveVato
December 8th, 2008, 04:14 PM
the auto eth0 didnt work for me, I ended up doing the rc.local fix and that worked. Eth0 stays up after every reboot.

Iced
December 20th, 2008, 06:57 AM
I'm having this same issue. But my problem is a bit different.
My network worked fine until I added second ip(static and as eth0:1). Eth0 is on dhcp.
I'm running a clean install of 8.10 64bit altrenate. On first boot network was fine. Then I modified /etc/network/interfaces and after that my network won't work before ifdown ifup on both eth0 and eth0:1.

After boot my network seems to be ok by ifconfig(it has gotten ip from dhcp etc). But it doesn't work.

Any help? This system is going to run as a NAS. So network should work automaticly after boot.

EDIT: oh, I forgot that my "network configurator" that gui network thing doesn't work either anymore. If I try to edit eth0 or eth0:1 I get a error that says something like: "Updating connection failed: nm-ifupdown-connection.c.82 - connection update not supported (read-only).."
I tried to run network configurator as root, but same screen appears.

Did you ever resolve this, Anagonda?