LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   eth0 fixed IP. eth1 DHCP gateway. Need access to eth0 (https://www.linuxquestions.org/questions/linux-networking-3/eth0-fixed-ip-eth1-dhcp-gateway-need-access-to-eth0-748764/)

fopetesl 08-19-2009 11:31 AM

eth0 fixed IP. eth1 DHCP gateway. Need access to eth0
 
5.10 Breezy configured as machine controller. Works great
eth0 is a fixed IP to communicate with controller comms board.
Not easy at all to alter - the comms board is hard coded to listen on eth0 for commands.

I can use eth1 as the default gateway and ping google.com, etc.

But when I now attempt to communicate with the controller with netcat, e.g.
Code:

echo !HH | nc 192.168.1.6 80
I obviously never get an answer since the request is passed via eth1.

Using the -g option with netcat doesn't work either.

I had a look at iptables but it doesn't seem to be able to do what I want.

How I can still use eth0 as my communication port to the controller whilst eth1 is the default gateway? :scratch:

wolfperkins 08-19-2009 11:36 AM

Use a different subnet to talk to eth0 and eth1

You could configure 192.168.0.* to eth0 and 192.168.1.* to eth1

fopetesl 08-19-2009 11:47 AM

Quote:

Originally Posted by wolfperkins (Post 3649649)
Use a different subnet to talk to eth0 and eth1

You could configure 192.168.0.* to eth0 and 192.168.1.* to eth1

Explain "subnet", please.

Presently eth0 is fixed at 192.168.1.20.

eth1 is DHCP as Default Gateway.
Since I won't have access to the DHCP Server I cannot alter this.

wolfperkins 08-20-2009 01:18 PM

The network traffic cannot be easily routed to both interfaces. This is definitely not a simple setup.

There are many web sites that will explain TCP/IP subnets (google the words as a starter) and how they are used.

fopetesl 08-21-2009 03:31 AM

Quote:

Originally Posted by wolfperkins (Post 3651193)
The network traffic cannot be easily routed to both interfaces. This is definitely not a simple setup.

There are many web sites that will explain TCP/IP subnets (google the words as a starter) and how they are used.

I don't need to route. All I need is to be able to communicate explicitly with eth0 which has no other connection to anywhere except the controller.

eth1 is required so that I can ssh into it from the Web.

wolfperkins 08-24-2009 05:54 AM

You are routing as soon as you have multiple interfaces. Your system needs a way to determine which interface to send the traffic onto based on destination ip address (and it does this by subnet). netstat probably reports to you that 192.168.1.0 is sent to eth1.

What is the destination ip address of your controller accessible through eth0?

You will need to set some manual routing such that
- 192.168.1.1 through 192.168.1.(controller's ip - 1) goes through eth1
- 192.168.1.(controller's ip) goes through eth0
- 192.168.1.(controller's ip + 1) goes through eth1

You should look at the "route add" command.

jschiwal 08-24-2009 06:12 AM

Add a host route for 192.168.1.6 that uses the eth0 device.

fopetesl 08-24-2009 08:37 AM

Good ideas
 
Thanks, guys. Maybe I'll check out today if work allows :)

fopetesl 08-25-2009 06:10 AM

Stumped!
 
Quote:

Originally Posted by jschiwal (Post 3655312)
Add a host route for 192.168.1.6 that uses the eth0 device.

I looked through "route add" and tried several different commands and although
Code:

route add -net default gw 192.168.1.6 dev eth0
seems to work it adds a wired route "christravel" to the routing table and scraps everything: no internet and no connection to 192.168.1.6.
Existing:
Code:

root@machine:/home/Peter# route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.1.0    *              255.255.255.0  U    0      0        0 eth1
192.16.1.0      *              255.255.255.0  U    0      0        0 eth0
default        2WIRE133        0.0.0.0        UG    0      0        0 eth1
root@machine:/home/Peter#

also
Code:

root@machine:/home/Peter# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:30:BD:70:34:12
          inet addr:192.16.1.20  Bcast:192.16.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:11 Base address:0xe000

eth1      Link encap:Ethernet  HWaddr 00:40:63:DE:CF:BF
          inet addr:192.168.1.38  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1618 errors:0 dropped:0 overruns:0 frame:0
          TX packets:861 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:667102 (651.4 KiB)  TX bytes:170260 (166.2 KiB)
          Interrupt:10 Base address:0xdc00

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:109 errors:0 dropped:0 overruns:0 frame:0
          TX packets:109 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:156000 (152.3 KiB)  TX bytes:156000 (152.3 KiB)

root@machine:/home/Peter#

So it must be my bad syntax :doh: but where?

BTW, why would I need a gateway for a fixed IP when traffic never leaves the computer?

Same question for "broadcast" and "network" settings.

EricTRA 08-25-2009 06:30 AM

Hi,

Don't know if it's an option for you but you could just configure a second IP (static) on the eth1 card that's in the range of the eth0. That way they can communicate with one another.

Have a look at this Debian Networking guide. In the middle of the page are the commands/files to run/edit.

Kind regards,

Eric

wolfperkins 08-25-2009 08:10 AM

Is there any way you can change the controller's ip address from 192.168.1.6 to 192.168.0.6?
If so, then assign a 192.168.0.* ip address to eth0 and you will be able to reach both with no further headaches.

BTW, your route command indicates a typo as it reports traffic for 192.16.1.0 going to eth0.

fopetesl 08-25-2009 09:09 AM

Quote:

Originally Posted by wolfperkins (Post 3656719)
Is there any way you can change the controller's ip address from 192.168.1.6 to 192.168.0.6?
If so, then assign a 192.168.0.* ip address to eth0 and you will be able to reach both with no further headaches.

BTW, your route command indicates a typo as it reports traffic for 192.16.1.0 going to eth0.

I could change 192.168.1.6 to 192.168.0.6 but it would take a little work and break older controllers communication, (there a a few), should I ever upgrade the PC software.

I don't know how, when or where the 192.16.1.0 address has come from. I certainly didn't add it to the routing table.
I guess if I could edit this routing information it might just solve my problem but just where is this information stored?

jschiwal 08-26-2009 02:06 AM

Look at "man routes". The location of the routes file should be indicated in the synopsis at the top. Probably /etc/sysconfig/network/routes or /etc/sysconfig/networking/routes.

The routes are probably set up at boot by a script, which reads the routes file. There may be a script in /etc/init.d/ which runs the script as a startup service.
Code:

NAME
      routes - configure the routing table

SYNOPSIS
      /etc/sysconfig/network/routes
      /etc/sysconfig/network/ifroute-*

When you configure a device, using your distro's wizard, doing so may edit the routes file. Sometimes there is a tab where you can add a route or a box you can click to enable routing. Also look at "man sysctrl.conf". This is a file that contains sysctrl settings made at boot, such as enabling ipv4 forwarding. You may need the nf_conntrack module enabled for forwarding to work. I had to do this on my old laptop to forward traffic from my desktop to wireless when my desktop didn't have wireless.

zhjim 08-26-2009 02:22 AM

Quote:

Originally Posted by fopetesl (Post 3656599)
I looked through "route add" and tried several different commands and although
Code:

route add -net default gw 192.168.1.6 dev eth0
seems to work it adds a wired route "christravel" to the routing table and scraps everything: no internet and no connection to 192.168.1.6.

When you take a close look the route add command for sure kills your inet connection. Reason you are adding a default route. Also when come to think about you don't need to add a -net. you want to add a host.

So no boot script or similar.
Try something like this

Code:

route add -host 192.168.1.6 dev eth1
and you should be set. Just make sure that you revert back to the working state before doing so.

Heres the listing of route from a host of mine
Code:

Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
10.0.0.5        *              255.255.255.255 UH    0      0        0 vif1.0
10.0.0.1        *              255.255.255.255 UH    0      0        0 vif4.0
10.0.0.2        *              255.255.255.255 UH    0      0        0 vif3.0
localnet        *              255.255.255.0  U    0      0        0 eth0
default        192.168.1.1    0.0.0.0        UG    0      0        0 eth0


fopetesl 08-26-2009 05:23 AM

One step forward. Two steps back..
 
Thanks, guys :) but I'm getting nowhere fast. Have a look at this:
Code:

root@machine:/home/Peter# route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.1.0    *              255.255.255.0  U    0      0        0 eth1
192.16.1.0      *              255.255.255.0  U    0      0        0 eth0
default        2WIRE133        0.0.0.0        UG    0      0        0 eth1
root@machine:/home/Peter# route add -host 192.168.1.6 eth0
root@machine:/home/Peter# route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
christravel    *              255.255.255.255 UH    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    0      0        0 eth1
192.16.1.0      *              255.255.255.0  U    0      0        0 eth0
default        2WIRE133        0.0.0.0        UG    0      0        0 eth1
root@machine:/home/Peter# man routes
No manual entry for routes
root@machine:/home/Peter# man route
.
.
.
FILES
      /proc/net/ipv6_route
      /proc/net/route
      /proc/net/rt_cache
.
root@machine:/home/Peter# cat /proc/net/ipv6_route
cat: /proc/net/ipv6_route: No such file or directory
root@machine:/home/Peter# cat /proc/net/route
Iface  Destination    Gateway        Flags  RefCnt  Use    Metric  Mask  MTU      Window  IRTT
eth0    0601A8C0        00000000        0005    0      0      0      FFFFFFF0
eth1    0001A8C0        00000000        0001    0      0      0      00FFFFF0
eth0    000110C0        00000000        0001    0      0      0      00FFFFF0
eth1    00000000        0101A8C0        0003    0      0      0      00000000
root@machine:/home/Peter# cat /proc/net/rt_cache
Iface  Destination    Gateway        Flags          RefCnt  Use    Metric Source          MTU    Window  IRTT    TOS    HHRef  HHUptod SpecDst
lo      2601A8C0        2601A8C0        84000000        0      1      0      0101A8C0 0      0      0      00      -1      0      2601A8C0
root@machine:/home/Peter# route add -host 192.168.1.6 dev eth1
root@machine:/home/Peter# route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
christravel    *              255.255.255.255 UH    0      0        0 eth1
christravel    *              255.255.255.255 UH    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    0      0        0 eth1
192.16.1.0      *              255.255.255.0  U    0      0        0 eth0
default        2WIRE133        0.0.0.0        UG    0      0        0 eth1
route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
christravel    *              255.255.255.255 UH    0      0        0 eth1
christravel    *              255.255.255.255 UH    0      0        0 eth0
192.168.1.0    *              255.255.255.0  U    0      0        0 eth1
192.16.1.0      *              255.255.255.0  U    0      0        0 eth0
default        2WIRE133        0.0.0.0        UG    0      0        0 eth1

root@machine:/home/Peter# ping 192.168.1.6
PING 192.168.1.6 (192.168.1.6) 56(84) bytes of data.

--- 192.168.1.6 ping statistics ---
14 packets transmitted, 0 received, 100% packet loss, time 12997ms

root@machine:/home/Peter# echo !HH | nc 192.168.1.6 80
bash: !HH | nc 192.168.1.6 80: event not found
root@machine:/home/Peter#

I assumed zhjim had made a typo with eth1 so tried with eth0 first then later added eth1. Didn't make any difference either way.
Didn't find any routes file either - that makes any sense.
Still puzzled where "christravel" appears from - only Chris I know has trouble with an abacus.

Where to bang my head against now? :banghead:


All times are GMT -5. The time now is 01:17 AM.