Tags:
create new tag
, view all tags
I set up my first modem under Linux (on Jen's spare machine). Using Mandrake 8.1 and setting it up during the (expert) install, it was easy. I ran into one problem that wasn't strictly a modem setup problem -- I set up two interfaces to the Internet (during the install) -- one via the modem, and one via the gateway on my local LAN. After problems pinging things like the nameserver at my ISP, I checked the routing table and realized it was wrong -- the default route went via the gateway on my local LAN, which will be fine when I am connected to the LAN, but doesn't work over the modem connection.

I actually edited the routing table and I am now writing this page from that machine over the modem. smile

This page is to document what I did and record a question -- what must I do to set up something like two hardware configurations and have an easy means to switch between them? I want to choose the modem connection or the LAN connection, and have everything set up properly accordingly (e.g., a proper routing table for each case).

At some point in time I would expect to pick a better name for this page.

See AboutThesePages.

Contents

How I Found the Problem

With the modem connection established (I clicked on the Internet Icon on the desktop and "followed my nose"), I did some pinging:

  • ping to www.fast.net -- unsuccessful
  • ping to local interface ip -- successful
  • ping to remote interface ip -- successful
  • ping to ISP's DNS -- unsuccessful
  • switched to root and tried traceroute to the same locations -- similar results, often very slow
  • typed "route" to view the routing table
  • noticed that the last line of the routing table referred to my LAN gateway (I also noticed that it took quite a while for the routing table to displayed -- I suspect it does something like try the route before displaying the table -- when I fixed the table it was displayed much quicker):

[root@home jen]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
209.92.5.71     *               255.255.255.255 UH    0      0        0 ppp0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         192.168.0.10    0.0.0.0         UG    0      0        0 eth0

How I Modified the Routing Table

  • Looked at the man page for route
  • Deleted the bad route using route del default
  • Ran route again to confirm the incorrect route was gone.
  • Added a valid default route using route add -net default netmask 0.0.0.0 dev ppp0
  • The routing table now looks like this, and I can surf the net:

[root@home jen]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
maxtnt01.abepa. *               255.255.255.255 UH    0      0        0 ppp0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         *               0.0.0.0         U     0      0        0 ppp0

How do I set up Two Hardware Configurations

Repeating the Question: What must I do to set up something like two hardware configurations and have an easy means to switch between them? I want to choose the modem connection or the LAN connection, and have everything set up properly accordingly (e.g., a proper routing table for each case).

Answer: Two suggestions (actually a few more) have been put forward:

Use Linuxconf

Linuxconf exists under Mandrake, and might do the job. It's not immediately obvious that it can actually change the routing tables -- it seems more focused on preserving and restoring versions of configuration files as stored under /etc. I have to do some more digging.

Use a Script

Here's a script written by Linc Fessenden, with a few modifications by me. As I think about it, I suspect that the routing table can gradually get crufty, so I may actually want to delete all the old routes and then insert the specific new routes I need. One route is established when the modem gets an IP during the connection "dialog" -- I guess that's the cruft I was worried about building up -- does something in the connection dialog automatically remove old invalid routes from previous dialup connections? Guess I'll have to pay attention and see.

This is Linc's script (originally aimed at switching resolv.conf), I (and Linc) have now added route commands, and, for the present, I don't have to switch resolv.conf.

Make a resolv.conf file for your ethernet network called resolv.eth with the correct DNS settings and another for your modem called resolv.modem with your dial-up DNS info in it - both created in the /etc directory. After that, write a quickie script something like this and put it in your roots bin directory...

#/bin/sh 
# Lets call this script dnswitch 
clear 
echo "DNSwitch Menu" 
echo 
echo " 1 Switch DNS to Ethernet Settings" 
echo " 2 Switch DNS to Modem Settings" 
echo " 3 Exit" 
echo 
echo "Please enter your numeric choice followed by  " 
read answer 
case "$answer" in 
1) 
cp /etc/resolv.eth /etc/resolv.conf 
;; 
2) 
cp /etc/resolv.modem /etc/resolv.conf 
*) 
clear 
;; 
esac 
exit 0 

Just make the above script executable and then whenever you need to, su to your root user and run it to change your settings.... Hope this helps.

I haven't worked out the route commands entirely yet, but here is the beginning:

On switching to modem:

  • route del default
  • route add -net default netmask 0.0.0.0 dev ppp0

On switching to LAN:

  • route del default
  • route add -net default gw 192.168.0.10 netmask 0.0.0.0 dev eth0 (haven't tested this one yet)

Additional words from Linc:

and then have it start your PPP script up and create an icon to start the whole thing from your preferred gui (if you must).

Contributors

  • RandyKramer - 21 Feb 2002
  • Linc Fessenden, FaberFedor, Dann Washko
  • <If you edit this page, add your name here, move this to the next line>
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2002-02-21 - RandyKramer
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look