Fun question. Let us call PC1 the one with OpenVPn working, and PC2 the one connected via cable to PC1.
On PC1, after plugging in the cable:
ip link set dev eth0 down
ip addr flush dev eth0
ip addr add 10.8.0.5/24 dev eth0
ip link set dev eth0 up
ip route add 10.8.0.6/32 dev eth0
The first two commands are there purely out of caution.
On PC2:
ip link set dev eth0 down
ip addr flush dev eth0
ip addr add 10.8.0.6/24 dev eth0
ip link set dev eth0 up
and then, still on PC2,
ip route add default via 10.8.0.3
Back to PC1:
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
If this does not work right away, please do not behave like this guy, try to help yourself by reporting error messages and what not.
EDIT:
if you want to forward over the OpenVPN the communications of a tethered machine, you only need to set up a dhcp server handling communications between PC1 and PC2. I will give the instructions for a Debian-family pc, they are similar 8though not quite identical) on other distros.
sudo apt-get install isc-dhcp-server
Then edit /etc/default/isc-dhcp-server and modify the INTERFACES line to look like this:
INTERFACES="eth0"
if eth0 is the interface with the cable going to PC2. Otherwise, modify eth0 accordingly.
Now edit /etc/dhcp/dhcpd.conf and introduce these lines:
option domain-name "mysecondlan.lan";
option domain-name-servers 8.8.8.8, 8.8.4.4;
subnet 192.168.123.0 netmask 255.255.255.0 {
range 192.168.123.1 192.168.123.10;
option routers 192.168.123.1;
}
Now restart the service
sudo service isc-dhcp-server restart
and you are done. Remember, you may have to use a crossover ethernet cable, especially if you are connecting to pcs.
Please see my edit. – MariusMatutiae – 2014-10-03T17:47:17.113