VladyslavVolskyi
Posts: 5
Joined: Sun Jan 07, 2018 10:07 pm

PC<->eth1(usb adapter)<->eth0<->internet

Sat Jan 20, 2018 7:57 pm

Hello Everyone, who is reading this topic :D

Could You help me to make suck kind of work.
I want to connect my PC with ethernet cable to usb adapter(USB-Ethernet)-> eth1 on raspberry pi(raspbian) routing trafic from eth1 to eth0, and eth0 will be connected to router with Internet. What and how should i do it, that at the result my PC will have Internet conection.
I use Raspbian stretch lite.
The main problems i have:

1) which ip address should be gived on each device and how, as i used a lot of different utilities.
2) How to route trafic from eth0<->eth1. Tried different programs and itables too, but it is very difficult for me.


At the end i want to achieve - filter packages from my PC on rpi. I am a new user of rpi and raspian. :shock: :shock:

vladnt
Posts: 78
Joined: Sun Feb 21, 2016 10:16 am

Re: PC<->eth1(usb adapter)<->eth0<->internet

Sun Jan 21, 2018 8:06 am

You must configure NAT
something similar..... ))))
1. Add or fix string net.ipv4.ip_forward=1 in /etc/sysctl.conf
2. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Google search iptables NAT )

User avatar
thagrol
Posts: 3455
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: PC<->eth1(usb adapter)<->eth0<->internet

Sun Jan 21, 2018 5:20 pm

You could use bridging rather than NAT. With bridging, you PC would get it's IP address etc from your router.

Take a look at https://wiki.debian.org/BridgeNetworkConnections it's for debain but that's what raspbian is based on.
Arguing with strangers on the internet since 1993.

User avatar
pi-anazazi
Posts: 803
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: PC<->eth1(usb adapter)<->eth0<->internet

Sun Jan 21, 2018 6:30 pm

...I use some raspis with 2 (two) USB-ethernet adapters in bridged mode running Wireshark (monitoring internet traffic of the "PC" in your example, which is coupled to one of the USB-RJ45), using the built-in RJ45 to access the (headless) raspi.

Bridging the two USB-devices (as sudo):

Code: Select all

ifconfig eth1 -arp promisc 0.0.0.0 up 
ifconfig eth2 -arp promisc 0.0.0.0 up 
brctl addbr br0 
brctl addif br0 eth1 
brctl addif br0 eth2 
ifconfig br0 -arp promisc 0.0.0.0 up
Kind regards

anazazi

Return to “General discussion”