share wireless connection

hi there itry to share wireless connection in opensuse 13.1

the internet connection is in wired card and i have also wireless card and i want to share the internet in the wireless card with wifi devices

i config static ip in the settings of the wireless card and enable ip forward but nothing.

anyone can guide me? i search in google but no help,

On 03/30/2014 09:16 AM, habernir2008 wrote:
>
> hi there itry to share wireless connection in opensuse 13.1
>
> the internet connection is in wired card and i have also wireless card
> and i want to share the internet in the wireless card with wifi devices
>
> i config static ip in the settings of the wireless card and enable ip
> forward but nothing.
>
> anyone can guide me? i search in google but no help,

What you want to do is set up a software access point. Google for “hostapd”. You
might start with
https://forums.opensuse.org/showthread.php/410475-How-to-setup-an-Access-Point.
In particular, read the first sentence. The cost of a computer has changes, but
the idea is still valid.

Not all wireless driver/card combinations will work with this approach.

thanks

i try it but if i try to connect from other wifi device i can see the wireless network name BUT when i click on it nothing happen .

On 03/30/2014 02:26 PM, habernir2008 wrote:
>
> thanks
>
> i try it but if i try to connect from other wifi device i can see the
> wireless network name BUT when i click on it nothing happen its even
> dont ask for my wep key.

Post your hostapd.conf and the identity of your wireless card.

I still recommend you buy an AP. For example,
http://www.ebay.com/itm/LINKSYS-WRT54G-54-Mbps-4-Port-10-100-Wireless-G-Router-WRT54G-v2-w-P-Adapter-/131153692615?pt=COMP_EN_Routers&hash=item1e895e87c7
is only $17.50 + shipping.

hi

my android device its connected to the wireless network (network name is ->“test”) and obtain ip address

BUT there is no internet connection.

i played with the dhcp server configuration but no luck.

i have wired card that connected to the internet and the wireless card that i want to share the internet i with other devices (like my andorid for testing that i do)

and the wireless card i gave him a static ip → 192.168.0.254 /255.255.255.0

and the wired card its connectd to the internet (with dynamic DHCP) and the ip the its have it → 10.0.0.3

this is my dhcpd…conf

option domain-name-servers 192.168.0.254;
option routers 192.168.0.254;
ddns-update-style none;
default-lease-time 14400;
subnet 192.168.0.0 netmask 255.255.255.0 {
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.2.255;
  range 192.168.0.10 192.168.0.64;
  default-lease-time 14400;
  max-lease-time 172800;
}

ok my error i change it to

option domain-name-servers 10.0.0.3;
option routers 10.0.0.3;
ddns-update-style none;
default-lease-time 14400;
subnet 192.168.0.0 netmask 255.255.255.0 {
       option subnet-mask 255.255.255.0;
       option broadcast-address 192.168.2.255;
       range 192.168.0.10 192.168.0.64;
       default-lease-time 14400;
       max-lease-time 172800;
}

or i need to change from 10.0.0.3 to 10.0.0.138(from "cat /etc/resolv.conf")?

both case don’t work.

On 03/31/2014 10:06 AM, habernir2008 wrote:
>
> ok my error i change it to
>
>
> Code:
> --------------------
> option domain-name-servers 10.0.0.3;
> option routers 10.0.0.3;
> ddns-update-style none;
> default-lease-time 14400;
> subnet 192.168.0.0 netmask 255.255.255.0 {
> option subnet-mask 255.255.255.0;
> option broadcast-address 192.168.2.255;
> range 192.168.0.10 192.168.0.64;
> default-lease-time 14400;
> max-lease-time 172800;
> }
> --------------------
>
> or i need to change from 10.0.0.3 to 10.0.0.138(from "cat
> /etc/resolv.conf")
?
>
> both case don’t work.

The wireless card and the dhcp range for the AP must have addresses that belong
to the same network, i.e. the first 3 octants must be the same. That will let
your Android device communicate with the AP. In general, those addresses should
not overlap the address of your wired address. Network 10.0.0.0 is fine for the
latter, and 192.168.0.0 is OK for the wireless network.

The parts you are missing are the iptables rules to do NAT between the two
networks. That is why you cannot get to the Internet.

Here is a script that will do what you need:


#!/bin/sh
# Script to start/stop a hostapd-based access point
#
# Sample start call "control_ap start wlan0 eth0"
# Stop with "control_ap stop"
#

case "$1" in
start)
if  $# -ne 3 ]
then
echo "Usage: $0 start AP_iface NET_iface"
exit 1
fi
;;
stop)
if  $# -ne 1 ]
then
echo "Usage: $0 stop"
exit 1
fi
;;
*)
echo "Usage:"
echo "$0 start AP-iface net_iface"
echo "or"
echo "$0 stop"
exit 1
;;
esac

# Symbols for needed programs

IPTABLES=/usr/sbin/iptables
IFCONFIG=/sbin/ifconfig
DHCPD=/usr/sbin/dhcpd
HOSTAPD=/usr/sbin/hostapd

# Symbols for AP and external interfaces

NET_AP=$2
NET_EXT=$3

# First 3 octets of IP address for the AP

AP_ADDR=192.168.0

# IP address for nameserver

NAME_SERVER=8.8.8.8

# AP Channel, SSID, Encryption method, driver,  and Encryption secret

AP_CHANNEL=11
AP_SSID=TEST
WPA_SECRET="This is a test"
ENCRYPT_MODE=2
DRIVER=nl80211

