Open Joeordie opened 9 years ago
With few changes I can implement this, but the purpose of this script is to create an AP. I will think about it because probably I need to change the command line arguments of create_ap and I need to take some good decisions for this. Anyway, even if I decide to add this feature, I'm a bit busy for now.
Few months ago I wrote a small script that do what you said, but is not that powerful as create_ap and it doesn't removes firewall restrictions etc. Check the code:
#!/bin/bash
INTERNET_IFACE=wlan0
WIRED_IFACE=eth0
SUBNET=192.168.12
cleanup() {
trap "" SIGINT
iptables -D FORWARD -d ${SUBNET}.0/24 -i $INTERNET_IFACE -j ACCEPT
iptables -D FORWARD -s ${SUBNET}.0/24 -i $WIRED_IFACE -j ACCEPT
iptables -t nat -D POSTROUTING -o $INTERNET_IFACE -j MASQUERADE
echo 0 > /proc/sys/net/ipv4/ip_forward
ip link set dev $WIRED_IFACE down
ip add flush $WIRED_IFACE
exit 0
}
# setup clean up function
trap "cleanup" SIGINT
# initialize ethernet
ip link set dev $WIRED_IFACE up
ip add flush $WIRED_IFACE
ip addr add ${SUBNET}.1/24 broadcast ${SUBNET}.255 dev $WIRED_IFACE
# set iptables rules
iptables -I FORWARD -d ${SUBNET}.0/24 -i $INTERNET_IFACE -j ACCEPT
iptables -I FORWARD -s ${SUBNET}.0/24 -i $WIRED_IFACE -j ACCEPT
iptables -t nat -I POSTROUTING -o $INTERNET_IFACE -j MASQUERADE
# enable ipv4 routing
echo 1 > /proc/sys/net/ipv4/ip_forward
# run dnsmasq
dnsmasq --no-hosts --listen-address=${SUBNET}.1 --dhcp-range=${SUBNET}.1,${SUBNET}.254,255.255.255.0,24h --dhcp-option=option:router,${SUBNET}.1 -d
cleanup
ill try this script, this one i can follow, I will look into create_ap and see if this can be accommodated. Still learning though.
I want a feature that share my Linux internet through another interface.
Internet(ipv4&ipv6)--------------[eth0/wlan0]--Linux--[eth1 with dhcpd(v4&v6)] --------------many clients in LAN
This is similar to Joeordie's . The interface to public Internet can be any type , wifi or wired.
And this create_ap is the best and most convenient tool I have ever seen on Internet. I hope it has this feature. Maybe it can be done by adding an option that just cut the creating wifi AP stuff.
@oblique, I understand that you don't have a plan on implementing this years ago. I'm using your above script though and it's working well.
I'm using a raspberry pi with create_ap. It was all good until I found out that the built in wifi is not capable for doing long range wifi. I bought a usb dongle to in hopes I can produce a wider ranged. But then there was a problem with powering the raspberry pi and this usb dongle.
What I came up with in the end was to use a router. The router has its own AP configured. Disabled DHCP, and is connected to raspberry pi. Now my setup is still the same idea with create_ap but now on eth1. Your script above works. But just wished I could still use create_ap instead.
More power to this script. Thank you for creating create_ap.
Gents,
Thanks for this great tool. I'm trying to see if I can help, but fear that this is above my expertise at the moment. I would request that we have a reverse AP available so it would specifically look like this.
WAN<--- (some wifi access point) <--- wlan0 (create_ap NAT's to eth0) ----> dhcp clients
so its simply sharing the wireless connection through a eth0.
I know there are other tools in the wild that can do this in the world but i would like to keep all simple using the create_ap commands/script. All the needed tools are available in this case but I don't think the command is built into the script.
Joeordie