View previous topic :: View next topic |
Author |
Message |
andros705 n00b
Joined: 03 Oct 2017 Posts: 9
|
Posted: Thu Oct 05, 2017 11:46 am Post subject: No internet on host after creating a hotspot |
|
|
Well so I've made a bridge:
Code: |
ip link add name br0 type bridge
ip link set br0 up
|
and made interface enp2s0 slave to it's master
Code: |
ip link set enp2s0 master br0
|
then I've configured hostapd and run it.
I've got something like this: enp2s0 <=br0=> wlp3s0
Now, I can connect with my phone to the hotspot and access the internet and all the local machines and they can access my phone
But I cannot access the internet from my laptop which is the hotspot (victim) in this situation.
Code: |
default via 10.107.0.254 dev enp2s0 proto static metric 100
10.10.20.201 via 10.107.0.254 dev enp2s0 proto dhcp metric 100
10.107.0.0/24 dev enp2s0 proto kernel scope link src 10.107.0.74 metric 100
169.254.0.0/16 dev enp2s0 proto kernel scope link src 169.254.78.140 metric 2
|
The ip of the gateway is 10.107.0.254, seems correct.
But the src is 10.107.0.74 which is the ip of my laptop (hotspot, victim, localhost).
I guess I know where is the issue but I am not sure how to approach the problem.
I can't just do Code: | ip route add default via 10.107.0.254 dev br0 |
|
|
Back to top |
|
|
bbgermany Veteran
Joined: 21 Feb 2005 Posts: 1844 Location: Oranienburg/Germany
|
Posted: Thu Oct 05, 2017 12:20 pm Post subject: |
|
|
Hi,
Where is your IP address set? On br0 or on enp2s0?
It should be set on br0!
greets, bb _________________ Desktop: Ryzen 5 5600G, 32GB, 2TB, RX7600
Notebook: Dell XPS 13 9370, 16GB, 1TB
Server #1: Ryzen 5 Pro 4650G, 64GB, 16.5TB
Server #2: Ryzen 4800H, 32GB, 22TB |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3136
|
Posted: Thu Oct 05, 2017 12:26 pm Post subject: |
|
|
How do you configure your network? (What tools? What commands? What is in your configs?)
This bit belowe is - obviously - wrong. You seem to be aware of it, though the point still holds: you don't use a device enslaved by a bridge directly, you use the bridge instead.
Code: | default via 10.107.0.254 dev enp2s0 proto static metric 100
10.10.20.201 via 10.107.0.254 dev enp2s0 proto dhcp metric 100
10.107.0.0/24 dev enp2s0 proto kernel scope link src 10.107.0.74 metric 100
169.254.0.0/16 dev enp2s0 proto kernel scope link src 169.254.78.140 metric 2 |
Now:
Quote: | I can't just do
Code: | ip route add default via 10.107.0.254 dev br0 |
|
Why? Because there is a conflict with this line below, or is there some other reason?
Code: | default via 10.107.0.254 dev enp2s0 proto static metric 100 | So, how 'bout dropping this route before adding a new one?
Also, is your wifi device actually attached to the bridge? Depending on your hardware, attaching wifi to a bridge works in more or less funny (or clunky) way. Does brctl show report it? |
|
Back to top |
|
|
andros705 n00b
Joined: 03 Oct 2017 Posts: 9
|
Posted: Thu Oct 05, 2017 1:07 pm Post subject: |
|
|
szatox wrote: | Also, is your wifi device actually attached to the bridge? Depending on your hardware, attaching wifi to a bridge works in more or less funny (or clunky) way. Does brctl show report it? |
Yes, hostapd automatically handles attaching wifi device to the bridge, I can't use brctl because I am not on systemd but ip link gives me:
Code: |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP mode DEFAULT group default qlen 1000
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
|
So if I understand correctly wlp3s0 and enp2s0 are both attached to the bridge (master br0).
When I try to route through br0, even after removing old default route it gives me:
Code: |
# ip route add default via 10.107.0.254 dev br0
RTNETLINK answers: Network is unreachable
|
bbgermany wrote: | Hi,
Where is your IP address set? On br0 or on enp2s0?
It should be set on br0!
greets, bb |
How do I do it?
Is it #ip route default via ...?
Thanks |
|
Back to top |
|
|
bbgermany Veteran
Joined: 21 Feb 2005 Posts: 1844 Location: Oranienburg/Germany
|
Posted: Thu Oct 05, 2017 2:56 pm Post subject: |
|
|
Hi,
"ip route" is the false command! you need to configure a bridge interface in /etc/conf/net. For example like this:
Code: |
config_enp2s0="null"
bridge_forward_delay_br0=0
bridge_hello_time_br0=1000
bridge_stp_state_br0=1
bridge_br0="enp2s0"
config_br0="dhcp" # if you use dhcp in your network. if you use static ip, change to your ip/netmask"
# routes_br0="default via 10.107.0.254" # uncomment this line, if you use static ip
|
start your hostapd and you should be set.
greets, bb _________________ Desktop: Ryzen 5 5600G, 32GB, 2TB, RX7600
Notebook: Dell XPS 13 9370, 16GB, 1TB
Server #1: Ryzen 5 Pro 4650G, 64GB, 16.5TB
Server #2: Ryzen 4800H, 32GB, 22TB |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Thu Oct 05, 2017 6:55 pm Post subject: |
|
|
Do you need a bridge at all? My hostapd setup works fine with just `sysctl net.ipv4.ip_forward=1`. |
|
Back to top |
|
|
joanandk Apprentice
Joined: 12 Feb 2017 Posts: 169
|
Posted: Thu Oct 05, 2017 8:07 pm Post subject: |
|
|
andros705 wrote: | I can't use brctl because I am not on systemd but ip link gives me |
What has brctl do with "not on systemd"?
You are mixing up terms.
a) br0 is a bridge
b) ethernet slave is used for bonding and creates a bond0.
Bonding is used for load balancing and/or bandwidth enhancement (so 2x 1Gbps links will give nearly 2Gbps). Bridge on the other hand gives no benefits other than having a software switch.
As others have said, you must assign IP and routes on the br0, not enp2s0. So literally you create a bridge with the two physical interfaces, let net.br0 assign ip to br0 and you are good to go. |
|
Back to top |
|
|
andros705 n00b
Joined: 03 Oct 2017 Posts: 9
|
Posted: Thu Oct 05, 2017 8:44 pm Post subject: |
|
|
bbgermany wrote: | Hi,
"ip route" is the false command! you need to configure a bridge interface in /etc/conf/net. For example like this:
Code: |
config_enp2s0="null"
bridge_forward_delay_br0=0
bridge_hello_time_br0=1000
bridge_stp_state_br0=1
bridge_br0="enp2s0"
config_br0="dhcp" # if you use dhcp in your network. if you use static ip, change to your ip/netmask"
# routes_br0="default via 10.107.0.254" # uncomment this line, if you use static ip
|
start your hostapd and you should be set.
greets, bb |
Can you just explain how is ip route "the false command"?
joanandk wrote: | andros705 wrote: | I can't use brctl because I am not on systemd but ip link gives me |
What has brctl do with "not on systemd"?
You are mixing up terms.
a) br0 is a bridge
b) ethernet slave is used for bonding and creates a bond0.
Bonding is used for load balancing and/or bandwidth enhancement (so 2x 1Gbps links will give nearly 2Gbps). Bridge on the other hand gives no benefits other than having a software switch.
As others have said, you must assign IP and routes on the br0, not enp2s0. So literally you create a bridge with the two physical interfaces, let net.br0 assign ip to br0 and you are good to go. |
I am not sure if I follow, but I'll try tomorrow. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3136
|
Posted: Thu Oct 05, 2017 9:05 pm Post subject: |
|
|
Quote: | I can't use brctl because I am not on systemd but ip link gives me(...) | Command name ending in "ctl" does not imply it's systemd.
Your ip link outpus looks reasonably though.
But you certainly have your IP assigned to physical interface rather than bridge.
Now, ip is not a "false command" by any means. It is in fact the very same thing that netifrc uses through its modules. You can use it directly if you like, but there are more convenient tools for handling both, persistent configuration (netifrc) and dynamic configuration (dhcpcd, wicd...). Since this is Gentoo, there are a lot of ways to do the same thing. Showing your configs is a good start to fixing mistakes. Say, with a fresh eye we can spot many mistakes instantaneously, but throwing clues before you show any background at all can only be based on out previous experience with most frequently asked questions (AKA what other people got wrong before).
Quote: | b) ethernet slave is used for bonding and creates a bond0. | Joanandk, I suppose this was intended for me.
I do not consider bonding and bridging to be scenarios so different from each other to invent a new name for the latter. You have a virtual device that does some magic on top of a physical device and you're not supposed to use the physical device directly at the same time. You know what I mean, I know what I mean, and the details of that particular magic are not relevant to the case in hand. |
|
Back to top |
|
|
bbgermany Veteran
Joined: 21 Feb 2005 Posts: 1844 Location: Oranienburg/Germany
|
Posted: Fri Oct 06, 2017 4:32 am Post subject: |
|
|
"ip route" adds or show the routes for your networks. you need to add an ip to your bridge, if you have created one. you either configure your network in /etc/conf.d/net or set an ip address via "ip addr add".
oh and yeah, ipforwarding is needed as well, but since youre not able to connect to the internet from the hostapd enabled system, i think you will need to configure an ip.
you should post the output of "ifconfig -a" from the hostapd system here. then we will show you, where you may need to switch stuff to get it working.
greets, bb _________________ Desktop: Ryzen 5 5600G, 32GB, 2TB, RX7600
Notebook: Dell XPS 13 9370, 16GB, 1TB
Server #1: Ryzen 5 Pro 4650G, 64GB, 16.5TB
Server #2: Ryzen 4800H, 32GB, 22TB |
|
Back to top |
|
|
andros705 n00b
Joined: 03 Oct 2017 Posts: 9
|
Posted: Fri Oct 06, 2017 9:02 am Post subject: |
|
|
I think you was right. I had dhcpcd running at boot and assigning ip address to enp2s0, then I just created the bridge and bound these without running dhcpcd on br0.
I've killed dhcpcd on enp2s0 and run it on br0, works like a charm!
Thanks! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|