Sharing internet connection from USB0 to WLAN0

2

1

I want to create a wireless AP from my kali linux machine to share internet connection to other devices. Internet connection to linux is given by USB tethering using an android mobile phone. There is an option in linux network manager to create hotspot with 1 click and it works well, in a way that internet connection from USB0 is shared to AP created on wlan0.

This is ifconfig before turning on linux hotspot.

eth0 Link encap:Ethernet HWaddr 00:90:f5:c9:c5:d8
UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:29

.

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:180 errors:0 dropped:0 overruns:0 frame:0 TX packets:180 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:13410 (13.0 KiB) TX bytes:13410 (13.0 KiB)

.

usb0 Link encap:Ethernet HWaddr be:24:53:78:58:7c
inet addr:192.168.42.106 Bcast:192.168.42.255 Mask:255.255.255.0 inet6 addr: fe80::bc24:53ff:fe78:587c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3557 errors:1 dropped:0 overruns:0 frame:1 TX packets:3982 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1096856 (1.0 MiB) TX bytes:719193 (702.3 KiB)

.

wlan0 Link encap:Ethernet HWaddr 4c:80:93:18:2b:99
UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:165261 errors:0 dropped:0 overruns:0 frame:0 TX packets:131910 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:172078178 (164.1 MiB) TX bytes:17919253 (17.0 MiB)

After turning on linux hotspot, it looked like this, I internet connection is shared correctly to wlan0 AP

eth0 Link encap:Ethernet HWaddr 00:90:f5:c9:c5:d8
UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:29

.

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:180 errors:0 dropped:0 overruns:0 frame:0 TX packets:180 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:13410 (13.0 KiB) TX bytes:13410 (13.0 KiB)

.

usb0 Link encap:Ethernet HWaddr be:24:53:78:58:7c
inet addr:192.168.42.106 Bcast:192.168.42.255 Mask:255.255.255.0 inet6 addr: fe80::bc24:53ff:fe78:587c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3634 errors:1 dropped:0 overruns:0 frame:1 TX packets:4058 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1107827 (1.0 MiB) TX bytes:746531 (729.0 KiB)

.

wlan0 Link encap:Ethernet HWaddr 4c:80:93:18:2b:99
inet addr:10.42.0.1 Bcast:10.42.0.255 Mask:255.255.255.0 inet6 addr: fe80::4e80:93ff:fe18:2b99/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:165261 errors:0 dropped:0 overruns:0 frame:0 TX packets:131960 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:172078178 (164.1 MiB) TX bytes:17929202 (17.0 MiB)

I want to know how to do it manually with airbase-ng. I can create the AP with an interface shown as at0 in ifconfig and I can assign ip address to that, and also assign IP addresses and configure other clients using DHCP server. But I couldn't share the internet connection to that from USB0. I tried creating a network bridge but didn't work most probably because I didn't know to do that correctly.

Then I turned on hotspot with linux built in method and copied all iptables rules, created a same kind of AP with exactly similar IP addresses with airbase and restored those iptable rules, but again no luck. Same results with hostapd too.

Please tell me how to create a bridge between usb0 usb tethering network and at0(for airbase-ng) and how to set appropriate iptable rules.

Thanks.

supun manathunga

Posted 2016-02-24T05:30:30.303

Reputation: 21

No answers