Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a CentOS server with 2 network interfaces with configurations:

eth0:

DEVICE=eth0
BOOTPROTO=none
BROADCAST=10.0.0.255
HWADDR=xx:
IPADDR=10.0.0.2
NETMASK=255.255.255.0
NETWORK=10.0.0.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=10.0.0.1
USERCTL=no
IPV6INIT=no
PEERDNS=yes

eth1:

DEVICE=eth1
BOOTPROTO=none
BROADCAST=192.168.0.255
HWADDR=yy
IPADDR=192.168.0.2
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
GATEWAY=192.168.0.1

192 network has internet access and 10 network doesn't. Currently, I can't connect to internet but I need my server have internet access.I figured I need to prioritize ethernet interfaces as eth1 and eth0. How can I do that ? Thank you for your answers.

share|improve this question

3 Answers 3

If you don't need traffic on the 10.0.0.0/24 net to pass outside the subnet: Remove the GATEWAY= from the 10.0.0.0/24 interface.


If you DO need traffic to traverse outside the 10net you are looking at more complicated routing tables. Remove the GATEWAY= from both interfaces.

IN: /etc/sysconfig/network-scripts/ifcfg-eth1 add:

DEVICE=eth1
BROADCAST=192.168.0.255
IPADDR=192.168.0.2
NETMASK=255.255.255.0
ONBOOT=yes
IPV6INIT=no

IN: /etc/sysconfig/network-scripts/route-eth1 add:

192.168.0.0/24 dev eth1
default via 192.168.0.1

IN: /etc/sysconfig/network-scripts/ifcfg-eth0 add:

DEVICE=eth0
BROADCAST=10.0.0.255
IPADDR=10.0.0.2
NETMASK=255.255.255.0
ONBOOT=yes
IPV6INIT=no

Now this is the silly part. Let's say that your 10.0.0.1 gateway routes traffic to 10.0.2.0/24 and 192.168.67.0/24 ...We need a static route defined to reach those networks through the proper gateway:

IN /etc/sysconfig/network-scripts/route-eth0 add:

10.0.0.0/24 dev eth0
10.0.2.0/24 via 10.0.0.1
192.168.67.0/24 via 10.0.0.1

I highly doubt you actually are routing outside the 10net on the 10 gateway.. but the above config is the solution for that use case. If you just want LOCAL access to the 10.0.0.0/24 subnet via eth0 do all of the above but replace /etc/sysconfig/network-scripts/route-eth0

10.0.0.0/24 dev eth0

The short version is to remove the GATEWAY line from eth0. Run /etc/init.d/network restart after making any of these changes. NOTE: You do not need a gateway if you are not leaving your subnet.

share|improve this answer

I think you can specify

DEFROUTE=yes

within the eth1 configuration to make it the default route.

share|improve this answer

Is eth0 not able to access the internet at all? or is it just that it's using eth1 as the default?

Check your routing table with the route command and look at the default row(s).

If you disconnect or disable eth1, are you able to connect to the internet still?

If yes, and you just want it to go through that interface primarily, you can add DEFROUTE=yes to the eth0 configuration.

If not, try testing with that interface.

  • Ping the gateway on that network (10.0.0.1)
  • Run traceroute www.google.com (or another host outside of your network) and analyze at the output.

Another possibility is that there is a problem with the 10.0.0.1 gateway.

If you are still having problems, please post the output of the route and traceroute commands.

share|improve this answer

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.