Server networking problem

Asked by HelgeB

I have a Ubuntu 8.1 workstation connected via cable to a router again connected via cable to an adsl modem.
This configuration works without problem, I'm connected to the internet.
Then I add an Ubuntu server, no Gui interface only character based. This server has 2 network cards, eth0 cabled to the ADSL modem and eth1 cabled to the router. With this configuration, the workstation is not able to get out on the net, it can only access other devices within the routers domain, i.e a web camera and also the server. The server can be accessed thru Putty and also sftp and ftp.
From the server, there is still access to the internet. I can ping any domain. Also, I can access the workstation from the server and also other devices on the internal network.
I have read all how to's and also browsed the net for similar problems, but cannot find any solution. I have also installed dhcp3 but that did not make any change.
Below is some information on how I have configured the server. Hope someone is able to give me a hint of how to solve my problem.

/etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

auto eth1
 iface eth1 inet static
 address 192.168.2.2
 netmask 255.255.255.0
 broadcast 192.168.2.255

# The primary network interface

auto eth0
 iface eth0 inet static
 address 192.168.1.33
 netmask 255.255.255.0
 gateway 192.168.1.1
 network 192.168.1.0
 broadcast 192.168.1.255

Output from ifconfig
eth0 Link encap:Ethernet HWaddr 00:1c:c0:7f:6d:9e
          inet addr:192.168.1.33 Bcast:192.168.1.255 Mask:255.255.255.0
          inet6 addr: fe80::21c:c0ff:fe7f:6d9e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:1644 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1402 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2413682 (2.4 MB) TX bytes:106111 (106.1 KB)
          Interrupt:220 Base address:0x6000

eth1 Link encap:Ethernet HWaddr 00:22:b0:52:bb:58
          inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0
          inet6 addr: fe80::222:b0ff:fe52:bb58/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:958 errors:0 dropped:0 overruns:0 frame:0
          TX packets:611 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:117383 (117.3 KB) TX bytes:107409 (107.4 KB)
          Interrupt:21

lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:50 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4621 (4.6 KB) TX bytes:4621 (4.6 KB)

Output from the route command
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 100 0 0 eth0

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
HelgeB
Solved:
Last query:
Last reply:
Revision history for this message
Tony Pursell (ajpursell) said :
#1

You need to give us the same sort of information for your workstation and router.

What port on the router is connected to the server. Is it the same port you used to connect to the ADSL modem? I.e the WAN port. If it is, reconnect the server to one of its LAN ports. Also make sure the IP addresses of the Router and workstation are both in the 192.168.2.0 domain.

I might also ask why you need the server between the router and the ADSL modem? Couldn't it just be connected to one of the router's LAN ports?

Tony

Revision history for this message
Francesco Conti (madmoose) said :
#2

You have to enable ip forwarding:

# on your server
# Substitute YOUR_EXTERNAL_INTERFACE with eth0 or eth1 (the one connected to your DSL modem)
#
sudo echo "1" > /proc/sys/net/ipv4/ip_forward
sudo /sbin/iptables --table nat --append POSTROUTING --out-interface YOUR_EXTERNAL_INTERFACE -j MASQUERADE

If it works you must automagically enable ip forwrding at boot:

# on your server add this line to /etc/sysctl.conf :
net.ipv4.ip_forward=1

then:

sudo /etc/init.d/networking restart

Revision history for this message
HelgeB (helge-branden) said :
#3

Thanks to your answers. I will try out the suggestions next weekend as the Linux network is in my summer house and I have returned back home now. The reason for doing it this way is that I am not knowledgable in Linux but have configured several Windoze servers this way without problems. I'll be back with an answer during next weekend.

Revision history for this message
Luky Winarto (luckyborneo) said :
#4

Hi HelgeB,

Perhaps you can read this site too:
https://help.ubuntu.com/community/Router

Hopefully that site will help you to configure the server.

Cheers,
-Luky-

Revision history for this message
HelgeB (helge-branden) said :
#5

None of the suggestions so far have solved the problem. The situation remains the same.
Is there anyone that has made this to work?
This is the networking information from my workstation
eth0 Link encap:Ethernet HWaddr 00:1c:c0:7f:6a:71
          inet addr:192.168.2.8 Bcast:192.168.2.255 Mask:255.255.255.0
          inet6 addr: fe80::21c:c0ff:fe7f:6a71/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1492 Metric:1
          RX packets:6832827 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3449804 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1447392843 (1.4 GB) TX bytes:215782210 (215.7 MB)
          Interrupt:220 Base address:0x8000

lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:138 errors:0 dropped:0 overruns:0 frame:0
          TX packets:138 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:15719 (15.7 KB) TX bytes:15719 (15.7 KB)

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 1 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 192.168.2.1 0.0.0.0 UG 0 0 0 eth0

Revision history for this message
Francesco Conti (madmoose) said :
#6

Hi, from your server you have:

>eth1 Link encap:Ethernet HWaddr 00:22:b0:52:bb:58
> inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0

On your workstation:

> default 192.168.2.1 0.0.0.0 UG 0 0 0 eth0

Workstation thinks server is 192.168.2.1, but server is 192.168.2.2

You have to change default gateway IP on worksation.

Hope this helps

Revision history for this message
HelgeB (helge-branden) said :
#7

Sorry, I still have the problem. I have been reinstalling and trying out your suggestions, but the result is the same. It looks to me like this may be a DNS issue, but I may be wrong. I did one new change on the workstation, from the Network tool, I added 192.168.2.2 as the DNS. What I can see then, is when doing a ping, url's are translated into ip addresses, but I do not get any answer.
This is my current configuration. In addition I have enable packet forwarding in /etc/sysctl.conf
The server
eth0 Link encap:Ethernet HWaddr 00:1c:c0:7f:6d:9e
          inet addr:192.168.1.33 Bcast:192.168.1.255 Mask:255.255.255.0
          inet6 addr: fe80::21c:c0ff:fe7f:6d9e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:310 errors:0 dropped:0 overruns:0 frame:0
          TX packets:894 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:72697 (72.6 KB) TX bytes:116299 (116.2 KB)
          Interrupt:220 Base address:0x6000

eth1 Link encap:Ethernet HWaddr 00:22:b0:52:bb:58
          inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0
          inet6 addr: fe80::222:b0ff:fe52:bb58/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:1953 errors:0 dropped:0 overruns:0 frame:0
          TX packets:583 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:301135 (301.1 KB) TX bytes:107545 (107.5 KB)
          Interrupt:21

lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:60 errors:0 dropped:0 overruns:0 frame:0
          TX packets:60 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:6038 (6.0 KB) TX bytes:6038 (6.0 KB)

vnet0 Link encap:Ethernet HWaddr 62:d9:bd:3c:dc:3b
          inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
          inet6 addr: fe80::60d9:bdff:fe3c:dc3b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:113 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B) TX bytes:20063 (20.0 KB)

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.122.0 * 255.255.255.0 U 0 0 0 vnet0
default 192.168.1.1 0.0.0.0 UG 100 0 0 eth0

The workstation
eth0 Link encap:Ethernet HWaddr 00:1c:c0:7f:6a:71
          inet addr:192.168.2.4 Bcast:192.168.2.255 Mask:255.255.255.0
          inet6 addr: fe80::21c:c0ff:fe7f:6a71/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:2708 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2296 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1693885 (1.6 MB) TX bytes:267155 (267.1 KB)
          Interrupt:220 Base address:0x4000

lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:200 (200.0 B) TX bytes:200 (200.0 B)

wlan0 Link encap:Ethernet HWaddr 00:16:0a:00:a9:b0
          inet6 addr: fe80::216:aff:fe00:a9b0/64 Scope:Link
          UP BROADCAST MULTICAST MTU:1500 Metric:1
          RX packets:63 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:14293 (14.2 KB) TX bytes:168 (168.0 B)
          Interrupt:21 Memory:90100000-90110000

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
default Noteberg 0.0.0.0 UG 100 0 0 eth0

From hosts
192.168.2.2 Noteberg

When trying to ping
 ping ubuntu.com
PING ubuntu.com (91.189.94.156) 56(84) bytes of data.
^Z
[2]+ Stopped ping ubuntu.com

Revision history for this message
HelgeB (helge-branden) said :
#8

Based on my discoveries yesterday, I found that my problems had to do something with DNS and or firewalling. Since firewall was not enabled in either adsl modem or lan router, I started researching into iptables.
After running the following commands, it all started to work
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

Great thanks to all who has contributed in solving my problem.