Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've got an Ubuntu 10.04 server with this configuration:

eth0: 192.168.10.XXX mask 255.255.255.0 gw 192.168.10.254
eth1: 192.168.0.XXX mask 255.255.255.0 gw 192.168.0.3

eth0 is used for incoming and outgoing trafic (internal webserver)
eth1 i want to use for accessing the network: 192.168.51.0/24 by gateway 192.168.0.1

when eth1 is down, the webserver is reachable.

When i want to bring the state of eth1 to up, i use the following commands:

$ sudo su
# ifconfig eth1 up
# route add -net 192.168.51.0 netmask 255.255.255.0 gw 192.168.0.1
# ping 192.168.51.XXX
[i've got contact]

# ip route add default via 192.168.10.254
# ping 192.168.51.XXX
[i've got contact]

but when i want to access the webserver, i can't get contact.

Can someone please give me some advice so the network .51 AND the webserver (network .10) is reachable?

ifconfig

# ifconfig
eth0      Link encap:Ethernet  HWaddr mymac  
          inet addr:192.168.10.2  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fee0:39c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23207 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24924 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2683656 (2.6 MB)  TX bytes:12841148 (12.8 MB)

eth0:1    Link encap:Ethernet  HWaddr mymac  
          inet addr:192.168.10.10  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1      Link encap:Ethernet  HWaddr mymac  
          inet addr:192.168.0.237  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fee0:3a6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3742 errors:0 dropped:0 overruns:0 frame:0
          TX packets:143 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:318099 (318.0 KB)  TX bytes:12994 (12.9 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3175 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3175 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:221390 (221.3 KB)  TX bytes:221390 (221.3 KB)

route -n

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.51.0    192.168.0.1     255.255.255.0   UG    0      0        0 eth1
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.10.254  0.0.0.0         UG    0      0        0 eth0
0.0.0.0         192.168.10.254  0.0.0.0         UG    100    0        0 eth0
0.0.0.0         192.168.10.254  0.0.0.0         UG    100    0        0 eth0

/etc/network/interfaces

# cat /etc/network/interfaces 

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static 
address 192.168.10.2
netmask 255.255.255.0
gateway 192.168.10.254

# A second ip address for SSL
auto eth0:1
iface eth0:1 inet static
address 192.168.10.10
netmask 255.255.255.0
gateway 192.168.10.254

auto eth1
iface eth1 inet static
address 192.168.0.237
netmask 255.255.255.0
gateway 192.168.0.3
post-up route add -net 192.168.51.0 netmask 255.255.255.0 gw 192.168.0.1 
share|improve this question
    
Hi and welcome to askubuntu - to mark an answer as solved, just click the tick button next to your answer. Thanks. –  fossfreedom Oct 24 '12 at 11:50
    
then a nice orange box will show with the message: You can accept your own answer in 17 hours –  Falco van Dooremolen Oct 24 '12 at 13:33
    
hey - come back tommorrow! - well done on the answer. –  fossfreedom Oct 24 '12 at 13:39
add comment

2 Answers 2

up vote 1 down vote accepted

I've got the solution!

The command i had executed was:

# route del -net 192.168.0.0 netmask 255.255.255.0 eth1

After that command my: 0 network, 10 network AND 51 network was accessible.
I also edit /etc/sysctl.conf and uncomment net.ipv4.ip_forward=1 before, but i'm not sure if this is necessary.

my configs:

ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:0c:29:e0:03:9c  
          inet addr:192.168.10.2  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fee0:39c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:53794 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53916 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6812117 (6.8 MB)  TX bytes:21573511 (21.5 MB)

eth0:1    Link encap:Ethernet  HWaddr 00:0c:29:e0:03:9c  
          inet addr:192.168.10.10  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1      Link encap:Ethernet  HWaddr 00:0c:29:e0:03:a6  
          inet addr:192.168.0.237  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fee0:3a6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29845 errors:0 dropped:0 overruns:0 frame:0
          TX packets:469 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2555869 (2.5 MB)  TX bytes:42872 (42.8 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8157 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8157 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:624350 (624.3 KB)  TX bytes:624350 (624.3 KB)

route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.51.0    192.168.0.1     255.255.255.0   UG    0      0        0 eth1
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.10.254  0.0.0.0         UG    0      0        0 eth0
0.0.0.0         192.168.10.254  0.0.0.0         UG    100    0        0 eth0
0.0.0.0         192.168.10.254  0.0.0.0         UG    100    0        0 eth0

/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

# The primary network interface
auto eth0
iface eth0 inet static 
address 192.168.10.2
netmask 255.255.255.0
gateway 192.168.10.254

auto eth0:1
iface eth0:1 inet static
address 192.168.10.10
netmask 255.255.255.0
gateway 192.168.10.254

auto eth1
iface eth1 inet static
address 192.168.0.237
netmask 255.255.255.0
gateway 192.168.0.1
post-up route add -net 192.168.51.0 netmask 255.255.255.0 gw 192.168.0.1 
share|improve this answer
add comment

Please post the results of the following commands:

$ifconfig
$route -n

Also post the contents of /etc/network/interfaces. You may use this command for this:

sudo gedit /etc/network/interfaces

UPDATE 1: Okay, in /etc/network/interfaces, set gateway of eth0 to 192.168.0.1 and remove all other gateway entries. Reboot system and see if it works now.

And I presume that you've edited the default gateway in the router config too, as most routers are set with a default gateway of 192.168.1.1. Do check the router gateway at once.

share|improve this answer
    
your comment results in no connection at all when i put the gw 192.168.0.1 in eth1, no change at all. –  Falco van Dooremolen Oct 23 '12 at 8:32
    
What's the router gw: 192.168.0.1 or 192.168.10.1 or 192.168.1.1? Are you using two routers with the same gw addr? Check the router gw & netmask first; seems to be a case of mismatch. –  TomKat Oct 23 '12 at 8:40
    
i've got a complex network situation. i made a network diagram for you: i.img-share.net/CP5nlDubSW.bmp –  Falco van Dooremolen Oct 23 '12 at 10:01
    
Falco, as far as I'm aware, multiple NICs can be used on the same system provided that they're part of two different networks! The first router connects to both the sub-nets and that's the reason why it's not working the way it should. That's what I can say according to my experience. –  TomKat Oct 24 '12 at 4:40
    
so, (if i understand well) in these configuration it is impossible? –  Falco van Dooremolen Oct 24 '12 at 9:21
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.