I access the internet using a VPN. With the help of iptables rules all out-going traffic from my machine to the internet is dropped instantly when my VPN connection is abruptly terminated.The iptables rules work on a wired connection but they do not when I am using mobile broadband. The said rules are as follows:#!/bin/bashecho Please wait a moment......echo Save original iptables. Apply new iptables rulesiptables-save > /home/username/vpn/iptables.saveiptables -A INPUT -m conntrack -j DROP --ctstate INVALIDiptables -A INPUT -i lo -j ACCEPTiptables -A OUTPUT -o lo -j ACCEPTiptables -A INPUT -p tcp -m tcp -m conntrack -s 123.123.123.123 -i eth0 --sport 443 -j ACCEPT  --ctstate ESTABLISHED #example.confiptables -A OUTPUT -p tcp -m tcp -m conntrack -d 123.123.123.123 -o eth0 --dport 443 -j ACCEPT --ctstate NEW,ESTABLISHED #example.confiptables -A INPUT -p tcp -m tcp -m conntrack -s 123.123.123.123 -i usb0 --sport 443 -j ACCEPT  --ctstate ESTABLISHED #example.confiptables -A OUTPUT -p tcp -m tcp -m conntrack -d 123.123.123.123 -o usb0 --dport 443 -j ACCEPT --ctstate NEW,ESTABLISHED #example.confiptables -A INPUT -i eth0 -j DROPiptables -A OUTPUT -o eth0 -j REJECTiptables -A OUTPUT -p tcp -m tcp -m conntrack -o tun0 --dport 80 -j ACCEPT  --ctstate NEW,ESTABLISHEDiptables -A OUTPUT -p tcp -m tcp -m conntrack -o tun0 --dport 443 -j ACCEPT  --ctstate NEW,ESTABLISHEDiptables -A OUTPUT -p tcp -m tcp -m conntrack -o tun0 --dport 53 -j ACCEPT  --ctstate NEW,ESTABLISHEDiptables -A OUTPUT -p tcp -m tcp -m conntrack -o tun0 --dport 53 -j ACCEPT  --ctstate NEW,ESTABLISHEDiptables -A INPUT -p tcp -m tcp -m conntrack -i tun0 --sport 80 -j ACCEPT  --ctstate ESTABLISHEDiptables -A INPUT -p tcp -m tcp -m conntrack -i tun0 --sport 443 -j ACCEPT  --ctstate ESTABLISHEDiptables -A INPUT -p tcp -m tcp -m conntrack -i tun0 --sport 53 -j ACCEPT  --ctstate ESTABLISHEDiptables -A INPUT -p tcp -m tcp -m conntrack -i tun0 --sport 53 -j ACCEPT  --ctstate ESTABLISHEDiptables -A FORWARD -i eth0 -o tun0 -j ACCEPTiptables -A FORWARD -i tun0 -o eth0 -j ACCEPTiptables -A FORWARD -j DROPI tried to solve the problem by sudo-ing and editing the file /etc/udev/rules.d/70-persistent-net.rules to include the following line:# Mobile Broadband USB dongleSUBSYSTEM==net, ACTION==add, DRIVERS==?*, ATTR{address}==MAC address of dongle, ATTR{dev_id}==0x0, ATTR{type}==1, KERNEL==eth*, NAME=usb0If it is helpful to you, below is the contents of the file 70-persistent-net.rules# This file was automatically generated by the /lib/udev/write_net_rules# program, run by the persistent-net-generator.rules rules file.## You can modify it, as long as you keep each rule on a single# line, and change only the value of the NAME= key.# PCI device (r8169)#SUBSYSTEM==net, ACTION==add, DRIVERS==?*, ATTR{address}==MAC address of ethernet card, ATTR{dev_id}==0x0, ATTR{type}==1, KERNEL==eth*, NAME=eth0# Mobile Broadband USB dongleSUBSYSTEM==net, ACTION==add, DRIVERS==?*, ATTR{address}==MAC address of dongle, ATTR{dev_id}==0x0, ATTR{type}==1, KERNEL==eth*, NAME=usb0Additional detailsTo get mobile broadband to work on Debian 7.9, I carried out the following steps:(1) Add the following line to /lib/udev/rules.d/40-usb_modeswitch.rules# Mobile Broadband USB dongleATTRS{idVendor}==19d2, ATTRS{idProduct}==0257, RUN+=usb_modeswitch '%b/%k'(2) Create a file called 19d2:0257 in /etc/usb_modeswitch.d/ with the following contents:# Mobile Broadband USB dongle#DefaultVendor= 0x19d2DefaultProduct= 0x0257TargetVendor= 0x19d2TargetProduct= 0x0257MessageContent=55534243123456782400000080000685000000240000000000000000000000CheckSuccess=20 (3 In order for Network Manager to recognize the device automatically, I add the following line to /etc/rc.localmodprobe usbserial vendor=0x19d2 product=0x0257
iptables not working on mobile broadband
linux;networking;iptables;vpn