Network API¶
Network configuration classes.
NetworkConfig¶
NetworkConfig
¶
Bases: UCISection
Network configuration manager.
Source code in src/wrtkit/network.py
add_device(device)
¶
add_interface(interface)
¶
get_commands()
¶
Get all UCI commands for network configuration.
Source code in src/wrtkit/network.py
NetworkDevice¶
NetworkDevice
¶
Bases: UCISection
Represents a network device configuration.
Source code in src/wrtkit/network.py
NetworkInterface¶
NetworkInterface
¶
Bases: UCISection
Represents a network interface configuration.
Source code in src/wrtkit/network.py
with_device(value)
¶
with_proto(value)
¶
with_ipaddr(value)
¶
with_netmask(value)
¶
with_gateway(value)
¶
with_master(value)
¶
with_mtu(value)
¶
with_routing_algo(value)
¶
with_gw_mode(value)
¶
with_gw_bandwidth(value)
¶
with_hop_penalty(value)
¶
with_orig_interval(value)
¶
Set the originator interval (for batman-adv) (returns new copy).
with_static_ip(ip, netmask='255.255.255.0', gateway=None)
¶
Configure interface with static IP (returns new copy).
Source code in src/wrtkit/network.py
Usage Example¶
from wrtkit import UCIConfig
from wrtkit.network import NetworkDevice, NetworkInterface
config = UCIConfig()
# Create a bridge
device = NetworkDevice("br_lan")\
.with_name("br-lan")\
.with_type("bridge")\
.with_port("lan1")\
.with_port("lan2")
config.network.add_device(device)
# Create an interface
interface = NetworkInterface("lan")\
.with_device("br-lan")\
.with_static_ip("192.168.1.1", "255.255.255.0")
config.network.add_interface(interface)