Share mobile broadband with windows computers

Connection sharing, Firewall, Samba..etc
Forum rules
Before you post please read this

Share mobile broadband with windows computers

Postby dirtyb15 on Mon Sep 16, 2013 3:55 pm

Hi all, first post, and i apologize if this has been covered but I have had no luck getting this work. Okay, so i have been a windows user for 15 years, finally tried mint a couple months ago and I am ready to make the switch. I use a verizon usb 4G modem and i am attempting to share it with the windows machines on my network. In the past i did this with windows ICS. I had a static IP address for the card i was using to share, and the client computers would just use this static ip as the gateway address. If possible i would like to keep the client computers set up the same, so how do set up my linux machine to share the connection? I see there is an option in the network manager to "share to other computers", but i dont see an option to assign a static IP address in that case? Can i use iptables to do everything i need?

Any help would be appreciated, still learning so bear with me.
dirtyb15
Level 1
Level 1
 
Posts: 15
Joined: Mon Sep 16, 2013 3:49 pm

Linux Mint is funded by ads and donations.
 

Re: Share mobile broadband with windows computers

Postby administrollaattori on Mon Sep 16, 2013 11:58 pm

It is easy, simply edit connections via NetworkManager and choose Wired connection -> Edit -> IPV4 settings -> Shared to the other computers.

http://www.youtube.com/watch?v=AoiTnRmO6QY

PS. If you use Firestarter, the connection share does not work, so you need to remove Firestarter for sharing connection successfully.
Attachments
shared connection.png
User avatar
administrollaattori
Level 6
Level 6
 
Posts: 1447
Joined: Tue Sep 03, 2013 4:51 am

Re: Share mobile broadband with windows computers

Postby dirtyb15 on Tue Sep 17, 2013 8:12 am

Thanks for the reply. How do i manually set the IP address for the wired adapter that is sharing the connection?
dirtyb15
Level 1
Level 1
 
Posts: 15
Joined: Mon Sep 16, 2013 3:49 pm

Re: Share mobile broadband with windows computers

Postby administrollaattori on Tue Sep 17, 2013 11:04 am

dirtyb15 wrote:Thanks for the reply. How do i manually set the IP address for the wired adapter that is sharing the connection?


You can set static IP via commanf line. An example 192.168.1.2
Code: Select all
sudo ifconfig eth0 192.168.1.2 up
sudo /etc/init.d/networking restart

PS. Connection share uses its own IP, so I do not know why static IP is needed?
User avatar
administrollaattori
Level 6
Level 6
 
Posts: 1447
Joined: Tue Sep 03, 2013 4:51 am

Re: Share mobile broadband with windows computers

Postby dirtyb15 on Tue Sep 17, 2013 12:16 pm

Well, currently i have about 8 windows clients that are sharing the mobile broadband connection from my windows machine. They currently use my machines ip, 192.168.44.2 as their gateway. I was just trying to set up the linux box so that i would not have to change anything on the client machines.
dirtyb15
Level 1
Level 1
 
Posts: 15
Joined: Mon Sep 16, 2013 3:49 pm

Re: Share mobile broadband with windows computers

Postby dirtyb15 on Tue Sep 24, 2013 9:56 am

So it looks like the network manager assigns the shared adapter an ip address of 10.42.0.1 with a subnet mask of 255.255.255.0.

I am able to manually change it to 192.168.44.8 with mask of 255.255.0.0 (which is what i would really like), but as soon as I restart it goes back to 10.42.0.1 Any way i can permanently change this?

thanks!
dirtyb15
Level 1
Level 1
 
Posts: 15
Joined: Mon Sep 16, 2013 3:49 pm

Re: Share mobile broadband with windows computers

Postby dirtyb15 on Wed Sep 25, 2013 9:15 am

Still not having any luck. Maybe this is not possible with the network manager? Should i try the iptables route?
dirtyb15
Level 1
Level 1
 
Posts: 15
Joined: Mon Sep 16, 2013 3:49 pm

Re: Share mobile broadband with windows computers

Postby dirtyb15 on Fri Sep 27, 2013 8:35 am

Okay, so i finally got it working, just thought id share in case anyone else had to do this. Instead of using the sharing feature in the network manager you just set up your adapter with a staic address then do the sharing with IPtables. I found a good guide posted below.

Code: Select all
Ubuntu Internet Gateway Method (iptables)

