===========
**ifup** and **ifdown** commands can be used to configure (or, respectively,
deconfigure) network interfaces based on interface definitions in the
- file **/etc/network/interfaces/** file.
+ config file ifupdown2.conf (defaults to **/etc/network/interfaces/** file).
**ifquery(8)** maybe used in conjunction with **ifup** and **ifdown**
commands to query and validate applied/running configuration.
- **ifup** always works on the current **interfaces(5)** file under
- **/etc/network/interfaces**. **ifdown** works on the last applied interface
+ **ifup** always works on the current **interfaces(5)** file defined in ifupdown2.conf
+ (default **/etc/network/interfaces**). **ifdown** works on the last applied interface
configuration.
**ifup** on an already ifup'ed interface will re-apply the configuration,
to be excluded.
-i INTERFACESFILE, --interfaces INTERFACESFILE
- Use interfaces file instead of default
- /etc/network/interfaces
+ Uses interfaces file instead of default defined in
+ ifupdown2.conf (default /etc/network/interfaces).
+ Also in ifupdown2.conf, users are not allowed to specify their own
+ interfaces file unless disable_cli_interfacesfile is set to 0
+ (default is 1).
-t {native,json}, --interfaces-format {native,json}
interfaces file format
configmap_g=None
logger = None
interfacesfileiobuf=None
+interfacesfilename=None
ENVPATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
def run_up(args):
cache=cachearg,
addons_enable=not args.noaddons,
statemanager_enable=not args.noaddons,
- interfacesfile=args.interfacesfile,
+ interfacesfile=interfacesfilename,
interfacesfileiobuf=interfacesfileiobuf,
interfacesfileformat=args.interfacesfileformat)
if args.noaddons:
dryrun=args.noact,
addons_enable=not args.noaddons,
statemanager_enable=not args.noaddons,
- interfacesfile=args.interfacesfile,
+ interfacesfile=interfacesfilename,
interfacesfileiobuf=interfacesfileiobuf,
interfacesfileformat=args.interfacesfileformat)
withdepends=args.withdepends,
perfmode=args.perfmode,
cache=cachearg,
- interfacesfile=args.interfacesfile,
+ interfacesfile=interfacesfilename,
interfacesfileiobuf=interfacesfileiobuf,
interfacesfileformat=args.interfacesfileformat)
try:
logger.debug('creating ifupdown object ..')
ifupdown_handle = ifupdownMain(config=configmap_g,
+ interfacesfile=interfacesfilename,
withdepends=args.withdepends,
perfmode=args.perfmode)
ifupdown_handle.reload(['pre-up', 'up', 'post-up'],
def init(args):
global logger
global interfacesfileiobuf
+ global interfacesfilename
log_level = logging.WARNING
if args.verbose:
except:
raise
- # If interfaces file is stdin, read
- if hasattr(args, 'interfacesfile') and args.interfacesfile == '-':
- interfacesfileiobuf = sys.stdin.read()
+ if hasattr(args, 'interfacesfile') and args.interfacesfile != None:
+ # Check to see if -i option is allowed by config file
+ if configmap_g.get('disable_cli_interfacesfile','1') == '1':
+ logger.error('disable_cli_interfacesfile is set so users '
+ 'not allowed to specify interfaces file on cli.')
+ exit(1)
+ if args.interfacesfile == '-':
+ # If interfaces file is stdin, read
+ interfacesfileiobuf = sys.stdin.read()
+ else:
+ interfacesfilename = args.interfacesfile
+ else:
+ # if the ifupdown2 config file does not have it, default to standard
+ interfacesfilename = configmap_g.get('default_interfaces_configfile',
+ '/etc/network/interfaces')
+
+
+
def deinit():
{}
help='Exclude interfaces from the list of interfaces' +
' to operate on. Can be specified multiple times.')
argparser.add_argument('-i', '--interfaces', dest='interfacesfile',
- default='/etc/network/interfaces',
- help='use interfaces file instead of default ' +
- '/etc/network/interfaces')
+ default=None,
+ help='Specify interfaces file instead of file defined ' +
+ 'in ifupdown2.conf file')
argparser.add_argument('-t', '--interfaces-format',
dest='interfacesfileformat',
default='native',