Giter VIP home page Giter VIP logo

network-config-manager's Introduction

network-config-manager

build

What is nmctl

The network-config-manager nmctl allows to configure and introspect the state of the network links as seen by systemd-networkd. nmctl can be used to query and configure devices's for Address, Routes, Gateways, DNS, NTP, domain, hostname. nmctl also allows to create virtual NetDev (VLan, VXLan, Bridge, Bond) etc. It also allows to configure link's various configuration such as WakeOnLanPassword, Port, BitsPerSecond, Duplex and Advertise etc. nmctl uses sd-bus, sd-device APIs to interact with systemd, systemd-networkd, systemd-resolved, systemd-hostnamed, and systemd-timesyncd via dbus. nmctl uses networkd verbs to explain output. nmctl can generate configurations for required network links from YAML description. It also understands kernel command line specified in dracut's network configuration format and can generate systemd-networkd's configuration while the system boots and will persist between reboots.

Features

Configure

  • Static IPv4 and IPv6 Address, Routes, Gateway.
  • DHCPv4/DHCPv6 Client (DHCP4 Client Identifier, UseMTU/UseDNS/UseDomains/UseNTP/UseRoutes).
  • LLDP, Link Local Addressing, IPv4LLRoute, LLMNR.
  • Per Link and global DNS, Domains
  • NTP
  • Routing Policy Rule
  • Multiple default gateway with routing policy rules.
  • Link's MAC, MTU, ARP, Multicast, AllMulticast, Promiscuous, Unmanaged, Group, RequiredForOnline, RequiredFamilyForOnline, and ActivationPolicy.
  • Create netdevs, vlan, vxlan, bridge, bond, veth, macvlan/macvtap, ipvlap/ipvtap, veth, tunnels(ipip, sit, gre, sit, vti), wireguard.
  • Hostname.
  • DHCPv4 Server.
  • DHCPv4 Server Static Lease.
  • IPv6 Router Advertisements.
  • Network and Link SRIOV
  • Add delete and view nftables table, chains and rules.
  • Edit network / link configuration via vim/vi.

Please see systemd.network for more information.

Device's

  • Alias, Description, MTUBytes, WakeOnLan, WakeOnLanPassword, Port, BitsPerSecond, Duplex and Advertise.
  • Offload parameters and other features.
  • MACAddressPolicy or MACAddress.
  • NamePolicy or Name.
  • AlternativeNamesPolicy or AlternativeName.
  • Pending packets receive buffer.
  • Queue size.
  • Flow control.
  • GSO.
  • Channels.
  • Coalesce.
  • Coalesced frames.
  • Coalesce packet rate.

Please see systemd.link for more information.

Allow to generates systemd-networkd's configuration

  • Flexible netplan like network configuration from YML file.
  • Dracut kernel command line network config.

Introspect

  • Links.
  • DNS and Domains.
  • Hostname.
  • nftable
  • Allows to export in JSON format.

Building from source.

~ meson build
➜  ~ ninja -C build
➜  ~ sudo ninja -C build install

Or by simply doing

❯ make
❯ sudo make install

Building in photon OS.

❯ git clone [email protected]:vmware/network-config-manager.git
❯ cd network-config-manager
❯ wget https://raw.githubusercontent.com/vmware/photon/master/SPECS/network-config-manager/network-config-manager.spec
❯ sudo rpmspec -q --srpm --requires network-config-manager.spec | sudo xargs -d '\n' tdnf -y install
❯ make
❯ sudo make install

Use cases

~ nmctl --help

Howto get started with nmctl

Contributing

The network-config-manager project team welcomes contributions from the community. If you wish to contribute code and you have not signed our contributor license agreement (CLA), our bot will update the issue when you open a Pull Request. For any questions about the CLA process, please refer to our FAQ.

network-config-manager's People

Contributors

jaankit avatar ntsbtz avatar ssahani avatar tapakund avatar tianyuanhao avatar vmwsrpbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

