Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have just setup a machine which has two NICs, one for private network and the other one for public network which has a real IP assigned to it.

DEVICE=eth0
HWADDR=XXX
TYPE=Ethernet
UUID=XXX
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=172.26.111.131
NETMASK=255.255.255.128
GATEWAY=172.26.111.129

Configuration of eth1 for public network as follows;

DEVICE=eth1
HWADDR=XXX
TYPE=Ethernet
UUID=XXX
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=PUBLIC_IP
NETMASK=255.255.255.248
GATEWAY=PUBLIC_GATEWAY


Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         PUBLIC_GATEWAY   0.0.0.0         UG    0      0        0 eth1
PUBLIC_NID      *               255.255.255.248 U     0      0        0 eth1
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1004   0        0 eth1
172.26.111.128  *               255.255.255.128 U     0      0        0 eth0

I am sure this is quite easy to achieve. I have searched about this, but somehow could not get this working. The machine still tries to route private IPs via public gateway.

I would appreciate any ideas on this. Where I am wrong at?

I am just trying to be able to access 172.26.111.128/25 via eth0.

share|improve this question
    
And what IP address are you coming from? –  tink Apr 30 '13 at 0:55
    
which ip you are trying to access in lan provide that also.. –  Rahul Patil Apr 30 '13 at 3:01
    
You appear to have given your NIC the network address. That ip isn't valid for a host. –  jordanm Apr 30 '13 at 3:29
    
172.26.111.131 is the IP address that I want to use for this host on that private network. I am trying to access 172.26.111.130, however, I even cannot ping the gateway itself with this current setup. –  compixtr Apr 30 '13 at 8:45
add comment

2 Answers

My setup

I've setup an alias for eth0 so that it actually possesses 2 IP addresses, 192.168.1.6 & 192.168.1.254.

I do something like this locally:

ifconfig eth1:0 192.168.1.254
route add -host 192.168.1.254 dev eth1:0

This gives me a routing table like this:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.254   0.0.0.0         255.255.255.255 UH    0      0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
ISP_NETWORK     0.0.0.0         255.255.240.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
0.0.0.0         ISP_GATEWAY     0.0.0.0         UG    0      0        0 eth0

This gives me a route like this:

192.168.1.254   0.0.0.0         255.255.255.255 UH    0      0        0 eth1

References

share|improve this answer
    
Hi slm, thank but I indeed am trying to be able to access 172.26.111.128/25 via eth0 while 172.26.111.131(within same network) should be assigned to eth0. –  compixtr Apr 30 '13 at 9:03
    
See my updates. –  slm Apr 30 '13 at 11:48
    
Well, to be honest, that did not make much sense to me - 192.168.1.254 -> 0.0.0.0 ? is this reasonable? does not this mean that the stuff destinate that IP will be routed via ISP's gateway? –  compixtr Apr 30 '13 at 12:05
add comment
up vote 0 down vote accepted

Well, it was our fault guys. I was trying to ping a host which indeed does not exist hence I was thinking as if the network was not routing properly. Thanks for all your messages and helps!

share|improve this answer
add 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.