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 think that you have the hoses hooked up right, but you're pumping the water the wrong direction.
Look at it this way: Iptables enables packets sent from wlan0 to be sent to eth0 or vise versa. It also alters the packets as necessary so that packets sent from wlan0 through eth0 are well formed... but Iptables has no idea which way the internet is located. It's just connecting this pipe to that pipe, and saying 'I"m acting like a router' or 'I'm acting like a switch'. There's absolutely no logic inherent in iptables that says packets headed for the internet need to be sent through wlan0.
That logic lives in the routing tables. In order to print out the routing tables on your server, run the following command:
/sbin/route:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.1 * 255.255.255.255 UH 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 1 0 0 eth0
192.168.1.0 * 255.255.255.0 U 2 0 0 wlan0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
when i disconnect eth0 its going nice and correctly through wlan0 but it should as only connection on the box.
Yeah... that's definitely not right. Your default route is through 192.168.1.1, but it's trying to send that through eth0, even though the 192.168.1.0 subnet is through wlan0. I'm not quite sure how to fix that yet.
/sbin/route:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.1 * 255.255.255.255 UH 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 1 0 0 eth0
192.168.1.0 * 255.255.255.0 U 2 0 0 wlan0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
when i disconnect eth0 its going nice and correctly through wlan0 but it should as only connection on the box.
Ok, I've just been reading through the man pages for route here's what I'm thinking:
First, delete the routes to 192.168.1.1; these are going through the wrong interface.
Code:
route del -host 192.168.1.1
route del default gw 192.168.1.1
Then add them back, correctly:
Code:
route add -host 192.168.1.1 netmask 255.255.255.255 dev wlan0
route add dfault gw 192.168.1.1 netmask 0.0.0.0 dev wlan0
I'm not sure that the first of these two lines is necessary, 192.168.1.1 is in the 192.168.1.0 subnet, and should be routed via
Code:
192.168.1.0 * 255.255.255.0 U 2 0 0 wlan0
Would someone else in the Linux-Networking forum care to check my math here? I don't go changing routing tables on a regular basis. R03L is pretty liberal with the 'thank you button', so it's worth your time
Quote:
Originally Posted by bartonski
Click on the reference to this quote, it will take you back to the post where I attached a PDF of the network configuration
route add -host 192.168.1.1 dev wlan0
route add default gw 192.168.1.1 netmask 0.0.0.0 dev wlan0
but its a temporaroly solution,
i read on this forum when the init scripts get updated rc.local will be cleared?
also when i disconnect from wlan0 i need to reboot for rc.local to be read again.
I think that I would poke around inside network manager and see if there's a check-box or something that says "this is my route to the internet" or something. I'm just guessing,.. if there's not, this is a bug in network manager.
Thanks for working with the route stuff, that was uncharted territory for me... I know how it works on a theoretical level, but I've never had the need or opportunity to actually change the routing. (The one time I did, I was very very new to networking and ended up routing packets back to the network that they came from, doubling the network load... someone else had to trouble shoot that one for me).
Where did you find the info about setting routes in rc.local?
I think that I would poke around inside network manager and see if there's a check-box or something that says "this is my route to the internet" or something. I'm just guessing,.. if there's not, this is a bug in network manager.
There is no check-box inside fedora core 12 NetworkManager say "this is my route to the internet"
I know this is an old thread but it kills me to see people using the rc.local file for this. This is not the right way to do this.
The correct way to add permanent static routes to a system besides setting the default gateway is to create a file /etc/sysconfig/network-scripts/route-eth0 (or whichever interface you want to route through). You can add as many routes as you would like per interface by simply incrementing the number at the end of each statement. Once saved a restart of the network services will force a read of this route file.
The syntax of the file should look like this:
ADDRESS0=x.x.x.x
GATEWAY0=x.x.x.x
NETMASK0=x.x.x.x
ADDRESS1=x.x.x.x
GATEWAY1=x.x.x.x
NETMASK1=x.x.x.x
Enjoy!
Take a look at /etc/sysconfig/network-scripts, and see if route-eth0 and route-wlan0 exist, if they do, look inside and see if each one is configured according the routes that you need. It may be that NetworkManager is reading from these, and that's why your routes are being re-written every time you re-connect to wlan0.
yes im new to setting routes. but thats the seccond point why im interesed in these things. im doing study LPI 1 so im little ahead on my study whit thisone.
yes im new to setting routes. but thats the seccond point why im interesed in these things. im doing study LPI 1 so im little ahead on my study whit thisone.
Yes, I think that you need to add route-wlan0, and I think that you'll have to edit route-eth0.
I'd like to see route-eth0, partly because I'm running a Debian system that doesn't use that file, and I'm curious to see it, and partly because it might be useful.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.