5

I have 2 ethernet interface eth0 with IP 192.168.1.11 and eth1 with IP 192.168.1.12 and i have modem/router as 192.168.1.1.

I can access internet from this server machine, but cannot access any other system from this server within the LAN.

Here is the outputs i have.

  knr@kannur:~$ ifconfig -a

    eth0      Link encap:Ethernet  HWaddr 00:27:0e:2f:83:60  
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0 
          inet6 addr:   fe80::227:eff:fe2f:8360/64   Scope:Link 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
          RX packets:13706   errors:0 dropped:0 overruns:0 frame:0 
          TX packets:15389   errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:7203014 (7.2 MB)  TX bytes:2382269 (2.3 MB)

    eth1      Link encap:Ethernet  HWaddr 00:90:27:77:29:ad  
          inet addr:192.168.1.12    Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr:   fe80::290:27ff:fe77:29ad/64 Scope:Link 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
          RX packets:7797   errors:0 dropped:9 overruns:0 frame:0 
          TX packets:166   errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:609078 (609.0 KB)  TX bytes:25460 (25.4 KB)
knr@kannur:~$ netstat -rn

Kernel IP routing table
Destination       Gateway           Genmask           Flags     MSS   Window    irtt    Iface
0.0.0.0           192.168.1.1       0.0.0.0           UG          0 0            0   eth0
169.254.0.0       0.0.0.0           255.255.0.0       U           0 0            0   eth0
192.168.1.0       0.0.0.0           255.255.255.0     U           0 0            0   eth0
192.168.1.0       0.0.0.0           255.255.255.0     U           0 0            0   eth1
    knr@kannur:~$ route

    Kernel IP routing table
    Destination       Gateway           Genmask           Flags  Metric   Ref      Use   Iface
    default           192.168.1.1     0.0.0.0             UG      0        0        0   eth0
    link-local        *                 255.255.0.0       U       1000     0        0   eth0
    192.168.1.0       *                 255.255.255.0     U       0        0        0   eth0
    192.168.1.0       *                 255.255.255.0     U       0        0        0   eth1

  • 1
    What your network topology ? What is connected to eth0, what is connected to eth1 ? What is the network address of your internal LAN ? You have two different ethernet interface belonging to the same network, this is NOT a normal setup. – Benoit Aug 8 '14 at 8:42
  • eth0 is connected to the modem-router and eth1 is the lan interface and i have enables ipv4 forward in sysctl.conf. I am now getting connected to the internet and can ping 192.168.1.1 which is my modem/router. I have client machine with static IP as 192.168.1.10 and gateway as 192.168.1.12 (as that of eth1) . I cannot ping from my server to client and vice-versa. – kannuruser Aug 8 '14 at 10:11
2

Well, you have two different network interfaces connecting the same subnet (192.168.1.0) used by not directly connected devices (your router on one side and the internal LAN on the other side).

So it is normal that it is not functioning right away.

Eth0 is the first listed interface and the default route for the packet sent by your computer, so all packets sent to any 192.168.1.x address will sent to this interface, so to the router.

The easiest way is to use only one interface of your Linux system, connected to the same hub/switch where the router and the others servers are connected. This way, you can still use 192.168.1.x addresses everywhere. The router must be the default gateway of all servers.

If you really want to keep the things separated (router on one side and servers on the other side, your Linux machine acting as a gateway in-between), you'll have to configure two different subnet.
Let's keep eth0 as it is now (192.168.1.0 with 255.255.255.0 subnet mask).
But you'll have to put the eth1 and all the servers in another subnet, like 192.168.2.0 with subnet mask 255.255.255.0.
If you give 192.168.2.1 as IP address on eth1, this address must be configured as the default gateway of all your internal servers.
Also, you'll have to enable IP forwarding on Linux, which you already done.

| improve this answer | |
  • Ip Forwarding is only necessary for routing. So if you want the router and the server-lan truly separated you should NOT activate ip_forward. Having the routes to both nets would be enough. the downside: the server has no internet access at all, of course. p.s.: no switch needed, just use lan cable on both cards pc --> server – s1mmel Mar 22 '16 at 15:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.