0

I want my linux (ubuntu 14.04 , 64 bit) system device which has a 3g card in it to have restricted access of internet . I want to build a scenario where if the card is active, the system should be able to connect to any url with the pattern mysite.com and google.com . Incoming connection won't be a problem. If web address can not be filtered even IP address can also be used .

Is Iptables the answer for it ? . How would we use IP tables to add the rules that will allow traffic only to two sites and not others. I want to do this procedure again and again (like after inserting or removing the card ) . How can I achieve the desired result ?

2
  • Do you have another source of Internet connectivity other then the card?
    – davidgo
    Jan 29, 2016 at 4:59
  • Yes , the lan port and wifi card are there but looking 3g card as the primary source of internet Jan 30, 2016 at 13:30

1 Answer 1

0

Yes, iptalbes is the answer for the filtering part.

To enable some rules when inserting the device, depending on the distribution, you can take a look at udev which handles, amongst other things, device naming and USB insert for example and make it execute a specific script.

As you are running Ubuntu, a simpler way would be to take a look at /etc/network/interfaces. The 3g card would have a fixed interface name (thanks to udev), so in the interfaces file, you can specify a/some pre-up or post-up scripts for this interface that will apply your iptables config "on the fly".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .