Score:0

Share USB4G connection to eth0 port

ng flag

I have been looking the past weeks on forums and YT videos about how to do what tittle says witout exist. I have a pc that only have a ethernet port and is configurated trought browser at the ip addres. So I need the raspberry to get internet from a 4G Usb dongle and give internet to the pc by the ethernet cable. This is mi ifconfig output:

pi@raspb:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.10.1 netmask 255.255.255.0 broadcast 10.10.10.255
ether dc:a6:32:f8:b6:c4 txqueuelen 1000 (Ethernet)
RX packets 225 bytes 13500 (13.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 1148 (1.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::e5db:be0d:34e8:be6c prefixlen 64 scopeid 0x20<link>
ether 00:a0:c6:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 3803 bytes 132422 (129.3 KiB)
RX errors 3723 dropped 0 overruns 0 frame 3723
TX packets 310 bytes 50065 (48.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

This config

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT 

And this outputs:

 $ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         _gateway        0.0.0.0         UG    100    0        0 eth1
10.10.10.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 eth1
$ sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 1493 packets, 174K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  eth1   eth0    0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  eth0   eth1    0.0.0.0/0            0.0.0.0/0

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

And sudo sysctl net.ipv4.ip_forward" returns 1

ChanganAuto avatar
us flag
Which OS are you running in the Pi?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.