LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   I have two working ethernet interfaces, but I can't host services like SSH, HTTP, etc (https://www.linuxquestions.org/questions/linux-networking-3/i-have-two-working-ethernet-interfaces-but-i-cant-host-services-like-ssh-http-etc-834766/)

feci 09-27-2010 11:28 AM

I have two working ethernet interfaces, but I can't host services like SSH, HTTP, etc
 
Hello all,

I have a quite interesting problem which I can't sort out by myself. Hopefully some of you have the necessary knowledge to help me out.

I have two NIC's configured this way:

feci@GEP0:/$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:1c:c0:2e:2d:94
inet addr:192.168.0.198 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::21c:c0ff:fe2e:2d94/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82565 errors:0 dropped:0 overruns:0 frame:0
TX packets:368242 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6459359 (6.4 MB) TX bytes:537036996 (537.0 MB)
Memory:e0500000-e0520000

eth1 Link encap:Ethernet HWaddr 00:40:f4:cf:84:d9
inet addr:192.168.2.108 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::240:f4ff:fecf:84d9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:328585 errors:0 dropped:0 overruns:0 frame:0
TX packets:273488 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:222918691 (222.9 MB) TX bytes:41672368 (41.6 MB)
Interrupt:18 Base address:0x1000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:39845 errors:0 dropped:0 overruns:0 frame:0
TX packets:39845 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:40634426 (40.6 MB) TX bytes:40634426 (40.6 MB)

ppp0 Link encap:Point-to-Point Protocol
inet addr:79.114.41.24 P-t-P:10.0.0.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:314667 errors:0 dropped:0 overruns:0 frame:0
TX packets:267921 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:214503260 (214.5 MB) TX bytes:35101671 (35.1 MB)

eth0 is on my local network, connected to a router, configuration is set to DHCP (but practically I receive the same IP from the router, because of DHCP reservation).

eth1 is plugged into a cable modem and ppp0 works over this connection. eth1 is also set to DHCP, but it's IP can change from time to time.

For surfing the internet I normally use eth1, so the default gateway and nameserver configuration come from eth1.

For the second part I also have some services which I would like to expose to the internet, but only via the eth0 interface (through the router). Port forwarding (or Virtual Servers as they are called on my D-Link) are working correctly and I can say this because the services are accessible if eth1 is shut down.
However when both interfaces are up my services on eth0 are invisible from outside the router.

My theory about what is happening is the following, lets take SSH in this example:
If a connection is attempted on the ssh port my router will forward the packet to ssh on eth0 (this works because I can see the connection attempt in the ssh log in real-time), however I think that because eth1 is the default route ssh will respond on eth1 to the packet received on eth0. For this reason the router on the client or the firewall will reject response because there is no active connection between my machine's eth1 and the client (the connection is between my eth0 and the client).

The question is whether there is a solution for the problem?
Any help is appreciated.
Thanks

Nemesiz 09-27-2010 11:36 AM

ip r or netstat -r will be great. I think your problems is default gateway. Packet is coming to eth0 but the reply is send back by eth1. You must set route table.

feci 09-27-2010 11:56 AM

Hello Nemesiz,
thank you for the fast reply,


feci@GEP0:/$ ip r
10.0.0.1 dev ppp0 proto kernel scope link src 79.114.41.24
192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.2.108
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.198
169.254.0.0/16 dev eth0 scope link metric 1000
default dev ppp0 scope link
default via 192.168.0.1 dev eth0 metric 100

feci@GEP0:/$ netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.0.0.1 * 255.255.255.255 UH 0 0 0 ppp0
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
default * 0.0.0.0 U 0 0 0 ppp0
default router 0.0.0.0 UG 0 0 0 eth0

Nemesiz 09-28-2010 02:10 PM

http://linux-ip.net/html/routing-tables.html

Can you do one trick? Open two consoles and enter:

Console1:
tcpdump -n -i eth0 host IP_ADDRESS

Console2:
tcpdump -n -i eth1 host IP_ADDRESS


IP_ADDRESS - external computer which will try to test your www or other service through router (eth0). You will see is the reply sends back through the same eth device.


All times are GMT -5. The time now is 08:55 AM.