You will need two network cards in the gateway computer, or a PPP interface and a network card. One network card (or PPP interface) connects to the Internet. We will call this card eth0. The other card connects to your internal network. We will call this eth1. It is also possible to do ICS with a single network card. In this case, use eth0 for the Internet and eth0:0 for the internal network.

    Internet <<==>> eth0 <> Ubuntu gateway <> eth1 <<==>> Client PC

    Internet <<==>> ppp0 <> Ubuntu gateway <> eth1 <<==>> Client PC

    Internet <<==>> eth0 <> Ubuntu gateway <> eth0:0 <<==>> Client PC

Gateway set up

The following example will focus on the most common gateway setup: an Ubuntu computer with two wired network adapters (eth0 and eth1) hosting ICS to a static internal network configured for the 192.168.0.x subnet.

For this example, eth0 is used to represent the network card connected to the Internet, and eth1 represents the network card connected to a client PC. You can replace eth0 and eth1 as needed for your situation. Also, any private IP subnet can be used for the internal network IP addresses.

In summary:

    eth0 = the network adapter with internet (external or WAN).
    eth1 = the network adapter to which a second computer is attached (internal or LAN).
    192.168.0.x = IP subnet for eth1

Your setup may be different. If so, make sure to change them accordingly in the following commands.

Configure internal network card

Configure your internal network card (eth1) for static IP like so:

sudo ip addr add 192.168.0.1/24 dev eth1

The external and internal network cards cannot be on the same subnet.

Configure NAT

Configure iptables for NAT translation so that packets can be correctly routed through the Ubuntu gateway.

sudo iptables -A FORWARD -o eth0 -i eth1 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -F POSTROUTING
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

The first rule allows forwarded packets (initial ones). The second rule allows forwarding of established connection packets (and those related to ones that started). The third rule does the NAT.

IPtables settings need to be set-up at each boot (they are not saved automatically), with the following commands:

    Save the iptables:

sudo iptables-save | sudo tee /etc/iptables.sav

    Edit /etc/rc.local and add the following lines before the "exit 0" line:

iptables-restore < /etc/iptables.sav

Enable routing

    Configure the gateway for routing between two interfaces by enabling IP forwarding:

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

    Edit /etc/sysctl.conf, and (up to 10.04) add these lines:

net.ipv4.conf.default.forwarding=1
net.ipv4.conf.all.forwarding=1

The /etc/sysctl.conf edit is required because of the following bug in Hardy and later releases: Launchpad Bug Report

    From 10.10 onwards, it suffices to edit /etc/sysctl.conf and uncomment:

#net.ipv4.ip_forward=1

... so that it reads:

net.ipv4.ip_forward=1

Client set up

Any OS can connect to the Internet as an ICS client as long as networking has been configured correctly. The following example will focus on how to set up an Ubuntu ICS client. For this example, it is assumed that the client is connected to an Ubuntu gateway, which has been configured to share ICS on the 192.168.0.x subnet according to the gateway set up outlined above.

For this example, eth0 is the network card on the client which is connected (by crossover cable) to eth1 on the Ubuntu gateway. You can replace eth0 as needed for your situation. Also, any private IP subnet can be used for the internal network IP address, as long as it matches the subnet on the gateway.

Disable networking

sudo /etc/init.d/networking stop

Give the client a static IP address

sudo ip addr add 192.168.0.100/24 dev eth0

This IP address can be anything within the gateway's private IP range.

Configure routing

sudo ip route add default via 192.168.0.1

This address should match the IP address on the gateway's internal network card (eth1 in the above example).

Configure DNS servers

Unless your ICS gateway can also perform DNS, you must manually configure the client with your ISP DNS servers. If you do not know your ISP's DNS servers, you can use OpenDNS servers instead.

    Backup your current /etc/resolve.conf file:

sudo cp /etc/resolv.conf /etc/resolv.conf.backup

    Open /etc/dhcp3/dhclient.conf with your favorite text editor:

sudo nano /etc/dhcp3/dhclient.conf

    Search for the line that starts "prepend domain-name-servers", and change it to look like this:

prepend domain-name-servers 208.67.222.222,208.67.220.220;

208.67.222.222 and 208.67.220.220 are OpenDNS DNS servers. If you wish to use your ISP's DNS servers, use them here instead of the OpenDNS servers.

Restart networking

sudo /etc/init.d/networking restart

Once this is finished, your client will now have access to the Internet via ICS. Please direct any questions/comments to the Internet Connection Sharing Documentation thread.
dirtyb15
Level 1
Level 1
 
Posts: 15
Joined: Mon Sep 16, 2013 3:49 pm

Linux Mint is funded by ads and donations.
 

Return to Other networking topics

Who is online

Users browsing this forum: No registered users and 3 guests