Linux networking - argh!

  • July 3, 2005 4:27 PM BST
    I suspect that setting the Kernel IP Forwarding rule (echo "1" > /proc/sys/net/ipv4/ip_forward) may have been all that was required to get it working. It is the most critical setting, the one which determines if the system acts as a router/gateway or not. It doesn't matter how well configured the rest of my system is, if I flick off that flag the LAN is instantly cut off from the internet, flick it back on and everything comes back to life. That rule doesn't care about network interfaces and what type they are, it acts at the IP protocol level.
  • June 21, 2005 1:16 PM BST
    OK, It's not often anybody will see me asking for technical help with computrs, but this is really driving me nuts.

    I have (as sent by my ISP(s)) three globespan chipset modems - being the bt voyager, bt voyager 100 and th bt voyager 105 which are all USB ADSL modems. Sadly, at this time I cannot afford a router as all the shops around here seem only to seel Netgear ones for around £70 - I'm not paying for a name anyway. I just want a simple two or more port ADSL router which if I had a credit card I could get for £30! SO, I'm stuck with a usb modem.

    I've just installed Linux, and so now my machine quite happily dual boots with XP and Fedora Core 4. To get an internet connection on Fedora, I need to install the ECIADSL dirver (eciadsl.flashtux.org) v 0.0.10-1. This is not a problem at all.

    However, My housemate runs an XP box, and mine shares it's internet connection. In other words, for mwe to start using linux again, I have to network my linux box with XP to share it's connection. The problem here is that past experience is thelling me that when configuring 'eth0', I loose the ability to resolve IP addresses on the internet for some reason.

    It's all a little confusing and dare I say daunting. Can anybody tell me if what I'm seeking to do is poissible, and if so, exactly how I go about it?
    • 338 posts
    June 21, 2005 6:44 PM BST
    I've done this the other way round, Linux having the net lik and XP talking to it.

    suscess with XP having the netlink is patchy to say the least.

    XP insists on changing the network cards address when it goes on line, not 100% sure to what, but it is consistent, i thnk it *should* be a matter of manually setting up the linux box to use the XP machines IP addy as the 'default gateway' and setting up one or two DNS manually.

    troulbe tends to result from the fact that XP don't run a DHCP server, thus ya in manual mode.



    *-----------* eth0 192.168.100.1
    | Linux Box |------| *--------* Modem (DHCP)
    *-----------* |------| XP Box |--------> Internet
    eth0 x.x.x.x *--------*



    So you let XP do whatever it likes, but give the linux box a fixed IP (i use the one above) the XP box will have a fixed IP for its link to the linux machine, they should be able to ping each other now.

    To fire the internet up point the linux boxes 'default gateway' to whatever windows sets x.x.x.x to, and copy down the DNS addresses for the internet provider from the windows config dialogs, restart eth0 on the linux box and you should be away (maybe a reboot to ensure everything fires up).

    the hard part is physically getting the two to talk to each other, once they can 'ping' it should be easy.

    know how you feel about a router... i use an old P-II and a 5 port hub to do the same job... oh yes and a firewall as well.

    had no ed of trouble with ADSL modems though, here linux isn't going to have a clue if the link is live or not, so keep an eye on it manually. I think XP should attempt to restart it if required, but here it pops a flipping dialog up every time.
  • June 21, 2005 7:23 PM BST
    LOL. sorry if I was unclear or made a mistake.

    Its Linux that I want to have the net (My machine at this moment), and the XP box across the room to be the network 'slave' (to take the internet connection from the linux box).

    I'm using the bog-standard BT Voyager ADSL USB modem, which on it's own runs fine with the eciadsl driver in fedora. As soon as I tried setting the eth0 settings though I lost all ability to resolve addresses. The modem stayed in synch though, so I'm assuming there was still a connection available - either linux didn't recognise it or lost the ability to resolve domain names.

    The only way I could fix it was re-installing fedora, simply because I didn't know how. Networking in linux is something I've never done before, let alone networking with an XP box.

    Luckily, I don't have to use DHCP on the linux box for the internet, as I have a static IP (). However, because it's a USB modem, Linux doean't seem to see it as a network device, and so I don't even know if the OS is acctualy aware that it has an intenet connection if you see my meaning?
  • June 22, 2005 10:58 PM BST
    I have no experience with USB modems, I have only ever used Ethernet. If the Ethernet NIC which connects to your LAN is eth0 does the USB modem show up as eth1? When you say that you loose the ability to do DNS resolution after configuring eth0 using ifconfig, do you also loose the ability to make connections altogether? I.E. can you still make connections using IP addresses directly? Try ping'ing your ISP's DNS server using its IP address when this happens. It is possible that after using ifconfig the routing tables are flushed out, thus you have no routing entry to your ISP's Gateway anymore, I'm not sure.

    I have a dedicated box which acts as my Gateway/Firewall/IDS. It has two Ethernet NIC's, eth0 is the LAN NIC which is connected to a switch and eth1 is connected to the Cable Modem. I have a couple of client boxes on the LAN (1 Linux, 1 XP) which are connected to the Gateway through the switch.

    My LAN works on the 10.10.10.xxx range.
    My Gateway box is 10.10.10.1.
    My Linux and XP client boxes are 10.10.10.2 and 10.10.10.3 respectively.
    My ISP's DNS name servers are 194.168.4.100 and 194.168.8.100.
    My external IP address is dynamic (kinda) but currently in the region of 81.xxx.102.xxx.
    My ISP's Gateway is 81.xxx.102.254

    Sorry I have masked some of them, but you get the idea.

    OK, the easy part, configuring the clients boxes. I set the Default Gateway to 10.10.10.1 and two DNS name server entries directly to the DNS IP address above, thats it.

    On the Gateway box eth0 (LAN) and eth1 (Cable Modem) are configured as below:

    eth0 Link encap:Ethernet HWaddr 004:75:75:9E1
    inet addr:10.10.10.1 Bcast:10.10.10.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

    eth1 Link encap:Ethernet HWaddr 004:75:D7:5C:76
    inet addr:81.xxx.102.xxx Bcast:255.255.255.255 Mask:255.255.255.0
    UP BROADCAST NOTRAILERS RUNNING MTU:1500 Metric:1

    As well as the IP addresses, you need to make sure that your BroadCast (Bcast - above) and NetMask (Mask - above) ranges are correct. For your LAN NIC the BroadCast address is usually <Your>.<IP>.<Range>.255 (follow example above) and the NetMask is usually 255.255.255.0. I am not sure for your external interface.

    Now you need to configure the routing entries to make it all work (mine are below as an example):

    Destination Gateway Genmask Flags Iface
    81.xxx.102.0 0.0.0.0 255.255.255.0 U eth1
    10.10.10.0 0.0.0.0 255.255.255.0 U eth0
    0.0.0.0 81.xxx.102.254 0.0.0.0 UG eth1

    To view the routing table entries use the command 'route -nv'. The 'man route' command will help too

    This shows that any traffic destined for any network address in the range of 81.xxx.102.0 (the 0 on the end means all address from 1 to 254) will be routed through interface eth1 (Cable Modem).

    Any traffic destined for any network address in the range of 10.10.10.0 (same applies to the 0 again) will be routed through interface eth0 (LAN).

    When network traffic comes in the kernel scans the routing tables from top to bottom until a route is found (if no route is found a 'no_route_to_host' error is returned). So the final entry in our list is the Default Gateway. This is like a 'catch all' entry which says if no other direct route to a host has been found send the traffic to the Gateway 81.xxx.102.254 through the eth1 (Cable Modem) interface. It is this entry which makes the box act as a Gateway.

    To create the routing entries for my setup (change to suite your own IP address) you would issue the following commands:

    route add -net 81.xxx.102.0 netmask 255.255.255.0 dev eth1
    route add -net 10.10.10.0 netmask 255.255.255.0 dev eth0
    route add default gw 81.xxx.102.254 dev eth1

    Finally you need to setup DNS name servers on your Linux box. This is configured in the '/etc/resolv.conf' file (man resolv.conf). Mine looks like this:

    nameserver 194.168.4.100
    nameserver 194.168.8.100

    It simply specifies the address of the DNS server(s) to use.

    If your USB modem doesn't show up as an interface in ifconfig, then I haven't got a clue how it works :/ hehe.

    I hope this helps and isn't just completely confusing. If it doesn't help maybe you could post the output from the ifconfig and 'route -nv' commands and the contents of /etc/resolv.conf from your box.
  • June 23, 2005 8:54 AM BST
    I forgot to mention one last step. You will need to ensure that IP Forwarding is enabled in the Kernel. IP Forwarding is the Kernel setting which allows traffic to pass from one interface to another, which is essential for the box to act as a Gateway. You can check if it is enabled or not by going to the '/proc/sys/net/ipv4' directory and looking for a file named 'ip_forward'. This file should contain simply a 1 or a 0, indicating if IP Forwarding is enabled or disabled. If it is disabled you can issue the following command to enable it:

    echo "1" > /proc/sys/net/ipv4/ip_forward

    Note: Changing this setting will be lost after a reboot, so you will need to make this happen at boot each time. Depending on your distro there are specific config files to use or you could simple put this in the init scripts - '/etc/rc.d/rc.local' for example.

    I have just realised that if the USB modem does show up in ifconfig at all, it wont appear as an eth<anything> interface as this is to designate an Ethernet device. I am not sure just how the USB networking works, but you would think it must make itself known to the kernel as a networking device. In which case it should show up using the ifconfig command and you should be able to add routes using the 'route' command.

    Note: Some 'special' interfaces won't appear in ifconfig unless you issue the command as follows 'ifconfig -a'. I have a 'special' device on my system called sit0, below:

    sit0 Link encap:IPv6-in-IPv4
    NOARP MTU:1480 Metric:1

    This isn't a real physical device and only shows up using the '-a' argument. It is a virtual device to tunnel IPv6 traffic over an IPv4 link. But if you USB device doesn't show in ifconfig (even when using '-a') then I am really quite out of ideas as this would mean that some tricky work is going on behind the scenes to bypass the normal Kernel networking system.
    • 338 posts
    June 29, 2005 6:23 PM BST
    ok now trying to get my two machines (one xp & one linux) talking to me mums xp box with its internet link...

    with internet sharing on me mums box *off* i can talk to it fine from both of mine, map and share drives via my samba server etc no worries.

    turn internet sharing *on* and the link dies, they can no longer ping each other etc or anything. windows reports the ip of the network card as 192.168.0.1, pinging this from either of my machines times out, pinging any known valid network link from my two also times out (they still talk to each other fine).

    i get the feeling if i allow my xp machine to auto configure it will work, but then not talk to the linux box at all (pity since tis my file server).

    i'm thinking the trouble is the default windows software having a few hardwired settings, which are set to screw up connections outside windows. the cure may be to setup some additional software, trouble is the interface card in this isn't liked by teh beklin software i have.. ARGH! i'm lothed to by a dedicated router to sort this out, it can't be hard since the machines *can* see each other, tis windows internet sharing thats screwed.
    • 338 posts
    June 29, 2005 6:32 PM BST
    ok just found this

    http://support.microsoft.com/kb/306126/

    and as a result of t change a local ip of 192.168.100.2 -> 192.168.0.2 and see if that helps...

    ARGH.. full reconfigure of my server as well.. bugger.
    • 338 posts
    June 29, 2005 7:09 PM BST
    ok partial success

    my linux box has 192.168.0.2 & xp box 192.168.0.3 the m/c with the connecttion is setup as 192.168.0.1 (no options there) the machines can now see each other, as expected this nuked samba, so a reconfigure there.. sigh..

    i can now ping the dns servers of ntl, but for reason or reasons unknown ping works, but not much else does.

    still better than before..
    • 338 posts
    June 29, 2005 7:29 PM BST
    finally...

    I'm now sat using my own machine.

    the two 'keys' were
    1, manually setting up my IP addresses to 192.168.0.2+
    2, configuring my DNS servers manually to te relevent IP (wannado in this case)

    *now* it works

    just gotta get me linux box fully talking to my windows box now... reconfig samba, apache, nis etc... ho hum

    but IT WORKS
  • June 29, 2005 8:48 PM BST
    Hi Clair,

    I am glad that you have it working now, with just a few things left to configure It is nice to see that you are given then freedom to choose your own IP range for your LAN. I would have had the same problem as you, being on 10.10.10.x range. It is a shame you have had to reconfigure your whole LAN IP ranges, and all the services which were using them. Still thats typical M$ they 'think' they are being 'helpful' lol ... they really thought ahead on that one didn't they

    Hugs,

    Katherine xxx
  • June 30, 2005 12:54 AM BST
    lol. Well I managed to buy a cheap 1 p[ort router, and used the USB conection on the XP box, and the ethernet port on the linux.

    Great stuff, apart from one thing.

    If I log onto linux as a normal user, the Router completely drops my connection, but I can log in as root and still access the web.

    What the hey is the point of running linux if you have to use root to browse the web!?!? lol
  • July 3, 2005 12:03 PM BST
    There was no need to do that Rhia, the principals above are sound.
    • 338 posts
    July 3, 2005 12:07 PM BST
    i had that for a while, used to switch to a text console, fire the link up as root, then switch back to actually use the link. turns out it was a file permission thingy. like just about every other problem in linux...

    need to allow user level access to the device, which typically isn't allowed. SuSE creates a group (Dialup) that can fire modems up etc, add that group to the user and you is away. can't be hard to add this to other systems)
  • July 3, 2005 3:27 PM BST
    I'm afraid there was no known interface for the usb modem. it didn't show as eth anything unfortunately. a router was the easiest option.
  • July 3, 2005 6:07 PM BST
    Ah - sorry. I didn't think of it that way. (quite embarrasing really. lol)

    I am glad I got the router though, purely because it now means that my puter doesn't have to be on 24/7 to maintain a connection on the other one
  • July 3, 2005 6:52 PM BST
    My apologies if I seemed a little short with you. I just spent quite a while putting those steps together for you, which seemed to go un-answered. I am glad you have something working now.