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.
I need to configure an ethernet interface, say 'eth0', and give it an IP of 10.1.1.19 with netmask 255.255.255.0
BUT
I need to set the default gw as 192.168.0.1
Whenever I do this with the 'route add default gw 192.168.0.1' command, it fails with:
SIOCADDRT: network is unreachable
I guess it only accepts default gateways that are similar, i.e. 10.1.1.X
In Windows this is straight forward; I just simply use the LAN properties window and play around with the TCP/IP properties to manually set the IP and gateway to whatever values I please and this works smoothly. Here's the output from windows:
What you want is impossible !
With eth0 having 10.1.1.19 you can only acces a 10.1.1. network,
What you can do with routing is program the routing table for a certain network
route add -net 192.168.0.0 netmask 255.255.255.0 gw 10.1.1.1 ( every address starting with 192.168.0 is send to router 10.1.1.1 )
route add default gw 10.1.1.254 the rest is send to 10.1.1.254
I don't think this is gonna work. I need the default route to be sent to the gateway 192.168.0.1
I can't believe how straight forward this is in Windows. Here's the output of the route table from the DOS prompt. Isn't there a way to replicate this table's characteristics with a few 'route add' commands in Linux?
I have to tel you first that this a work around, you can do the following
first add an alias
ifconfig eth0:1 192.168.0.254
route add default gw 169.254.0.1
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.