I'm trying to configure a Linux machine as a "middlebox router" that allows a connecting client machine to use the internet connection of the machine itself. It has two physical ethernet interfaces, let's call them eth0 and eth1. eth0 is the internet connection for the middlebox (connects to a switch) and the internet connection tests as working correctly. The LAN subnet for the internet connection is 192.168.0.0/24 with a gateway of 192.168.1.1. I configured a different subnet for the middlebox, shown below in the config file.
I tried to configure the other ethernet interface eth1 to basically share the internet connection, but I'm getting an error message Internet Connection Failed to Initialize and the client does not connect to the internet.
What I tried to do to setup this middlebox is this:
1. Installed isc-dhcp-server 2. Configured DHCP and a static IP address for the client interface eth1 3. Enabled IPv4 forwarding on the middlebox systemctl -w net.ipv4.ip_forward=1 4. iptables rules: iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -i etho0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT 5. Set the internet connection interface (eth0) as the default route on the middlebox. IFF it's not already set to eth0, I run these commands to set the new default gateway route to eth0 (and printing the default route table shows the gateway is set to the right interface eth0 and the ip address for eth0, as expected): GW_IP=`route -n | grep -E "^0.0.0.0 .+UG .+eth0" | awk '{print $2}'` route del default $OTHER_INTERFACE route add default gw $GW_IP eth0 /etc/dhcp/dhcpd.conf
interface eth1 static ip_address=192.168.34.1/24 authoritative; subnet 192.168.34.0 netmask 255.255.255.0 { range 192.168.34.10 192.168.34.250; option broadcast-address 192.168.34.255; option routers 192.168.34.1; default-lease-time 600; max-lease-time 7200; option domain-name "local-network"; option domain-name-servers DNS_SERVER_IP1, DNS_SERVER_IP2; } /etc/default/isc-dhcp-server
INTERFACESv4="eth1" I'm not sure what I'm missing, but I was thinking this would allow "client" connections on eth1 to use the same gateway and internet connection as eth0 for the middlebox. Does anyone see what I'm missing or doing wrong?