1. Network topology

         Network topology diagram is given below:

STB软路由实现_第1张图片

 

         We use one PC with 3 Ethernet interfaces to simulate the scenario. The three interfaces are eth0, eth1, and eth2. eth0 simulate the WAN interface in the TOPWAY spec. eth2 simulates USB-Wireless dongle, providing subnet and NAT feature.

2. Configuring the modes

         This section gives details on configuring the PC to work in Mode 1, 2 and 3, as listed in spec.

2.1 Mode 1

Steps:

  1. Enable kernel ip forwarding: vi /etc/sysctl.conf, enable:

net.ipv4.ip_forward=1

net.ipv6.conf.all.forwarding=1

  1. Set up DHCP server.
    1. Install dhcp server: apt-get install isc-dhcp-server
    2. Change default DHCP interface: vi /etc/default/isc-dhcp-server, change INTERFACES=”eth2”
    3. Config subnet address: vi /etc/dhcp/dhcpd.conf, change

                                                               i.      option domain-name “yourdomain.org” (optional)

                                                             ii.      subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.100 192.168.0.254;

option domain-name-servers 8.8.8.8, 8.8.8.4;

option domain-name “yourdomain.org”;

default-lease-time 600;

max-lease-time 7200;

}

    1. reboot to let dhcp server settings take effect.
  1. Set up subnet route table.
    1. route add -net 192.168.0.0/24 dev eth2

 

2.2 Mode 2

Steps:

  1. Setup DHCP server. Same as in Mode 1.
  2. Setup subnet routing table. Same as in Mode 1.
  3. Setup iptables to enable NAT:
    1. iptables -t nat -A POSTROUTING -s 192.168.0.0/24 ! -d 192.168.0.0/24 -o eth0 -j MASQUERADE

 

2.3 Mode 3

Steps:

  1. Disable DHCP server on eth2.
  2. Setup bridge over eth0 and eth2:
    1. Install bridge utilities: apt-get install bridge-utils
    2. Setup bridge:

brctl addbr br1

brctl stp br1 off

brctl addif br1 eth0

brctl addif br1 eth2

ifconfig eth0 down

ifconfig eth2 down

ifconfig eth0 0.0.0.0 up

ifconfig eth2 0.0.0.0 up

ifconfig br1 up

echo “1”>/proc/sys/net/ipv4/ip_forward