0

I have many pptp vpn tunnels or servers to connect to and linux would assign ppp0 for the 1st connection, ppp1 for 2nd connection and so on. I need the interfaces to be fixed so i can forward the connection properly via iptables. Is there a way to fix the interface name to each tunnel?

1 Answer 1

2

That's not the way this is done. The way to do it is specified in the ever-helpful Arch Linux wiki, under the heading Split Tunneling based on port by /etc/ppp/ip-up.d.

Let me explain. All files in /etc/ppp/ip-up.d are executed every time a pptp connection is established, and the file 01-routebyport.sh is passed the following arguments,as per the Web page above:

  # This script is called with the following arguments:
  # Arg Name
  # $1 Interface name
  # $2 The tty
  # $3 The link speed
  # $4 Local IP number
  # $5 Peer IP number
  # $6 Optional ``ipparam'' value foo

Thus, since you are passed the peer IP number and the interface name, you can build your iptables rules by means of case:

  case $5 in:
        1.1.1.1) 
                   iptables -i $1 -j DROP
        8.8.8.8) 
                      iptables -i$1-j ACCEPT

and so on.

3
  • So i guess it's not possible to use a custom interface name? Thanks for the url & script. I am a little familiar with shell scripting, i shall see what i can do. Sep 15, 2015 at 10:55
  • @13thMatrix It is better than it's not possible to use a custom interface name: you do not have to know what each interface is called, you can let your own pc do that for you, an still make it work. Less work for you. Sep 15, 2015 at 11:05
  • I finally manage to script up everything. It's a little more complicated as thought because i have numerous VPN connections which need many iptables rules for forwarding. Thanks. Nov 6, 2015 at 5:39

You must log in to answer this question.

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