case "$1" in
start)
echo "Starting AP mode for $NET_AP at address $AP_ADDR.1"
# Disable packet forwarding
echo 0 > /proc/sys/net/ipv4/ip_forward
# Stop any existing hostapd and dhcpd daemons
killproc hostapd
killproc dhcpd
#Set up forwarding
$IPTABLES -t nat -A POSTROUTING -o $NET_EXT -j MASQUERADE
$IPTABLES -A FORWARD -i $NET_EXT -o $NET_AP -m state \
--state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $NET_AP -o $NET_EXT -j ACCEPT
# Enable packet forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# Get the AP interface in the right state
$IFCONFIG $NET_AP down
$IFCONFIG $NET_AP up
$IFCONFIG $NET_AP $AP_ADDR.1
# dhcpd needs to have a leases file available - create it if needed
if  ! -f /var/lib/dhcp/db/dhcpd.leases ]; then
mkdir -p /var/lib/dhcp/db
touch /var/lib/dhcp/db/dhcpd.leases
fi
# Write the DHCP server configuration file
echo "option domain-name-servers $NAME_SERVER;" > ~/dhcpd.conf
echo "default-lease-time 600;" >> ~/dhcpd.conf
echo "max-lease-time 7200;" >> ~/dhcpd.conf
echo "ddns-update-style none; ddns-updates off;" >> ~/dhcpd.conf
echo "subnet $AP_ADDR.0 netmask 255.255.255.0 {" >> ~/dhcpd.conf
echo "        range $AP_ADDR.200 $AP_ADDR.229;" >> ~/dhcpd.conf
echo "        option subnet-mask 255.255.255.0;" >> ~/dhcpd.conf
echo "        option broadcast-address $AP_ADDR.255;" >> ~/dhcpd.conf
echo "        option routers $AP_ADDR.1;" >> ~/dhcpd.conf
echo "}" >> ~/dhcpd.conf
# Bring up the DHCP server
$DHCPD -cf ~/dhcpd.conf $NET_AP
# Write the hostapd configuration file
cat > ~/hostapd.conf << EOF
auth_algs=1
beacon_int=100
#bridge=br0
country_code=US
ctrl_interface_group=0
ctrl_interface=/var/run/hostapd
dtim_period=2
dump_file=/tmp/hostapd.dump
fragm_threshold=2346
#ht_capab=[HT40-][SHORT-GI-20][SHORT-GI-40][MAX-AMSDU-7935][DSSS_CCK-40]
#ieee80211d=1
#ieee80211n=1
ignore_broadcast_ssid=0
logger_stdout=-1
logger_stdout_level=2
logger_syslog=-1
logger_syslog_level=2
macaddr_acl=0
max_num_sta=255
rts_threshold=2347
wmm_ac_be_acm=0
wmm_ac_be_aifs=3
wmm_ac_be_cwmax=10
wmm_ac_be_cwmin=4
wmm_ac_be_txop_limit=0
wmm_ac_bk_acm=0
wmm_ac_bk_aifs=7
wmm_ac_bk_cwmax=10
wmm_ac_bk_cwmin=4
wmm_ac_bk_txop_limit=0
wmm_ac_vi_acm=0
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmax=4
wmm_ac_vi_cwmin=3
wmm_ac_vi_txop_limit=94
wmm_ac_vo_acm=0
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_cwmin=2
wmm_ac_vo_txop_limit=47
wmm_enabled=1
EOF
echo "interface=$NET_AP" >> ~/hostapd.conf
echo "ssid=$AP_SSID" >> ~/hostapd.conf
echo "driver=$DRIVER" >> ~/hostapd.conf
echo "hw_mode=g" >> ~/hostapd.conf
echo "channel=$AP_CHANNEL" >> ~/hostapd.conf
echo "wpa=$ENCRYPT_MODE" >> ~/hostapd.conf
echo "wpa_key_mgmt=WPA-PSK" >> ~/hostapd.conf
echo "wpa_pairwise=TKIP CCMP" >> ~/hostapd.conf
echo "rsn_pairwise=CCMP" >> ~/hostapd.conf
echo "wpa_passphrase=$WPA_SECRET" >> ~/hostapd.conf
# Bring up hostapd
$HOSTAPD -dd -B ~/hostapd.conf
;;
stop)
echo "Stopping AP mode"
# Stop hostapd and dhcpd daemons
killproc hostapd
killproc dhcpd
rm -f ~/hostapd.conf
rm -f ~/dhcpd.conf
;;
esac

Some parts of that will need to be modified to fit you network, but all the
pieces are there. BTW, if you plan to have that softap up very much, I would
never use WEP. It is too insecure!!

thanks everything work perfect!!!

if i want that the iptable rules will load in startup

iptables -t nat -A POSTROUTING -o enp3s0 -j MASQUERADE
iptables -A FORWARD -i enp3s0 -o wlp5s0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i wlp5s0 -o enp3s0 -j ACCEPT

which file and section do i need to write to?

On 04/01/2014 03:16 AM, habernir2008 wrote:
>
> if i want that the iptable rules will load in startup
>
> iptables -t nat -A POSTROUTING -o enp3s0 -j MASQUERADE
>
>
> iptables -A FORWARD -i enp3s0 -o wlp5s0 -m state --state
> ESTABLISHED,RELATED -j ACCEPT
> iptables -A FORWARD -i wlp5s0 -o enp3s0 -j ACCEPT
>
> which file and section do i need to write to?

The script I gave you runs it when you start the softap. Why don’t you use that?
You could make that run as part of your login. It is possible you could make it
part of your firewall setup. It is the only standard part of openSUSE that
manipulates iptables. Otherwise, you will need to write a service file for
systemd that does this action after the network is started. Of course, that
might inhibit booting if the network devices are not present.