def nat_config_save(self, req, **kwargs): json_body = json.loads(req.body) save_dict = nat_settings.load() if save_dict is None: save_dict = {} save_dict['wan_port'] = json_body.get('wanPort') save_dict['public_ip'] = IPAddress(json_body.get('publicIP')) public_gateway = json_body.get('publicGateway') save_dict['public_gateway'] = IPAddress(public_gateway) save_dict['public_ip_subnetwork'] = IPNetwork(public_gateway + '/24') net = json_body.get('privateNetwork') + '/24' save_dict['private_subnetwork'] = IPNetwork(net) save_dict['private_gateway'] = IPNetwork(net)[1] save_dict['broadcast_ip'] = IPNetwork(net)[255] save_dict['dns_ip'] = IPAddress('8.8.8.8') save_dict['mac_on_dhcp'] = '08:00:27:b8:0f:8d' save_dict['mac_on_wan'] = '00:0e:c6:87:a6:fb' save_dict['mac_on_lan'] = '00:0e:c6:87:a6:fa' if nat_settings.save(save_dict): pp = pprint.PrettyPrinter(indent=2) pp.pprint(save_dict) return Response(status=200) else: return Response(status=400)
def nat_config_save(self, req, **kwargs): json_body = json.loads(req.body) save_dict = nat_settings.load() if save_dict is None: save_dict = {} save_dict['wan_port'] = json_body.get('wanPort') save_dict['nat_public_ip'] = IPAddress(json_body.get('natPublicIp')) save_dict['default_gateway'] = IPAddress(json_body.get('defaultGateway')) net = json_body.get('natPrivateNetwork') + '/24' save_dict['ip_network'] = IPNetwork(net) save_dict['dhcp_gw_addr'] = IPNetwork(net)[1] save_dict['broadcast_addr'] = IPAddress('192.168.8.255') save_dict['dns_addr'] = IPAddress('8.8.8.8') save_dict['dhcp_hw_addr'] = '08:00:27:b8:0f:8d' save_dict['MAC_ON_WAN'] = '00:0e:c6:87:a6:fb' save_dict['MAC_ON_LAN'] = '00:0e:c6:87:a6:fa' if nat_settings.save(save_dict): pp = pprint.PrettyPrinter(indent=2) pp.pprint(save_dict) return Response(status=200) else: return Response(status=400)
def nat_config_init(self, req, **kwargs): save_dict = {} save_dict['wan_port'] = 1 save_dict['public_ip'] = IPAddress('140.114.71.178') save_dict['public_gateway'] = IPAddress('140.114.71.254') save_dict['public_ip_subnetwork'] = IPNetwork('140.114.71.0/24') network = '192.168.8.0/24' save_dict['private_subnetwork'] = IPNetwork(network) save_dict['private_gateway'] = IPNetwork(network)[1] save_dict['broadcast_ip'] = IPAddress('192.168.8.255') save_dict['dns_ip'] = IPAddress('8.8.8.8') save_dict['mac_on_dhcp'] = '08:00:27:b8:0f:8d' save_dict['mac_on_wan'] = '00:0e:c6:87:a6:fb' save_dict['mac_on_lan'] = '00:0e:c6:87:a6:fa' if nat_settings.save(save_dict): pp = pprint.PrettyPrinter(indent=2) pp.pprint(save_dict) return Response(status=200) else: return Response(status=400)
def nat_config_init(self, req, **kwargs): save_dict = {} save_dict['wan_port'] = 1 save_dict['nat_public_ip'] = IPAddress('140.114.71.178') save_dict['default_gateway'] = IPAddress('140.114.71.254') network = '192.168.8.0/24' save_dict['ip_network'] = IPNetwork(network) save_dict['dhcp_gw_addr'] = IPNetwork(network)[1] save_dict['broadcast_addr'] = IPAddress('192.168.8.255') save_dict['dns_addr'] = IPAddress('8.8.8.8') save_dict['dhcp_hw_addr'] = '08:00:27:b8:0f:8d' save_dict['MAC_ON_WAN'] = '00:0e:c6:87:a6:fb' save_dict['MAC_ON_LAN'] = '00:0e:c6:87:a6:fa' if nat_settings.save(save_dict): pp = pprint.PrettyPrinter(indent=2) pp.pprint(save_dict) return Response(status=200) else: return Response(status=400)