LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting up a server with 2 network cards & ADSL (https://www.linuxquestions.org/questions/linux-newbie-8/setting-up-a-server-with-2-network-cards-and-adsl-536800/)

Avatar 03-12-2007 08:31 AM

Setting up a server with 2 network cards & ADSL
 
OK Linux people I need help -- again!

I've got a nice server set up here that does just what I need it to, except it's become unreliable. So, I'm replacing it. This server has been running for about 3 years now.

I am currently preparing its replacement. The new server has Ubuntu 6.10 with kernel 2.6.17.

Both servers have 2 network cards, one connects to the LAN switch (eth1) and one connects to the ADSL modem. (eth0).

Three years ago when I set up the current server. I wrote down what I did. One of my instructions was "configure eth0 NOT to come up at boot time" but I can't remember how I did this.

Old server works great. Eth1 takes care of the LAN, and eth0 is used as ppp0 and connects to the ADSL on boot.

New server, has all kinds of routing table problems, and ifconfig shows Eth1, Eth0 AND ppp0 when connected.

I think if I can just figure out how to get the eth0 to stay down, it would solve some problems. Just typing "ifconfig eth0 down" results in ppp0 not being able to connect.

A little help? :)

Gzou 03-12-2007 02:09 PM

Umm I'm a little confused. Why would you want eth0 to stay down ?

it's a bit normal that ppp doesn't work when you do a "ifconfig eth0 down" since ppp uses eth0 to connect with your ADSL modem. no eth0, no ppp, no internet.

