LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 08-03-2006, 01:10 AM   #1
shamilson
LQ Newbie
 
Registered: Aug 2006
Posts: 11

Rep: Reputation: 0
How to configure two NIC's properly in the server with RH 9.0


I want to create a small network with 3 computers. In my network there will be 2 clients and 1 server computer and all of them will be running Redhat 9.0 OS. I have configured the NIC cards for clients. I want my server to be connected to the internet so I inserted into it two NIC cards, one of the NIC is connected to the internet and the other to sub LAN.
Below i have given the structure of the network.

internet conn (eth0) ip=165.229.192.57
<------------------> SERVER

(eth1) ip=192.168.0.4||

Client A <---------> Switch <------> Client B
ip=192.168.0.3(IP of A) ip=192.168.0.2 (IP of B)

Note: I am connecting my server to internet throught LAN in my lab.
The client computers connected to server throught switch.

My problems
1. In my server when i insert the second NIC card(i.e eth1) then the first one is not functioning(i.e eth0). And there is no internet connection. How to configure two NIC's so that they will function properly ?

2. I want my server to be a gateway and a router for two other computers ?. Could you give a link how and what i need to do so that properly configure my server as a router ?.

Waiting for your replies ...

Last edited by shamilson; 08-03-2006 at 01:15 AM.
 
Old 08-03-2006, 06:01 AM   #2
penguintutor
Member
 
Registered: Jun 2006
Location: UK
Distribution: Ubuntu, Mandriva, Redhat and Fedora
Posts: 118

Rep: Reputation: 15
My guess is that you have a default route set on both interfaces, so that when the new interface comes up it is routing the internet traffic through the local interface.

You can check this using
Code:
netstat -rn
and check that you have a default gateway (destination 0.0.0.0) pointing at your Internet gateway address, and not your local one.

The default gateway is configured in
/etc/sysconfig/network
using an entry such as:
Code:
GATEWAY 192.168.1.1
replacing the ip address with your router / ISP router.

Any static routes for the local network (probably not required if they are just connected to the same subnet as the local interface) go into /etc/rc.local using the route command.

The /etc/sysconfig/network file is also used to define ip_forwarding - which is required for the machine to act as a router using
Code:
FORWARD_IPV4=true
Your machine should then forward any traffic to the Internet.

I'd suggest you also take a look at adding some IPTABLE rules so that the gateway machine can act as a basic firewall.


If this hasn't fixed your problem, then a copy of the /etc/network, netstat -rn , and a
Code:
sudo /sbin/ifconfig -a
output may be helpful.
 
Old 08-04-2006, 02:36 AM   #3
shamilson
LQ Newbie
 
Registered: Aug 2006
Posts: 11

Original Poster
Rep: Reputation: 0
It didnot worked out for me ... So below my configurations

[root@my-hostname root]# sudo /sbin/ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0A:5E:46:8F:6F
inet addr:165.229.192.57 Bcast:165.229.192.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:527 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:354 (354.0 b) TX bytes:31620 (30.8 Kb)
Interrupt:5 Base address:0xc800

eth1 Link encap:Ethernet HWaddr 00:04:76:9D:F1:74
inet addr:192.168.0.4 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6935 errors:0 dropped:0 overruns:1 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:676775 (660.9 Kb) TX bytes:660 (660.0 b)
Interrupt:10 Base address:0xcc00

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:1007 errors:0 dropped:0 overruns:0 frame:0
TX packets:1007 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:75356 (73.5 Kb) TX bytes:75356 (73.5 Kb)

[root@my-hostname root]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
165.229.192.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.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 165.229.192.2 0.0.0.0 UG 0 0 0 eth0

/etc/sysconfig/network
========================================
NETWORKING=yes
HOSTNAME=my-hostname2
FORWARD_IPV4=true
GATEWAY=165.229.192.2

/etc/sysconfig/network-scripts/ifcfg-eth0
=========================================
DEVICE=eth0
ONBOOT=yes
IPADDR=165.229.192.57
NETMASK=255.255.255.0
GATEWAY=165.229.192.2
TYPE=Ethernet
USERCTL=no
PEERDNS=no
NETWORK=165.229.192.0
BROADCAST=165.229.192.255
BOOTPROTO=none

/etc/sysconfig/network-scripts/ifcfg-eth1
=========================================
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
USERCTL=no
PEERDNS=yes
GATEWAY=165.229.192.57
TYPE=Ethernet
DEVICE=eth1
HWADDR=00:04:76:9d:f1:74
BOOTPROTO=none
NETMASK=255.255.255.0
ONBOOT=yes
IPADDR=192.168.0.4
NETWORK=192.168.0.0
BROADCAST=192.168.0.255

I have added the routes like this, could you tell me is it right ?

route add default gw 165.229.192.2 dev eth0
route add -net 192.168.0.0 netmask 255.255.255.0 gw 165.229.192.57 dev eth0

I have used for eth1 gateway the eth0 ip address is it right ?

