Last active
June 14, 2017 17:33
-
-
Save pianomanfrazier/51d89c96e1e3fec847c57108b31d38cd to your computer and use it in GitHub Desktop.
Setup virtual box VM host only adapter networking. Works for Debian 3.16 64 bit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""This sets up a Debian VM for host-only network adapter""" | |
import argparse | |
from subprocess import call | |
parser = argparse.ArgumentParser(description="setup VM for host only networking") | |
parser.add_argument('--ip', '-ip', required=True, help='an ip address for host only adapter') | |
args = vars(parser.parse_args()) | |
ifconfig = "ifconfig eth1 {} netmask 255.255.255.0 up".format(args['ip']) | |
interface = """# The host-only network interface | |
auto eth1 | |
iface eth1 inet static | |
address {} | |
netmask 255.255.255.0 | |
network 192.168.56.0 | |
broadcast 192.168.56.255""".format(args['ip']) | |
host = "{}\tlocalhost".format(args['ip']) | |
#call(ifconfig, shell=True) | |
with open("/etc/network/interfaces", "a") as fout: | |
fout.write(interface) | |
with open("/etc/hosts", "a") as fout: | |
fout.write(host) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment