0

I made my raspberry pi into a router.

The eth0 is connected with internet, while the wlan0 is served as an accessible point.

So I created a br0, then addif both eth0 and wlan0 to br0. Started dhcpd(so that my phone can get ip from the wlan0) and hostapd. Everything works fine I got internet on my phone from wifi connection with the raspberry pi.

But, I cannot ping the pi with either the wlan0 IP or the eth0 IP. I noticed I got a IP in the same sub net of the eth0. But still, I cannot ping it.

why? Or is there still a way that I can ping two of them? I know iptables would be an option. But just curious if it's doable with bridge.

4
  • you can't ping it from a wired or wireless device? if wireless, did you configure IPTables for "Client Isolation"? Nov 30, 2017 at 16:53
  • So, just to clarify: You have a working wired network. You want to allow your phone access to the internet via this existing network. To that end, you’re trying to make your Pi into a wireless access point. Correct?
    – Daniel B
    Nov 30, 2017 at 17:52
  • @DanielB Yes. I have already done it followed some instructions. But I am not very sure with the bridge and do not understand why I cannot ping these two ports
    – J.R.
    Nov 30, 2017 at 17:55
  • If you followed a guide, please provide a link if possible! As for the bridge ports: See grawity’s answer. He’s got that topic covered.
    – Daniel B
    Nov 30, 2017 at 17:57

2 Answers 2

4

I made my raspberry pi into a router.
I created a br0, then addif both eth0 and wlan0 to br0.

That's not a router. (It'd be a router if it linked two networks together, but right now you have a bridge – which means same subnet on both sides.)

Started dhcpd and hostapd

Somewhat concerned about this – is your Raspberry Pi the only DHCP server in the LAN, or did you accidentally set up a 2nd one?

But, I cannot ping the pi with either the wlan0 IP or the eth0 IP.

When you turn eth0 and wlan0 into bridge ports, they become nothing more than bridge ports. They no longer speak IP even if configured.

Instead, you need to set up the same IP address on the bridge interface br0 (and can remove all addresses from the "port" interfaces).

10
  • Hey I edited my question for some of your points. So the dhcpd on the pi is for the phone that connected with the pi via wifi. There's another dhcpd on the LAN for the eth0 port, this dhcpd runs on the real router. I got it, so after the bridge is done. The IP of eth0 and wlan0 do not have any meaning. And I can just assign a ip to the wlan0 and ping it from my phone? But in this case as I said, my phone got a address that are in the same subnet of the eth0. So I probably can only ping the br0 if its ip is set as a ip in the same subnet?
    – J.R.
    Nov 30, 2017 at 17:19
  • 1
    A bridge does not divide subnets. (That's why it's called a bridge!) If your eth0 was in the 192.168.1.x subnet, and you bridged it to wlan0, then br0 will be in the same subnet, and your Wi-Fi will be in the same subnet as well. You do not need a 2nd DHCP server for Wi-Fi, because you already have one. Nov 30, 2017 at 17:37
  • I got. Many Thnx! So it means the most of the commercial routers sold in the markets are using iptables to re-direct from wifi to lan right? Cause I can login my router via wifi on the browser with a static ip. If the wlan0 and eth0 of the routers are bridged, then the wlan0 will not be able to have a static ip.
    – J.R.
    Nov 30, 2017 at 17:54
  • 1
    @J.R. No. A good resource for stuff like that is OpenWrt’s default configuration: Bridged LAN and WiFi, routed WAN (with NAT using IPTables, yes). The bridge itself is the interface you should be looking at.
    – Daniel B
    Nov 30, 2017 at 17:59
  • so eventually if I want to have a static ip as the interface to communicate with I will always need the NAT...Cause only NAT offers the functionality to divide the outter net from the inner net. Your explanation rly helped alot, thnx!
    – J.R.
    Nov 30, 2017 at 18:09
3

After adding the bridge, you can no longer ping. You need to check route -n. And then delete the entry of the interface that has been bridged. Once that entry is deleted, you can ping ok. Here is an actual demo in virtualbox: Two Virtualbox Machines Using Host-Only-Adapter. The key command is:

route del -net 192.168.3.0 gw 0.0.0.0 netmask 255.255.255.0 dev enp0s8

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .