Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Can i use multiple gateways in Linux just like in Windows? I´m new in Linux,
and I love it because I can use aliases to my IP address. Windows can´t (I think),
but it can use multiple gateways.
My computer IP is 192.168.2.253, and the gateway at the factory is 192.168.2.3,
and sometimes I have to go to the main office, and their gateway is 192.168.1.3,
so I made alias to the real IP with 192.168.1.253. Therefore, with Linux,
I don´t have to change my IP address, but too bad I have to change the gateway
in my computer.
ifconfig eth0:0 192.168.1.253
ifconfig eth0:1 192.168.2.253
route add default gw 192.168.2.3 via dev eth0
route add default gw 192.168.1.3 via dev eth0
The first two lines set up ip alias so that your eth0 interface can see both 192.168.1/2 networks, and the second two add a new default gateway for each network segment. It may sound counter-intuitive but you can in fact have more than one default gateway; this becomes clear once you realise that they're in different subnets. See mine:
Code:
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
10.0.0.0 * 255.0.0.0 U 0 0 0 wlan0
loopback * 255.0.0.0 U 0 0 0 lo
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 1 0 0 eth0
I hope I haven't made any stupid mistakes...it's been a rough evening.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.