network-config-manager's Issues

add-route did not add CIDR [0.5.2]

Describe the bug

OS: PhotonOS 4.0
Network-config-manager: v0.5.2 (0.5.2-1.ph4.x86_64)

Using 'add-route' command the CIDR part will be ignored.

Reproduction steps

root@photonOS [ ~ ]# nmctl add-route eth0 gw 10.1.2.2 dest 10.5.5.0/24
root@photonOS [ ~ ]# ip r
default via 172.17.63.1 dev eth2 proto static
10.1.2.0/24 dev eth0 proto kernel scope link src 10.1.2.3
10.5.5.0 via 10.1.2.2 dev eth0 proto static
172.17.63.0/24 dev eth2 proto kernel scope link src 172.17.63.40
root@photonOS [ ~ ]#

Expected behavior

In /etc/systemd/network/10-eth0.network we should found:
[Route]
Gateway=10.1.2.2
Destination=10.5.5.0/24

Executing 'ip r' we should have:
10.5.5.0/24 via 10.1.2.2 dev eth0 proto static

Additional context

/etc/systemd/network/10-eth0.network content:
[Match]
Name=eth0

[Network]

[Address]
Address=10.1.2.3/24

[Route]
Gateway=10.1.2.2
Destination=10.5.5.0

add-default-gateway write 'Gateway' tag inside Route section instead of 'Network' section

Describe the bug

Hello,

When you execute: nmctl add-default-gateway eth3 gw 10.1.1.1

It should add in [Network] section the Gateway tag, instead it is added in [Route] section.

This cause default gateway loose if you then add some static route using 'add-route'.

Regards

Reproduction steps

nmctl add-default-gateway eth3 gw 10.1.1.1

You will find in:
in /etc/systemd/network/.network:
[Route]
Gateway=10.1.1.1

Expected behavior

in /etc/systemd/network/.network:
[Network]
Gateway=10.1.1.1

[Address]
Address=xxx.xxx.xxx.xxx/yy

Additional context

No response

Requires get APIs corresponding to each configure API in public Header

In include/network-config-manager.h

I see following APIs to configure the network:

int ncm_link_add_default_gateway(int argc, char *argv[]);

int ncm_link_set_dhcp4_section(int argc, char *argv[]);
int ncm_link_set_dhcp6_section(int argc, char *argv[]);

int ncm_link_set_dhcp_client_duid(int argc, char *argv[]);

int ncm_link_set_mode(int argc, char *argv[]);
int ncm_link_set_network_section_bool(int argc, char *argv[]);
int ncm_link_update_state(int argc, char *argv[]);

int ncm_link_enable_ipv6(int argc, char *argv[]);

int ncm_revert_resolve_link(int argc, char *argv[]);

int ncm_create_vlan(int argc, char *argv[]);
int ncm_create_bridge(int argc, char *argv[]);
int ncm_create_bond(int argc, char *argv[]);
int ncm_create_vxlan(int argc, char *argv[]);
int ncm_create_macvlan(int argc, char *argv[]);
int ncm_create_ipvlan(int argc, char *argv[]);
int ncm_create_vrf(int argc, char *argv[]);
int ncm_create_veth(int argc, char *argv[]);
int ncm_create_tunnel(int argc, char *argv[]);
int ncm_create_wireguard_tunnel(int argc, char *argv[]);

But there are no corresponding get APIs to check if the above configuration actually done correctly or not.

Also, i think there is no need of show APIs in public Header for development using ncm-devel like below:

int ncm_link_status(int argc, char *argv[]);
int ncm_show_dns_server(int argc, char *argv[]);
int ncm_show_dns_server_domains(int argc, char *argv[]);
int ncm_show_version(void);   --> we can replace it with ncm_get_version(char **version);
int ncm_nft_show_tables(int argc, char *argv[]);
int ncm_nft_show_chains(int argc, char *argv[]);
int ncm_nft_show_rules(int argc, char *argv[]);

I think only configure and get API are required.

