Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
08-19-2009, 12:31 PM
|
#1
|
Member
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147
Rep:
|
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? 
|
|
|
08-19-2009, 12:36 PM
|
#2
|
Member
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110
Rep:
|
Use a different subnet to talk to eth0 and eth1
You could configure 192.168.0.* to eth0 and 192.168.1.* to eth1
|
|
|
08-19-2009, 12:47 PM
|
#3
|
Member
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147
Original Poster
Rep:
|
Quote:
Originally Posted by wolfperkins
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.
|
|
|
08-20-2009, 02:18 PM
|
#4
|
Member
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110
Rep:
|
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.
|
|
|
08-21-2009, 04:31 AM
|
#5
|
Member
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147
Original Poster
Rep:
|
Quote:
Originally Posted by wolfperkins
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.
|
|
|
08-24-2009, 06:54 AM
|
#6
|
Member
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110
Rep:
|
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.
|
|
|
08-24-2009, 07:12 AM
|
#7
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Add a host route for 192.168.1.6 that uses the eth0 device.
|
|
|
08-24-2009, 09:37 AM
|
#8
|
Member
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147
Original Poster
Rep:
|
Good ideas
Thanks, guys. Maybe I'll check out today if work allows 
|
|
|
08-25-2009, 07:10 AM
|
#9
|
Member
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147
Original Poster
Rep:
|
Stumped!
Quote:
Originally Posted by jschiwal
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 07:47 AM.
Reason: Add more questions
|
|
|
08-25-2009, 07:30 AM
|
#10
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
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
|
|
|
08-25-2009, 09:10 AM
|
#11
|
Member
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110
Rep:
|
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.
|
|
|
08-25-2009, 10:09 AM
|
#12
|
Member
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147
Original Poster
Rep:
|
Quote:
Originally Posted by wolfperkins
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?
|
|
|
08-26-2009, 03:06 AM
|
#13
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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 03:08 AM.
|
|
|
08-26-2009, 03:22 AM
|
#14
|
Senior Member
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
|
Quote:
Originally Posted by fopetesl
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
|
|
|
08-26-2009, 06:23 AM
|
#15
|
Member
Registered: Jan 2005
Location: Yorkshire Dales, UK
Distribution: Ubuntu 5.10; Mandriva 2007; Debian Lenny
Posts: 147
Original Poster
Rep:
|
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? 
|
|
|
All times are GMT -5. The time now is 05:44 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|