-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81b9d59
commit 8aec1b9
Showing
1 changed file
with
28 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,37 @@ assign lan interfaces, create vlans, vlan-interfaces and setup dhcp in a single | |
- my opnsense runs in a vm, so it really doesnt matter for me | ||
- i just add the interfaces via libvirt and all i need to do is to enable them, given the /conf/config.xml method | ||
|
||
### copy tjhe config file to your machine | ||
## usage | ||
```python | ||
from opnsensehelper import helper | ||
filepath = '/home/ji/confignew.xml' | ||
output="/home/ji/.ansible/collections/ansible_collections/ji_podhead/podnet/plugins/x.xml" | ||
conf_path="/conf/config.xml" | ||
vlan3 ={'parentinterface': 'vtnet1', 'tag': '3', 'pcp': '0', 'proto': None, 'descr': 'vlan3', 'vlanif': 'vlan0.3',"attr":{"uuid":"cb503df8-821d-4acd-86ba-66b35e4df17n"}} | ||
vlan4 ={'parentinterface': 'vtnet1', 'tag': '4', 'pcp': '0', 'proto': None, 'descr': 'vlan4', 'vlanif': 'vlan0.4',"attr":{"uuid":"cb503df8-821d-4acd-86ba-66b35e4s7c"}} | ||
opt3_dhcp= {'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.3.10', '_to': '200.0.3.100'},"attr":None} | ||
opt4_dhcp= {'enable': '1', 'ddnsdomainalgorithm': 'hmac-md', "range":{'from': '200.0.4.10', '_to': '200.0.4.100'},"attr":None} | ||
opt3_interface= {'descr': 'vlan3', 'enable': '1', 'ipaddr': '200.0.3.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:03', 'attr': {}} | ||
opt4_interface= {'descr': 'vlan4', 'enable': '1', 'ipaddr': '200.0.3.1', 'subnet': '24', 'type': None, 'virtual': None, 'spoofmac': '00:00:00:00:00:04', 'attr': {}} | ||
helper=opnsensehelper(filepath,True,"root","opnsense","192.168.1.103") | ||
helper.get_file(conf_path, output) | ||
helper.initialize() | ||
helper.objects["dhcpd"]["opt3"]=opt3_dhcp | ||
helper.objects["dhcpd"]["opt4"]=opt4_dhcp | ||
helper.objects["vlans"]["vlan3"]=vlan3 | ||
helper.objects["vlans"]["vlan4"]=vlan4 | ||
helper.objects["interfaces"]["opt3"]=opt3_interface | ||
helper.objects["interfaces"]["opt4"]=opt4_interface | ||
helper.save(output) | ||
helper.put_file(output,conf_path) | ||
helper.close_con() | ||
``` | ||
|
||
### copy the config file to your machine manually | ||
```bash | ||
scp [email protected]:/conf/config.xml /home/user/confignew.xml && chmod +x /home/user/confignew.xml && chown user:user /home/user/confignew.xml | ||
``` | ||
### replace the original file | ||
### replace the original file manually | ||
```bash | ||
scp /home/user/config.xml [email protected]:/conf/config.xml | ||
``` |