Note: 165.229.192.2 ==> is the cable for internet connection.
165.229.192.57 ==> is eth0 ip address

Looking forward for your reply
Thank you ...

Quote:
Originally Posted by penguintutor
My guess is that you have a default route set on both interfaces, so that when the new interface comes up it is routing the internet traffic through the local interface.

You can check this using
Code:
netstat -rn
and check that you have a default gateway (destination 0.0.0.0) pointing at your Internet gateway address, and not your local one.

The default gateway is configured in
/etc/sysconfig/network
using an entry such as:
Code:
GATEWAY 192.168.1.1
replacing the ip address with your router / ISP router.

Any static routes for the local network (probably not required if they are just connected to the same subnet as the local interface) go into /etc/rc.local using the route command.

The /etc/sysconfig/network file is also used to define ip_forwarding - which is required for the machine to act as a router using
Code:
FORWARD_IPV4=true
Your machine should then forward any traffic to the Internet.

I'd suggest you also take a look at adding some IPTABLE rules so that the gateway machine can act as a basic firewall.


If this hasn't fixed your problem, then a copy of the /etc/network, netstat -rn , and a
Code:
sudo /sbin/ifconfig -a
output may be helpful.
 
Old 08-04-2006, 03:50 AM   #4
dambla
Member
 
Registered: Aug 2006
Posts: 51

Rep: Reputation: 15
i think the problem is you have a GATEWAY entry for both nics. comment out one of them and see if it works. also, you might want to look into using iptables to forward traffic with SNAT. i think it's something like
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source <ip_addres_of_eth0>

Last edited by dambla; 08-04-2006 at 03:53 AM.
 
Old 08-04-2006, 04:16 AM   #5
penguintutor
Member
 
Registered: Jun 2006
Location: UK
Distribution: Ubuntu, Mandriva, Redhat and Fedora
Posts: 118

Rep: Reputation: 15
You should remove the gateway entry in the ifcfg-eth1 file.

That will try and add a gateway entry using that interface which is wrong.

The following entry should not be needed as it is implied in your interface configuration
Quote:
route add -net 192.168.0.0 netmask 255.255.255.0 gw 165.229.192.57 dev eth0
If you run netstat -rn you should have an entry similar to:
Quote:
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
If you do need to explicitly add the entry, then it should not have the gateway as the Internet interface.

To add a route to a local network then you use
Code:
route add -net 192.168.0.0 netmask 255.255.255.0 dev eth1
but this should be defined anyway, you should not have to run that manually.

You should then be able to test connectivity from your gateway to devices on both the Internet and your local lan.

A IPTABLE nat/masquerading rule will be required to allow traffic between a reserved address range (the 192.168.*) and the Internet.
 
Old 08-04-2006, 11:48 PM   #6
shamilson
LQ Newbie
 
Registered: Aug 2006
Posts: 11

Original Poster
Rep: Reputation: 0
Could you be so kind as to clarify the below doubts.

1. My server computer is installed RH9.0 as a "Workstation" not "server" is a problem ?.

2. So i have to NIC's in my server computer(i.e gateway,router).
eth0's, ip address is: 165.229.192.57, netmask is:255.255.255.0 and default gateway is: 165.229.192.2.

eth1's ip address is: 192.168.0.4, netmask is:255.255.255.0 and default gateway is: What should be the gateway address for this NIC(i.e 165.229.192.2 or ip-address_of_eth0).

Thank you.

Quote:
Originally Posted by penguintutor
You should remove the gateway entry in the ifcfg-eth1 file.

That will try and add a gateway entry using that interface which is wrong.

The following entry should not be needed as it is implied in your interface configuration


If you run netstat -rn you should have an entry similar to:


If you do need to explicitly add the entry, then it should not have the gateway as the Internet interface.

To add a route to a local network then you use
Code:
route add -net 192.168.0.0 netmask 255.255.255.0 dev eth1
but this should be defined anyway, you should not have to run that manually.

You should then be able to test connectivity from your gateway to devices on both the Internet and your local lan.

A IPTABLE nat/masquerading rule will be required to allow traffic between a reserved address range (the 192.168.*) and the Internet.
 
Old 08-05-2006, 01:24 AM   #7
dambla
Member
 
Registered: Aug 2006
Posts: 51

Rep: Reputation: 15
that's just it. it isn't supposed to have any default gateway. in the file you posted above with eth1 you need to comment out the GATEWAY entry.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to setup rsh or configure ssh properly cheeku Linux - Software 5 03-30-2006 07:47 AM
Need Advice; 3 NIC's; High Volume Mail Server; Sendmail; Iptables? Killer Bassist Linux - Networking 3 12-04-2005 11:40 PM
Server with 2 NIC's TheRealDeal Linux - General 2 09-22-2003 09:08 PM
DHCP Server and 2 NIC's NVETHIS Linux - Networking 4 07-10-2003 09:26 AM
x1 server, x2 NIC's, x2 networks jcbotha Linux - Networking 2 03-12-2003 11:59 AM


All times are GMT -5. The time now is 02:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration