1

I am not able to route packets between the lan side of my ubuntu server and the wan side. I'm looking for some assistance. I have 5 ethernet ports on my server - 1 onboard (eth0, used for wan) and 4 in a PCI card (eth1-eth4, bonded together as bond0, used for lan). Any help is appreciated. Thanks in advance.

Some ping tests from a directly-connected windows machine that obtained an IP via DHCP.

C:\Users\mike>ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : servo.firewall
   Link-local IPv6 Address . . . . . : fe80::ec54:579a:a4b5:991f%9
   IPv4 Address. . . . . . . . . . . : 10.10.10.108
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 10.10.10.1

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wi-Fi:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : hsd1.pa.comcast.net

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.servo.firewall:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : servo.firewall

C:\Users\mike>ping 10.10.10.1 <- the server

Pinging 10.10.10.1 with 32 bytes of data:
Reply from 10.10.10.1: bytes=32 time=15ms TTL=64
Reply from 10.10.10.1: bytes=32 time<1ms TTL=64
Reply from 10.10.10.1: bytes=32 time=1ms TTL=64
Reply from 10.10.10.1: bytes=32 time<1ms TTL=64

Ping statistics for 10.10.10.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 15ms, Average = 4ms

C:\Users\mike>ping 10.0.0.1 <- the current gateway address on the WAN

Pinging 10.0.0.1 with 32 bytes of data: 
Control-C
^C

C:\Users\mike>ping yahoo.com <- DNS test

Ping request could not find host yahoo.com. Please check the name and try again.

C:\Users\mike>ping 8.8.8.8 <- public ip test

Pinging 8.8.8.8 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out. 
Request timed out.

Ping statistics for 8.8.8.8:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

Below is information I edited to attempt to get this working.

/etc/default/ufw

DEFAULT_FORWARD_POLICY="ACCEPT"

/etc/ufw/sysctl.conf

net.ipv4.ip_forward=1
net/ipv6/conf/default/forwarding=1
net/ipv6/conf/all/forwarding=1

/etc/ufw/before.rules

# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]

# Forward traffic through eth0 - Change to match you out-interface
-A POSTROUTING -s 10.10.10.0/24 -o eth0 -j MASQUERADE

# don't delete the 'COMMIT' line or these nat table rules won't
# be processed
COMMIT

/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet manual
bond-master bond0

auto eth2
iface eth2 inet manual
bond-master bond0

auto eth3
iface eth3 inet manual
bond-master bond0

auto eth4
iface eth4 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
address 10.10.10.1
netmask 255.255.255.0
bond-mode broadcast
bond-miimon 100
bond-slaves eth1 eth2 eth3 eth4
post-up iptables-restore < /etc/iptables.up.rules
post-up ip6tables-restore < /etc/ip6tables.up.rules

ifconfig

bond0     Link encap:Ethernet  HWaddr 00:26:55:dc:d8:4f
          inet addr:10.10.10.1  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::226:55ff:fedc:d84f/64 Scope:Link
          UP BROADCAST MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:3209 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1362 errors:0 dropped:2 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:439418 (439.4 KB)  TX bytes:148509 (148.5 KB)

docker0   Link encap:Ethernet  HWaddr 02:42:d7:46:11:85
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:d7ff:fe46:1185/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23734 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:536 (536.0 B)  TX bytes:1631564 (1.6 MB)

eth0      Link encap:Ethernet  HWaddr 44:8a:5b:cd:95:56
          inet addr:10.0.0.201  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::468a:5bff:fecd:9556/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:362525 errors:0 dropped:0 overruns:0 frame:0
          TX packets:134713 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:91216243 (91.2 MB)  TX bytes:48392528 (48.3 MB)

eth1      Link encap:Ethernet  HWaddr 00:26:55:dc:d8:4f
          UP BROADCAST SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:34 Memory:fe920000-fe940000

eth2      Link encap:Ethernet  HWaddr 00:26:55:dc:d8:4f
          UP BROADCAST SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:40 Memory:fe900000-fe920000

eth3      Link encap:Ethernet  HWaddr 00:26:55:dc:d8:4f
          UP BROADCAST SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:42 Memory:fe720000-fe740000

eth4      Link encap:Ethernet  HWaddr 00:26:55:dc:d8:4f
          UP BROADCAST SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:3209 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1362 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:439418 (439.4 KB)  TX bytes:148509 (148.5 KB)
          Interrupt:44 Memory:fe700000-fe720000

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:65536  Metric:1
          RX packets:48953 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48953 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:8562847 (8.5 MB)  TX bytes:8562847 (8.5 MB)

vethdcf53dc Link encap:Ethernet  HWaddr 42:f9:a6:0e:bc:7a
          inet6 addr: fe80::40f9:a6ff:fe0e:bc7a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23750 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:648 (648.0 B)  TX bytes:1634701 (1.6 MB)

sudo iptables -t nat -L -v

Chain PREROUTING (policy ACCEPT 2629 packets, 1186K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain INPUT (policy ACCEPT 125 packets, 32492 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 368 packets, 32186 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 368 packets, 32186 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  all  --  any    eth0    10.10.10.0/24        anywhere

Chain DOCKER (0 references)
 pkts bytes target     prot opt in     out     source               destination
  • You told it to send the packet out on the lan port, which is why it can't reach the Internet. You need to try pinging from another computer on the lan instead. – psusi Oct 25 '16 at 22:41
  • Thank you for your response. My bad. I thought the ping -I command was used to specify the interface to send FROM not THROUGH. I did initially test from a computer behind the server, however. I added some ping tests from a directly-connected windows computer that obtained an IP address via DHCP from the server to the original post. I can ping the server, just not anything past it. – freshjerky Oct 26 '16 at 1:37
  • Can you ping ubuntus server's WAN interface 10.0.0.201 ? And does your your next device on WAN knows to forward all 10.10.10.0/24 traffic to you server? – meccooll Oct 27 '16 at 7:07
0

I was able to get this working with the following commands. I guess the ufw rules weren't sufficient.

sudo iptables -A FORWARD -i eth0 -o bond0 -j ACCEPT 
sudo iptables -A FORWARD -i bond0 -o eth0 -j ACCEPT 
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.