nmctl is crashing with SIGSEGV

Describe the bug

nmctl is crashing while running the command to get status in json format.

command - nmctl status -j

Looks like unallocated memory trying to free.

Ran with gdb below is the backtrace for crash

Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x410) at malloc.c:3102
3102 malloc.c: No such file or directory.
(gdb) bt
#0 __GI___libc_free (mem=0x410) at malloc.c:3102
#1 0x0000555555567cfc in freep (p=0x7fffffffdbc8) at ../src/share/alloc-util.h:23
#2 0x000055555556952d in json_system_status (ret=0x0) at ../src/json/network-json.c:159
#3 0x0000555555571540 in ncm_system_status (argc=1, argv=0x7fffffffe038) at ../src/manager/ctl-display.c:676
#4 0x0000555555563625 in ctl_run_command (m=0x5555555f3ff0, argc=3, argv=0x7fffffffe038) at ../src/ctl/ctl.c:99
#5 0x00005555555c231a in cli_run (argc=3, argv=0x7fffffffe028) at ../src/manager/network-manager-ctl.c:490
#6 0x00005555555c237d in main (argc=3, argv=0x7fffffffe028) at ../src/manager/network-manager-ctl.c:496
(gdb)

Reproduction steps

  1. Install network-config-manager
  2. Run the nmctl command with json flag
    nmctl status -j
    ...

Expected behavior

nmctl status -j
{
"System Name": "ubuntu",
"KernelName": "Linux",
"KernelRelease": "5.15.0-69-generic",
"SystemdVersion": "245.4-4ubuntu3.20",
"Architecture": "x86-64",
"Virtualization": "vmware",
"OperatingSystem": "Ubuntu 20.04.6 LTS",
"MachineID": "4e089520c6b24ba8870ac4f2eff22abf",
"OperationalState": "routable",
"CarrierState": "carrier",
"Addresses": [
{
"ifname": "ens33",
"ip": "fe80::c099:2598:cc4c:14d1/64",
"family": "ipv6",
"ifindex": 2
},
{
"ifname": "lo",
"ip": "::1/128",
"family": "ipv6",
"ifindex": 1
},
{
"ifname": "lo",
"ip": "127.0.0.1/8",
"family": "ipv4",
"ifindex": 1
},
{
"ifname": "ens33",
"ip": "172.16.61.154/24",
"family": "ipv4",
"ifindex": 2
}
],
"Routes": [
{
"ifname": "ens33",
"gateway": "172.16.61.2",
"destination": "0.0.0.0",
"family": "ipv4",
"ifindex": 2
}
],
"DNS": [
"1.2.3.4",
"2.3.4.5",
"6.7.8.9",
"172.16.61.2"
],
"Domains": [
"localdomain"
]
}

Additional context

No response

Document set-ipv4 and set-ipv6

Is your feature request related to a problem? Please describe.

set-ipv4 and set-ipv6 behaves diffrently with keep yes. We need to document it with other detail how it works

Describe the solution you'd like

Document it

Describe alternatives you've considered

No response

Additional context

No response

add-route replace previously added routes

Describe the bug

Hello,

If you execute multiple time "nmctl add-route" only last occurrence will be kept.

Regards

Reproduction steps

  1. nmctl add-route eth3 gw 10.100.10.2 dest 10.1.1.0/24
  2. nmctl add-route eth3 gw 10.100.10.2 dest 10.1.2.0/24
  3. nmctl add-route eth3 gw 10.100.10.5 dest 10.1.4.0/24

In /etc/system.d/network/10-eth3.network you will find only one occurrence of 'Route' section with the latest executed command.

Expected behavior

'/etc/system.d/network/10-eth3.network' should contain the following:
[Route]
Gateway=10.100.10.2
Destination=10.1.1.0/24

[Route]
Gateway=10.100.10.2
Destination=10.1.2.0/24

[Route]
Gateway=10.100.10.5
Destination=10.1.4.0/24

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.