def nat_config_save(self, req, **kwargs): json_body = json.loads(req.body) save_dict = 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 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 = 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 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 = {} # Default settings modify these value to fit your requirements 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 settings.save(save_dict): pp = pprint.PrettyPrinter(indent=2) pp.pprint(save_dict) return Response(status=200) else: return Response(status=400)