LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to configure two NIC's properly in the server with RH 9.0 (https://www.linuxquestions.org/questions/linux-networking-3/how-to-configure-two-nic%27s-properly-in-the-server-with-rh-9-0-a-470316/)

shamilson 08-03-2006 01:10 AM

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 ...

penguintutor 08-03-2006 06:01 AM

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.

shamilson 08-04-2006 02:36 AM

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.


dambla 08-04-2006 03:50 AM

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>

penguintutor 08-04-2006 04:16 AM

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.

shamilson 08-04-2006 11:48 PM

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.


dambla 08-05-2006 01:24 AM

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.


All times are GMT -5. The time now is 02:49 AM.