github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/network/debinterfaces/testdata/ifupdown-examples (about)

     1  # This is a copy of the example interfaces file from the ifupdown
     2  # package.
     3  
     4  ######################################################################
     5  # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
     6  #
     7  # A "#" character in the very first column makes the rest of the line
     8  # be ignored. Blank lines are ignored. Lines may be indented freely.
     9  # A "\" character at the very end of the line indicates the next line
    10  # should be treated as a continuation of the current one.
    11  #
    12  # The "pre-up", "up", "down" and "post-down" options are valid for all 
    13  # interfaces, and may be specified multiple times. All other options
    14  # may only be specified once.
    15  #
    16  # See the interfaces(5) manpage for information on what options are 
    17  # available.
    18  ######################################################################
    19  
    20  # The loopback interface isn't really required any longer,
    21  # but can be used if needed.
    22  #
    23  auto lo
    24  iface lo inet loopback
    25  
    26  # An example ethernet card setup: (broadcast and gateway are optional)
    27  #
    28  auto eth0
    29  iface eth0 inet static
    30      address 192.168.0.42/24
    31      gateway 192.168.0.1
    32  
    33  # A more complicated ethernet setup, with a less common netmask, and a downright
    34  # weird broadcast address: (the "up" lines are executed verbatim when the 
    35  # interface is brought up, the "down" lines when it's brought down)
    36  #
    37  auto eth0
    38  iface eth0 inet static
    39      address 192.168.1.42/25
    40      up route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2
    41      up route add default gw 192.168.1.200
    42      down route del default gw 192.168.1.200
    43      down route del -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2
    44  
    45  # A more complicated ethernet setup with a single ethernet card with
    46  # two interfaces.
    47  # Note: This happens to work since ifconfig handles it that way, not because
    48  # ifup/down handles the ':' any differently.
    49  # Warning: There is a known bug if you do this, since the state will not
    50  # be properly defined if you try to 'ifdown eth0' when both interfaces
    51  # are up. The ifconfig program will not remove eth0 but it will be
    52  # removed from the interfaces state so you will see it up until you execute:
    53  # 'ifdown eth0:1 ; ifup eth0; ifdown eth0'
    54  # BTW, this is "bug" #193679 (it's not really a bug, it's more of a 
    55  # limitation)
    56  #
    57  auto eth0 eth0:1
    58  iface eth0 inet static
    59      address 192.168.0.100/24
    60      gateway 192.168.0.1
    61  iface eth0:1 inet static
    62      address 192.168.0.200
    63      netmask 255.255.255.0
    64  
    65  # Another way to accomplish this:
    66  #
    67  auto eth0
    68  iface eth0 inet static
    69      address 192.168.0.100/24
    70      gateway 192.168.0.1
    71  iface eth0 inet static
    72      address 192.168.0.200
    73      netmask 255.255.255.0
    74  #
    75  # However, when specifying multiple addresses this way, there will be no
    76  # way to add or remove them individually using ifup/ifdown only.
    77  
    78  # "pre-up" and "post-down" commands are also available. In addition, the
    79  # exit status of these commands are checked, and if any fail, configuration
    80  # (or deconfiguration) is aborted. So:
    81  #
    82  auto eth0
    83  iface eth0 inet dhcp
    84      pre-up [ -f /etc/network/local-network-ok ]
    85  #
    86  # will allow you to only have eth0 brought up when the file 
    87  # /etc/network/local-network-ok exists.
    88  
    89  # Two ethernet interfaces, one connected to a trusted LAN, the other to
    90  # the untrusted Internet. If their MAC addresses get swapped (because an
    91  # updated kernel uses a different order when probing for network cards,
    92  # say), then they don't get brought up at all.
    93  #
    94  auto eth0 eth1
    95  iface eth0 inet static
    96      address 192.168.42.1
    97      netmask 255.255.255.0
    98      pre-up /path/to/check-mac-address.sh eth0 11:22:33:44:55:66
    99      pre-up /usr/local/sbin/enable-masq
   100  iface eth1 inet dhcp
   101      pre-up /path/to/check-mac-address.sh eth1 AA:BB:CC:DD:EE:FF
   102      pre-up /usr/local/sbin/firewall
   103  
   104  # Two ethernet interfaces, one connected to a trusted LAN, the other to
   105  # the untrusted Internet, identified by MAC address rather than interface
   106  # name:
   107  #
   108  auto eth0 eth1
   109  mapping eth0 eth1
   110      script /path/to/get-mac-address.sh
   111      map 11:22:33:44:55:66 lan
   112      map AA:BB:CC:DD:EE:FF internet
   113  iface lan inet static
   114      address 192.168.42.1
   115      netmask 255.255.255.0
   116      pre-up /usr/local/sbin/enable-masq $IFACE
   117  iface internet inet dhcp
   118      pre-up /usr/local/sbin/firewall $IFACE
   119  
   120  # A PCMCIA interface for a laptop that is used in different locations:
   121  # (note the lack of an "auto" line for any of these)
   122  #
   123  mapping eth0
   124     script /path/to/pcmcia-compat.sh
   125     map home,*,*,*                  home
   126     map work,*,*,00:11:22:33:44:55  work-wireless
   127     map work,*,*,01:12:23:34:45:50  work-static
   128  #
   129  iface home inet dhcp
   130  iface work-wireless bootp
   131  iface work-static static
   132      address 10.15.43.23
   133      netmask 255.255.255.0
   134      gateway 10.15.43.1
   135  #
   136  # Note, this won't work unless you specifically change the file
   137  # /etc/pcmcia/network to look more like:
   138  #
   139  #     if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi
   140  #     get_info $DEVICE
   141  #     case "$ACTION" in
   142  #         'start')
   143  #             /sbin/ifup $DEVICE
   144  #             ;;
   145  #         'stop')
   146  #             /sbin/ifdown $DEVICE
   147  #             ;;
   148  #     esac
   149  #     exit 0
   150  
   151  # An alternate way of doing the same thing: (in this case identifying
   152  # where the laptop is is done by configuring the interface as various
   153  # options, and seeing if a computer that is known to be on each particular
   154  # network will respond to pings. The various numbers here need to be chosen
   155  # with a great deal of care.)
   156  #
   157  mapping eth0
   158     script /path/to/ping-places.sh
   159     map 192.168.42.254/24 192.168.42.1 home
   160     map 10.15.43.254/24 10.15.43.1 work-wireless
   161     map 10.15.43.23/24 10.15.43.1 work-static
   162  #
   163  iface home inet dhcp
   164  iface work-wireless bootp
   165  iface work-static static
   166      address 10.15.43.23
   167      netmask 255.255.255.0
   168      gateway 10.15.43.1
   169  #
   170  # Note that the ping-places script requires the iproute package installed,
   171  # and the same changes to /etc/pcmcia/network are required for this as for
   172  # the previous example.
   173  
   174  
   175  # Set up an interface to read all the traffic on the network. This 
   176  # configuration can be useful to setup Network Intrusion Detection
   177  # sensors in 'stealth'-type configuration. This prevents the NIDS
   178  # system to be a direct target in a hostile network since they have
   179  # no IP address on the network. Notice, however, that there have been
   180  # known bugs over time in sensors part of NIDS (for example see 
   181  # DSA-297 related to Snort) and remote buffer overflows might even be
   182  # triggered by network packet processing.
   183  # 
   184  auto eth0
   185  iface eth0 inet manual
   186  	up ifconfig $IFACE 0.0.0.0 up
   187  	up ip link set $IFACE promisc on
   188  	down ip link set $IFACE promisc off
   189  	down ifconfig $IFACE down
   190  
   191  # Set up an interface which will not be allocated an IP address by
   192  # ifupdown but will be configured through external programs. This
   193  # can be useful to setup interfaces configured through other programs,
   194  # like, for example, PPPOE scripts.
   195  #
   196  auto eth0
   197  iface eth0 inet manual
   198        up ifconfig $IFACE 0.0.0.0 up
   199        up /usr/local/bin/myconfigscript
   200        down ifconfig $IFACE down