one way I know of to stop eth0 from being hotplugged by udev at boot (although I don't know how this can help you) is to:

edit /etc/conf.d/rc (using something like vim or nano)

look for RC_PLUG_SERVICES="" in the file and add "!net.eth0" in the quotes. So it would look like :

RC_PLUG_SERVICES="!net.eth0"

should work, although i've never tried it on my ubuntu.

Also, posting a few error messages like the one that tells you about the routing table problems might help.

Avatar 03-12-2007 04:30 PM

Well I don't want eth0 to up at boot because then it gives itself an IP address rather than using ppp0.

And, my route table is all messed up somehow.

My main problem is I am swiching distros from Mandrake (RPM based kernel 2.4) to Ubuntu (Debian based, kernel 2.6) so all my config files from Mandrake are useless.

For example my configuration on my existing Mandrake server is as follows:

/etc/sysconfig/network-scripts/ifcfg-eth0
Code:

DEVICE=eth0
USERCTL=no
ONBOOT=no
BOOTPROTO=dhcp
IPADDR=
NETMASK=
NETWORK=0.0.0.0
BROADCAST=255.255.255.255
DHCP_CLIENT=/sbin/dhclient

/etc/sysconfig/network-scripts/ifcfg-eth1
Code:

DEVICE=eth1
USERCTL=no
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
DHCP_CLIENT=/sbin/dhcpcd

ifconfig (Mandrake)
Code:


eth0      Link encap:Ethernet  HWaddr 00:09:6B:63:15:4E
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1428644 errors:5404 dropped:0 overruns:0 frame:0
          TX packets:1301018 errors:0 dropped:0 overruns:0 carrier:0
          collisions:5404 txqueuelen:100
          RX bytes:1270698349 (1211.8 Mb)  TX bytes:227804479 (217.2 Mb)
          Interrupt:24 Memory:fbff0000-fc000000

eth1      Link encap:Ethernet  HWaddr 00:09:6B:63:15:4F
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1235481 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1529784 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:236154610 (225.2 Mb)  TX bytes:1451267485 (1384.0 Mb)
          Interrupt:25 Memory:fbfe0000-fbff0000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:499685 errors:0 dropped:0 overruns:0 frame:0
          TX packets:499685 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:49578901 (47.2 Mb)  TX bytes:49578901 (47.2 Mb)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:XXX.XXX.XXX.XXX  P-t-P:XXX.XXX.XXX.XXX  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:15 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:3318 (3.2 Kb)  TX bytes:342 (342.0 b)

Notice eth0 DOES NOT HAVE AN IP ADDRESS.

Of course on Debian everything is done differently.

I found a file /etc/network/interfaces wich I assume does what my above files do, but the syntax is all different:
Code:

# 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 dhcp

auto dsl-provider
iface dsl-provider inet ppp
provider dsl-provider

    pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf

As you can see my eth1, which I would like it to be a static IP address (not configured to be static yet) is not even listed.

Here is my Ubuntu ifconfig:
Code:

eth0      Link encap:Ethernet  HWaddr 00:10:18:24:C9:4B
          inet addr:192.168.1.198  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::210:18ff:fe24:c94b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8975 errors:13 dropped:0 overruns:0 frame:0
          TX packets:6348 errors:0 dropped:0 overruns:0 carrier:0
          collisions:13 txqueuelen:1000
          RX bytes:11856108 (11.3 MiB)  TX bytes:595537 (581.5 KiB)
          Interrupt:90

eth1      Link encap:Ethernet  HWaddr 00:14:5E:20:32:02
          inet addr:192.168.1.199  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::214:5eff:fe20:3202/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16837 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16763 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1520865 (1.4 MiB)  TX bytes:14536916 (13.8 MiB)
          Interrupt:177

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:10793 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10793 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3579997 (3.4 MiB)  TX bytes:3579997 (3.4 MiB)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:XXX.XXX.XXX.XXX  P-t-P:XXX.XXX.XXX.XXX  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:8912 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6490 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:11614467 (11.0 MiB)  TX bytes:441069 (430.7 KiB)

Everything works great in Mandrake, but in Ubuntu I have a helluva time, from the server I can access EITHER the Lan OR the Internet via Lynx but not both at the same time, and the LAN cannot access the Internet, but sometimes it can if I mess with the route command enough.... I also have to do pon and poff several times before it works. So I think if I could configure it the way I have Mandrake, it would work. My belief is that eth0 and ppp0 are arguing. I have to do route add commands. Here is my routing tables

Mandrake
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
XXX.XXX.XXX.51  0.0.0.0        255.255.255.255 UH    0      0        0 ppp0
192.168.1.0    0.0.0.0        255.255.255.0  U    0      0        0 eth1
127.0.0.0      0.0.0.0        255.0.0.0      U    0      0        0 lo
0.0.0.0        XXX.XXX.XXX.51  0.0.0.0        UG    0      0        0 ppp0

Ubuntu
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
64.230.197.51  0.0.0.0        255.255.255.255 UH    0      0        0 ppp0
192.168.1.0    0.0.0.0        255.255.255.0  U    0      0        0 eth1
0.0.0.0        0.0.0.0        0.0.0.0        U    0      0        0 ppp0


TigerOC 03-13-2007 07:01 AM

There are 2 problems in your /etc/network/interfaces that are not configured and therefore causing problems with your routing. The first is you need to specify eth1 static details;

auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0

Now you need to specify in the ppp section that the lease address that it picks up is the gateway for the system. I have not used this method as we use pppoa in the UK which is all handled by the modem/router interface but it should be easy enough to find out how to specify this. I am not sure what you are using eth1 for in this mix.

Avatar 03-13-2007 08:33 AM

Hi TigerOC,

Sorry, I should have given more details about my setup.

It looks like this:

LAN -- eth1 -- Server -- eth0 (ppp0) -- ADSL modem -- Internet

So the server sits between our local network and the Internet (adsl modem) The ISP provides us a public IP address via DHCP. Eth0 is plugged into the modem and eth1 is plugged into our Lan switch.

I read the man page and have reconfigured my /etc/network/interfaces as follows:

Code:


auto lo eth1
iface lo inet loopback
iface eth1 inet static
      address 192.168.1.1
      netmask 255.255.255.0
      network 192.168.1.0
      broadcast 192.168.1.255

auto eth0
iface eth0 inet dhcp

When I rebooted my eth0 did not give itself an IP address which is what I wanted. I can access the Internet now through that box, if I first do echo "1" > /proc/sys/net/ipv4/ip_forward.

Is there any way I can get this to work at boot time:

Eth1 - comes up at boot
Eth0 - connects to ppp0/ADSL at boot time
ip_forward is set properly at boot time

I would like to have everythig work at start up - the less we have to type after booting up, the better.

TigerOC 03-14-2007 03:32 AM

Make a small script;
Code:

#!/bin/sh
echo "1" > /proc/sys/net/ipv4/ip_forward

save the script in /etc/init.d as ip_forward.sh and then as root cd to /etc/init.d/ and do;
chmod 700 ip_forward.sh.

Test the script by doing /etc/init.d/ip_forward start which should execute without error. You can stop it by replacing start with stop. Now put it in the required run levels by doing as root (whilst still in /etc/init.d/);-

update-rc.d ip_forward defaults 89

if any stage you wish to remove these soft links to this script do;-

update-rc.d -f ip_forward remove

Avatar 03-14-2007 09:13 AM

Hi TigerOC,

Thanks for your help, I think it worked! Without IP forward I can't do anything except via my squid proxy. I.E. no email, can't ping, etc.

I followed your direction and got this result:
Code:

root@proxy:/etc/init.d# update-rc.d ip_forward.sh defaults 89
 Adding system startup for /etc/init.d/ip_forward.sh ...
  /etc/rc0.d/K89ip_forward.sh -> ../init.d/ip_forward.sh
  /etc/rc1.d/K89ip_forward.sh -> ../init.d/ip_forward.sh
  /etc/rc6.d/K89ip_forward.sh -> ../init.d/ip_forward.sh
  /etc/rc2.d/S89ip_forward.sh -> ../init.d/ip_forward.sh
  /etc/rc3.d/S89ip_forward.sh -> ../init.d/ip_forward.sh
  /etc/rc4.d/S89ip_forward.sh -> ../init.d/ip_forward.sh
  /etc/rc5.d/S89ip_forward.sh -> ../init.d/ip_forward.sh
root@proxy:/etc/init.d#

Now: how do I get my ADSL to connect on boot? The command is: pon, do I just do the same thing as with setting ip_forward?

On my old Mandrake server, I had done the ip_forward setting in the init.d script, which I believe is similar to what we just did. But the ADSL, I believe, had its own script (which I no longer have access to since the Mandrake server died for good yesterday, and won't boot any more). Mandrake uses adsl-setup/adsl-connect and Debian/Ubuntu uses pon/poff for connections, so I couldn't just copy from the old server.

I realise you don't use ADSL but I have a feeling this is a simple problem ... :)

TigerOC 03-15-2007 02:35 AM

Yes do the same thing;

Code:

#!/bin/sh
pon

Save it in /etc/init.d/ as adsl_connect.sh and then follow the same route as above.

So how does this system work? In the UK we use pppoa and we use modem/routers that are permanently connected and the router connects via ethernet to the lan box. So all this is handled by the router in the modem/router.


All times are GMT -5. The time now is 11:31 AM.