LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-19-2009, 11:31 AM   #1
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Rep: Reputation: 15
Question 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?
 
Old 08-19-2009, 11:36 AM   #2
wolfperkins
Member
 
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110

Rep: Reputation: 16
Use a different subnet to talk to eth0 and eth1

You could configure 192.168.0.* to eth0 and 192.168.1.* to eth1
 
Old 08-19-2009, 11:47 AM   #3
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Question

Quote:
Originally Posted by wolfperkins View Post
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.
 
Old 08-20-2009, 01:18 PM   #4
wolfperkins
Member
 
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110

Rep: Reputation: 16
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.
 
Old 08-21-2009, 03:31 AM   #5
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Exclamation

Quote:
Originally Posted by wolfperkins View Post
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.
 
Old 08-24-2009, 05:54 AM   #6
wolfperkins
Member
 
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110

Rep: Reputation: 16
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.
 
Old 08-24-2009, 06:12 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Add a host route for 192.168.1.6 that uses the eth0 device.
 
Old 08-24-2009, 08:37 AM   #8
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Wink Good ideas

Thanks, guys. Maybe I'll check out today if work allows
 
Old 08-25-2009, 06:10 AM   #9
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Angry Stumped!

Quote:
Originally Posted by jschiwal View Post
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 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.

Last edited by fopetesl; 08-25-2009 at 06:47 AM. Reason: Add more questions
 
Old 08-25-2009, 06:30 AM   #10
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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
 
Old 08-25-2009, 08:10 AM   #11
wolfperkins
Member
 
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110

Rep: Reputation: 16
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.
 
Old 08-25-2009, 09:09 AM   #12
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Question

Quote:
Originally Posted by wolfperkins View Post
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?
 
Old 08-26-2009, 02:06 AM   #13
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.

Last edited by jschiwal; 08-26-2009 at 02:08 AM.
 
Old 08-26-2009, 02:22 AM   #14
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by fopetesl View Post
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
 
Old 08-26-2009, 05:23 AM   #15
fopetesl
Member
 
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147

Original Poster
Rep: Reputation: 15
Thumbs down 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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I tell my server to use eth0 for the internet [DNS + gateway] in stead of eth1 elvisious Linux - Networking 1 02-14-2009 05:53 PM
Eth0 using DHCP and eth1 using static ip: eth0 receive internal ip not the router ip geraldomanaus Linux - Networking 3 04-23-2008 03:00 PM
eth0, eth1, dhcp, slackware 11 problem q3noob Slackware 5 07-31-2007 09:26 AM
Dhcp eth0 and XP eth1 internet sharing props666999 Slackware 8 08-20-2005 09:48 AM
How do I set the ip address for eth0, eth1 and the default gateway? abefroman SUSE / openSUSE 5 05-19-2005 04:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration