Search code examples
network-programmingipifconfig

Networking Homework Questions from PythonAnywhere


What is the IP configuration for your PythonAnywhere server (i.e. what is the output of the shell command used for this purpose)? Optional: Write a function that garners this information from the shell and returns a dictionary of { "interface name": {"ipv4": "ipv4 address", "ipv6": "ipv6 address"} }. Hint: use subprocess.getoutput. What are the MAC addresses for these interfaces? What are all the IPv4 addresses associated with these interfaces? What is the IP subnet associated with each of these addresses? What is the netmask of each of these IP subnets? How many IP addresses are available in each of these subnets? Do any of the interfaces stand out? If so, do some research into what they might imply regarding the structure of PythonAnywhere. Are any of these IP addresses public? If not, prove it. If so, prove it.


Solution

  • Network Management

    open a bash console and use the "ls" command. The IP configuration is....

    'ip address show' (command. 
    

    A list should pop up and all the information is in the pop up.

    using a 3.5 Ipython console

    step by step

    #import subprocess 
    #subprocess.get
    #subprocess.getoutput('ls')
    #ipinfo = subprocess.getoutput('ip address show')
    
    #import ipaddress
    #iface = `ippadress.ipv4 interface
    #iface = ippaddress.ipv4'
    #iface.
    #iface.netmask iface.netmask
    #face.network
    #iface.network.num_addresses