Hello,
I am running ubuntu 18.04 and do not have much experience with networking. This ubuntu server runs on our robot and is supposed to act as a wlan to lan bridge for the rest of the wired modules on the robot. I have been using dd-wrt routers previously in client bridge mode to achieve the same, but they are too inconsistent. An off the shelf extender with ethernet ports is a little expensive and hence i wanted to try this out. Following is my netplan config:
Code:
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: no
dhcp6: no
wifis:
wlp3s0:
dhcp4: no
dhcp6: no
access-points:
"leibnitz":
password: ""
bridges:
br0:
dhcp4: no
dhcp6: no
addresses: [192.168.0.10/24]
gateway4: 192.168.0.1
# routes:
# - to: 0.0.0.0/0
# via: 192.168.0.1/24
interfaces: [enp2s0,wlp3s0]
mtu: 1500
nameservers:
addresses: [8.8.8.8]
parameters:
stp: true
forward-delay: 4
But i had to do some extra configurations in order to add the wireless interface wlp3s0 to the bridge by following this page
https://wiki.debian.org/BridgeNetworkConnections
Code:
$ iw dev wlp3s0 set 4addr on
$ brctl addif br0 wlp3s0
After this had to use ebtables to do layer 2 nat, since only wlp3s0 is authenticated with the AP (which is my primary router).
Code:
ebtables -t nat -A POSTROUTING -o wlp3s0 -n snat --to-src "MAC_OF_WLP3S0" --snat-arp --snat-target ACCEPT
ebtables -t nat -A PREROUTING -p IPv4 -i wlp3s0 --ip-dst 192.168.0.12 -j dnat --to-dst $MAC_OF_CLIENT --dnat-target ACCEPT
ebtables -t nat -A PREROUTING -p ARP -i wlp3s0 --arp-ip-dst 192.168.0.12 -j dnat --to-dst $MAC_OF_CLIENT --dnat-target ACCEPT
192.168.0.12 is the ip of the downstream client computer. Please correct me if my understanding of the above commands is wrong. The first ebtables command ensures that every outgoing packet from the bridge interface has the mac address of wlp3s0. And the subsequent 2 commands ensure that when a packet addressed to 192.168.0.12 is received at the input chain its destination mac address is changed to that of the bridge client.
Now the bridge interface works.
Code:
$ brctl showmacs br0
port no mac addr is local? ageing timer
2 00:0a:f7:81:da:a3 no 0.00
2 24:0a:64:89:33:8d no 241.86
2 70:bb:e9:13:b6:03 no 32.02
1 d8:50:e6:23:32:6b no 3.34
2 d8:fc:93:c5:df:aa yes 0.00
2 d8:fc:93:c5:df:aa yes 0.00
2 f4:8c:eb:9e:e2:64 no 0.08
1 fc:aa:14:e3:e4:94 yes 0.00
1 fc:aa:14:e3:e4:94 yes 0.00
I can ping 8.8.8.8 on the downstream client computer which is connected to the ethernet interface of the bridge. But i dont get internet, i cant browse internet on the client.
This is the route table of the client:
Code:
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 20100 0 0 enp4s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enp4s0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp4s0
This is the output of ifconfig:
Code:
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.10 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::7c0d:f9ff:feb1:68ba prefixlen 64 scopeid 0x20<link>
inet6 fd01::7c0d:f9ff:feb1:68ba prefixlen 64 scopeid 0x0<global>
ether 7e:0d:f9:b1:68:ba txqueuelen 1000 (Ethernet)
RX packets 80966 bytes 108616599 (108.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 82286 bytes 10385602 (10.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.9.1 netmask 255.255.255.0 broadcast 192.168.9.255
inet6 fe80::42:ddff:fe39:8ff0 prefixlen 64 scopeid 0x20<link>
ether 02:42:dd:39:8f:f0 txqueuelen 0 (Ethernet)
RX packets 38417 bytes 2933398 (2.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28883 bytes 2575833 (2.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether fc:aa:14:e3:e4:94 txqueuelen 1000 (Ethernet)
RX packets 3863 bytes 326607 (326.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1662 bytes 125423 (125.4 KB)
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
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 1288744 bytes 205878639 (205.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1288744 bytes 205878639 (205.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth8bdf2aa: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::b834:49ff:fe31:12ac prefixlen 64 scopeid 0x20<link>
ether ba:34:49:31:12:ac txqueuelen 0 (Ethernet)
RX packets 19226 bytes 1736798 (1.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14559 bytes 1297280 (1.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth9e8287f: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::eccb:eaff:fe68:6b60 prefixlen 64 scopeid 0x20<link>
ether ee:cb:ea:68:6b:60 txqueuelen 0 (Ethernet)
RX packets 19191 bytes 1734438 (1.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14593 bytes 1299457 (1.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether d8:fc:93:c5:df:aa txqueuelen 1000 (Ethernet)
RX packets 129600 bytes 112940617 (112.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 89885 bytes 13247558 (13.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Following is the netplan config of the client computer:
Code:
network:
version: 2
renderer: NetworkManager
ethernets:
enp4s0:
dhcp4: no
dhcp6: no
addresses: [192.168.0.12/24]
gateway: 192.168.0.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
I'm not sure if 192.168.0.1 is the right gateway for the bridge client or should it be the ip of the bridge. I know that bridge is a layer 2 mechanism and it is supposed to be transparent to layer 3, hence all the devices connected to the bridge will have the same gateway as the devices that are connected to the AP outside of the bridge.
How i do i connect the client machine to the internet