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 00
4:75:75:9E
1
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 00
4: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.