답변:
간단한 해결책은 create_ap 을 사용하는 것 입니다. 그들의 사이트에서 :
create_ap은 모든 채널에서 개방형 또는 암호화 된 AP를 생성하고, SSID를 숨기고, 클라이언트 간 통신을 비활성화 (클라이언트 격리), IEEE 802.11n 및 802.11ac 지원, 인터넷 공유 방법 : NAT 또는 브리지 또는 없음 (아니오) 인터넷 공유)
귀하의 경우 동글에서 클라이언트로 인터넷을 공유하지 않고 Linux PC로 AP를 만들려고하지만 파일 공유와 같은 다른 Lan 작업을 수행 할 수 있습니다.
Wi-Fi 카드는 AP 생성을 지원해야합니다
일부 패키지를 설치하십시오.
sudo apt install util-linux bash procps hostapd iproute2 iw haveged net-tools dnsmasq iptables
create_ap패키지를 가져 옵니다 . 터미널에서
git clone https://github.com/oblique/create_ap
cd create_ap
sudo make install
설치 후 ifconfig(더 이상 사용되지 않는) 또는 다음으로 모뎀 및 Wi-Fi 카드의 이름을 확인하십시오 .
iwconfig
와이파이 카드는 일반적으로 wlan0또는 wlp2s0USB 모뎀입니다 eth0. 당신과 다를 수 있습니다
이제 인터넷없이 리눅스에서 핫스팟을 시작하십시오 :
sudo create_ap -n wlp2s0 MyAccessPoint
그런 다음 클라이언트를 연결할 수 있습니다. 인터넷은 공유되지 않지만 인터넷없이 삼바 및 기타 작업을 수행 할 수 있습니다.
다음은 핫스팟을 생성하지만 장치 와 인터넷을 공유 하지 않는 스크립트입니다 . 시스템에 따라 네트워크 인터페이스 이름을 변경해야합니다.EthernetWiFi
입력 ip link하여 찾으십시오. 또한, 설치했는지 확인 dnsmasq하고 hostapd.
sudo apt-get install ifconfig dnsmasq hostapd
스크립트를 실행하기 전에 당신은 어떤을 중지해야합니다 네트워크 관리 도구를 제어한다 WiFi.
eth-to-wifi-route.sh
#!/bin/bash
# Share Eth with WiFi Hotspot
#
# This script is created to work with Raspbian Stretch
# but it can be used with most of the distributions
# by making few changes.
#
# Make sure you have already installed `dnsmasq` and `hostapd`
# Please modify the variables according to your need
# Don't forget to change the name of network interface
# Check them with `ifconfig`
ip_address="192.168.2.1"
netmask="255.255.255.0"
dhcp_range_start="192.168.2.2"
dhcp_range_end="192.168.2.100"
dhcp_time="12h"
eth="eth0" # replace it with Huawei 3G Modem interface
wlan="wlan0"
ssid="Arpit-Raspberry"
psk="arpit1997"
sudo rfkill unblock wlan &> /dev/null
sleep 2
#sudo iptables -F
#sudo iptables -t nat -F
#sudo iptables -t nat -A POSTROUTING -o $eth -j MASQUERADE
#sudo iptables -A FORWARD -i $eth -o $wlan -m state --state RELATED,ESTABLISHED -j ACCEPT
#sudo iptables -A FORWARD -i $wlan -o $eth -j ACCEPT
#sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo ifconfig $wlan $ip_address netmask $netmask
sudo ip route del 0/0 dev $wlan &> /dev/null
a=`route | awk "/${eth}/"'{print $5+1;exit}'`
sudo route add -net default gw $ip_address netmask 0.0.0.0 dev $wlan metric $a
echo -e "interface=$wlan \n\
bind-interfaces \n\
server=8.8.8.8 \n\
domain-needed \n\
bogus-priv \n\
dhcp-range=$dhcp_range_start,$dhcp_range_end,$dhcp_time" > /etc/dnsmasq.conf
sudo systemctl restart dnsmasq
echo -e "interface=$wlan\n\
driver=nl80211\n\
ssid=$ssid\n\
hw_mode=g\n\
ieee80211n=1\n\
wmm_enabled=1\n\
macaddr_acl=0\n\
auth_algs=1\n\
ignore_broadcast_ssid=0\n\
wpa=2\n\
wpa_key_mgmt=WPA-PSK\n\
wpa_passphrase=$psk\n\
rsn_pairwise=CCMP" > /etc/hostapd/hostapd.conf
sudo systemctl restart hostapd
sudo systemctl status hostapd &> /dev/null
if [ "$?" != 0 ];then
echo "Some Network Management tool is running, which is stopping"
echo "hostapd to be configured."
echo "Please stop that and again run the script."
fi
iptable및 packet forwarding명령에 댓글을 달았습니다 . 언제든지 장치에 인터넷을 제공 해야하는 경우 주석 처리를 제거하십시오.
스크립트를 실행
sudo bash eth-to-wifi-route.sh
출처 : eth-to-wifi-route.sh