eth0 fixed IP. eth1 DHCP gateway. Need access to eth0
Linux - NetworkingThis 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.
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.
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?
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
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.
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.
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?
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.