Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Linux - Create Bridge of 3G Internet and Ethernet Port (LAN) on a PC ?

  • 29-03-2014 1:26pm
    #1
    Registered Users, Registered Users 2 Posts: 165 ✭✭


    hi folks
    here is my setup - I have a 4-port switch in the attic
    I have a 3G internet dongle (3 dongle) attached via USB to a PC lets call the PC "PC-net" the 3G internet dongle assigns itself as a gateway using a gateway IP address of 192.168.1.1 - on PC-net.

    i went into the network conections option in windows 7 this is what i do
    I create the bridge by highlighting the 3G dongle connection and PC-net’s ethernet connection together and right click and choose “create bridge” when the bridge is created I statically assign the bridge an IP address of 192.168.1.121 - so now PC-net has that address and when i connect the ethernet cable from PC-net into the 4-port switch i have 2 way flow (in/out) of internet through the ethernet ( lan ) port of PC-net
    so that when connected to the switch via ethernet cable PC-net effectivelty shares its internet with all other PC’s connected to the switch - i can assign these other pcs static ip addresses - so theyre ok

    preconditions - 1. i dont want to nor am i willing to buy a 3G router as i know its unnecessary and expensive
    2. i want to be able to assign the client PCs their IP addresses manually in the range 192.168.1.125 to 192.168.1.128

    how do I achieve this in linux (Fedora 20 in my case) - if i install fedora (or other linux) on PC-net - how do i achieve the above windows equivalent setup on linux - can i do it using GUI or do I need to use those scary iptables commands ? thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,370 ✭✭✭Knasher


    Ultimately yes you will be doing this with iptables, but there are some GUI frontends that can build up the iptables commands for you. See https://wiki.archlinux.org/index.php/firewalls#Graphic_frontends for some examples. Your requirements aren't that complicated, so I'd imagine that any of those GUIs should be able to handle it. I quoted the Arch wiki, but it should be generally the same for Fedora, I'd probably start with firewalld as that is their project.


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    There shouldn't really be any need for many iptables rules at all. As long as the USB device is supported in your distro the setup should be straight forward. The PC will show two interfaces, USB and ethernet. Simply enabling IP Forwarding (edit /etc/sysctl.conf and add in net.ipv4.ip_forward=1 ) will allow you to pass traffic from your LAN interface to the USB interface. You should then be able to get away with one iptables command, to NAT the traffic from the LAN interface to the 3G interface :
    iptables -t nat -A POSTROUTING -o $USB_INTERFACE -j MASQUERADE
    

    If you give the LAN interface (eth0) the IP of 192.168.1.121 you can then manually set your clients on the LAN to use that IP as their default gateway.

    Or, if you fancy it, grab yourself dnsmasq to get that to hand out the IPs to the LAN subnet.


  • Registered Users, Registered Users 2 Posts: 2,755 ✭✭✭niallb


    You probably don't need to do any of that manually.
    If network-manager is installed, set up a new network connection on the ethernet port,
    and under IPV4 settings choose "Method: Shared to other computers".

    It takes care of handing out addresses and routing on a NATted private network.


Advertisement