跳转到内容
Ask AI

Basic Configuration

此内容尚不支持你的语言。

By default, AsterNOS devices support login through both the serial console and SSH (Secure Shell).

When initially logging into the switch, you will need to use the console port (referred to as the serial port below) to establish a connection. After configuring the management interface’s IP address, you can then use SSH to log into the switch. Local login via the serial console is the fundamental method for accessing the device, and it forms the basis for configuring other login methods. The specific steps are as follows:

This series of switches utilize RJ-45 connectors for serial console connections. The distribution of serial console ports varies among different models. Generally, they can be found on the front panel of the device, while some might be located on the rear panel, often marked with the label “CON.”

After the device is powered on, connect the switch’s serial console port to a server or PC. It’s important to ensure that the communication parameter settings of the user terminal match the default configuration of the switch’s serial console to establish communication. The default values for each parameter are as shown in the table below:

ParameterDefault Value
Baud Rate115200
Data Bits8
Stop Bits1
ParityNone
  1. Initial Login via Console Port: Connect to the device through the Console port. After pressing Enter, a login prompt will appear.
Welcome to minicom 2.7 OPTIONS: I18n
Compiled on Nov 15 2018, 20:18:47.
Port /dev/ttyUSB1, 11:24:17 Press CTRL-A Z for help on special keys
Debian GNU/Linux 9 sonic ttyS0
sonic login:
  1. Logging into the Device with Default Credentials:

Username: admin

Password: asteros

sonic login: admin
Password:
Last login: Thu Nov 3 17:17:59 UTC 2016 from 192.168.0.79 on pts/0
Linux sonic 5.10.34-asternos #5 SMP PREEMPT Thu Jul 14 08:20:14 EDT 2022 aarch64
_ _ _ _ ___ ____
/ \ ___ | |_ ___ _ __ | \ | | / _ \ / ___|
/ _ \ / __| | __| / _ \| '__|| \| || | | |___ \
/ ___ \ __ \ | |_ | __/ | | | |\ || |_| | ___) |
/_/ _\|___/ __| ___| |_| |_| _| ___/ |____/
------- Asterfusion Network Operating System -------
Help: http://www.asterfusion.com/
Last login: Wed Jun 23 06:44:22 2021 from 192.168.10.198
...Entering cli view, please wait...
sonic#
  1. Configuring the Management Interface IP Address:
sonic# configure
sonic(config)# interface mgmt 0
sonic(config-mgmt-0)# ip address 30.1.1.2/24 30.1.1.1
sonic(config-mgmt-0)# vrf mgmt
  1. Saving the Configuration:
sonic# write
save running-config...
Existing files will be overwritten, continue? [y/N]: y
Running command: /usr/local/bin/sonic-cfggen -d --print-data > /etc/sonic/config_db.json

Getting Familiar with Using CISCO-LIKE Command Line

Section titled “Getting Familiar with Using CISCO-LIKE Command Line”
OperationCommandDescription
Enter the CLI viewsudo sonic cliBy default, upon logging into the device, you will automatically enter the command line view.
Exit the CLI viewsystem bashUse the ‘exit’ command to return to the command line configuration interface.
KeywordsDescription
noCancel or disable a specific setting
show thisDisplay the current configuration of the current view
configure terminalEnter the system configuration mode
deleteDelete a configuration file
rebootReboot the device
writeSave the current configuration
shutdownDisable or turn off a port
exitExit to the previous level or log out

When entering an incomplete keyword, pressing the Tab or Space key will automatically complete the keyword.

If you encounter issues while using the command line, you can utilize the help function to get assistance, eliminating the need to memorize extensive and intricate commands.

While entering a command, pressing the Tab key will display a list of matching keywords. Entering ”?” will provide hints for relevant keywords or explanations of parameters.

sonic# show <tab>
acl arp counters history image interface link-aggregation
lldp mac-address platform running-config startup-config sub-interface traffic
sonic# configure terminal
sonic(config)# access-list l3 test ingress <tab>
<cr>
sonic(config)# access-list l3 test <enter>
Syntax error: The command is not completed
sonic(config)# access-list l3 test1 ingress
sonic(config-l3-acl-test1)# ?
end Exit to the exec Mode
exit Exit from current mode
no Negate a command or set its defaults
rule Add an access list entry
show show running-config
sonic(config-l3-acl-test1)# rule ?
rule ID (0..500)
sonic(config-l3-acl-test1)# rule 1 ?
source-mac Specify source mac address
destination-mac Specify destination mac address
ethernet-type Specify ethernet protocol type
outer-vlan Specify outer VLAN id
vlan-pri Specify outer VLAN priority

The configuration files for this series of switches are in JSON (JavaScript Object Notation) format. JSON is a lightweight data interchange format, and its file extension is typically .json.

By default, the system configuration files are stored in the /etc/sonic directory. The default system configuration file is named config_db.json. When performing configuration saving or restoration operations, it’s this file that gets modified, determining the initial configuration upon the device’s next startup. Additionally, this directory also contains backups of configuration files, labeled with timestamps, which facilitates configuration recovery for users. Every time the “write” command is executed, a new config_db.json file is generated to save the current configuration, and the original file’s name is modified to the format config_bd+timestamp.

After a user logs into the device, configurations made through command-line operations or other means are temporary. If you require persistent configurations, you should manually save the modified settings. This involves updating the current configuration to the default configuration file, config_db.json. If you don’t save the configurations, the device’s settings will revert to their state before modifications after a reboot.

OperationMaintenance InterfaceCommandDescription
Save configurationwrite
Display startup configurationshow startup-config

The device supports multiple methods to copy version images onto the target device for upgrading.

In this scenario, the device and a file server establish communication. The device functions as a TFTP client, while the file server operates as a TFTP server. The objective is to download the version image stored on the server to the device, thereby accomplishing the software version upgrade.

  1. Configure the IP address of the file server, ensuring that the file server and the device are routable.
  2. Start the TFTP server on the device to initiate the download of the version image.
admin@sonic:~$ tftp
tftp> help
tftp> connect
(to) 150.1.0.1
tftp> get AsterNOS-V5.2R001.bin
Received 17437 bytes in 0.0 seconds
tftp> quit
admin@sonic:~$ ls
AsterNOS-V5.2R001.bin

  1. Configure the IP address of the file server to ensure that the file server and the device are reachable via routing.
  2. On the device, use the SCP command to complete the download of the version image.
admin@sonic:~$ sudo scp server@192.168.0.100:/share/ AsterNOS-V5.2R001.bin
admin@sonic:~$ ls
AsterNOS-V5.2R001.bin

This method is suitable when there is no network environment available, and you need to copy the version image to the device. Typically, the USB port of the device is located on the front panel.

  1. Insert the USB drive containing the system image into the device’s USB port.
  2. Execute a command to view the disk name corresponding to the USB drive:
Terminal window
admin@sonic:\~$ sudo /sbin/fdisk -l
  1. Create a directory for mounting the USB drive.
Terminal window
admin@sonic:\~$ sudo mkdir /mnt/usb/
  1. Mount the USB drive. Take the example of /dev/sdb4 as the path for the USB drive, but please adjust according to the actual situation.
Terminal window
admin@sonic:\~$ sudo mount /dev/sdb4 /mnt/usb
  1. Navigate to the directory of the mounted disk and copy files from the disk to the device.
admin@sonic:~$ cd /mnt/usb
admin@sonic:/mnt/usb/$ sudo cp AsterNOS-V5.2R001.bin /home/admin
admin@sonic:~$ ls
AsterNOS-V5.2R001.bin
OperationCommandDescription
Execute the upgrade commandimage update image-nameIf a configuration upgrade is required, please execute the “write” command to save the configuration before proceeding with the upgrade. Once the upgrade is completed without any errors, you’ll need to manually restart the device to switch to the new version
Display the versionshow version-

Zero Touch Provisioning (ZTP) refers to the automatic loading of initialization files (configuration files, upgrade files) on newly manufactured or blank devices when they are powered on. This functionality enables devices to be deployed and configured without requiring on-site manual configuration. As a result, ZTP reduces labor costs and enhances deployment efficiency.

As illustrated in the diagram, a device awaiting configuration is connected to a DHCP relay device via its service port or management port. Upon powering on, the device checks whether a ZTP initialization process has been carried out. If yes, it loads the system configuration files and starts the device. If not, the device enters the ZTP initialization process through DHCP.

During this process, the device operates as a DHCP client and sends DHCP request packets to the DHCP server to obtain an IP address and the path to the required upgrade files. Based on the configuration information carried in the received DHCP response packet, the device automatically retrieves version and configuration files from the specified file server. It then proceeds to execute the upgrade command and reboot the device.

Upon completion of the device reboot, automatic loading of both the version and configuration is achieved.

DHCP Server: Used to assign temporary management IP addresses to devices and provide the file server address.

TFTP/FTP Server: Stores the configuration files, version images required for ZTP initialization, and user logs after upgrades are completed.

DHCP Relay: When the device to be upgraded and the DHCP Server are in different network segments, a relay device is needed to forward DHCP packets.

Devices can carry their hardware model and serial number in the packets. TFTP/FTP servers can name version files based on hardware models and name configuration files based on serial numbers, enabling provision of different versions and independent configuration files for devices of various models and serial numbers.

The workflow of ZTP is illustrated in the diagram below:

The DHCP server passes network configuration parameters to the device through the Option field. When the device to be configured is not on the same subnet as the DHCP server, a DHCP relay needs to be configured to forward DHCP interaction messages.

When the device enters the ZTP process, both the management port and service port of the device will send DHCPv4 Discover messages, carrying option 67 to request the path to the intermediate file required for provisioning.

DHCP Option Parameters Description

Option NumberFunction
Option 1Sets the subnet mask for the IP address
Option 3Sets the gateway for the DHCP client
Option 6Sets the IP address of the DNS server
Option 67Sets the path to the intermediate file. Such as: ftp://ftpserver:test@192.168.0.10/ztp.json

The file server is used to store the files that need to be transferred during the ZTP process, including intermediate files, image files, configuration files, and logs. Generally, a third-party server is used as the file server, and during deployment, the network connectivity between the file server and the device must be ensured. The file server supports TFTP and FTP servers.

Place the intermediate file and other provisioning files in the working directory of the file server and rename the files as specified:

Image File: The name should be the device type followed by .bin. For example, if the device type is CX204Y-48GT-M-SWP4, the image file name should be CX204Y-48GT-M-SWP4.bin.

Configuration File: The name should be the device serial number (SN) followed by .bin. For example, if the device SN is F020000A055, the configuration file name should be F020000A055.bin.

Intermediate File: The file must be named exactly ztp.json.

Logs: Logs generated by the device during the ZTP process will be uploaded to the file server after the ZTP process is completed or if it fails for some reason, to facilitate troubleshooting.

ZTP provisioning requires the pre-preparation of provisioning files, including the configuration file and the intermediate file.

The configuration file is in .json format, which the device loads to generate the configuration after startup. The configuration file can be manually written or copied from another device.

To save the configuration file, execute the write command on the device. The configuration file is saved in the /etc/sonic/ directory of the device, named in the format ** config_db_*.json **. Then, export the configuration file using SCP or other methods.

It is important to note that the configuration file must be written strictly in JSON format and comply with the device’s requirements for the configuration file content. It is recommended that users export the configuration file and modify it as needed, rather than writing the configuration file directly.

The intermediate file is used to inform the device about the paths of the version image and configuration file to be fetched, as well as the path where the log files generated during the ZTP process need to be uploaded. The file must be named ztp.json.

{
"ztp": {
"configdb-json": {
"dynamic-url": {
"source": {
"prefix": "ftp://ftpserver:test@192.168.0.10/ZTP_CFG/",
"identifier": "serial-number",
"suffix": ".json"
},
"destination":"/etc/sonic/config_db.json"
}
},
"firmware": {
"install": {
"dynamic-url": {
"source": {
"prefix": "ftp://ftpserver:test@192.168.0.10/ZTP_IMAGE/",
"identifier": "product-name",
"suffix": ".bin"
}
},
"set-default": true
}
},
"upload-log": {
"dynamic-upload-url": {
"destination": {
"prefix": "ftp://ftpserver:test@192.168.0.10/ZTP_LOG/",
"identifier": " serial-number",
"suffix": ".LOG"
}
},
"reboot-on-success": true
}
}
}
```** Field Meanings **|** Field **|** Meaning ** | |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- |
| configdb-json | prefix | The absolute path of the configuration file. |
| identifier | The configuration file name. When the field content is serial-number, it indicates that the field will be automatically filled with the device's SN code. If there is no need to distinguish between different devices, a fixed configuration file name can be used. | |
| suffix | The file format, which must be .json for configuration files. | |
| firmware | prefix | The absolute path of the image file. |
| identifier | The image file name. When the field content is product-name, it indicates that the field will be automatically filled with the device type. If there is no need to distinguish between device types, a fixed name can be used. | |
| suffix | The file format, which must be .bin for image files. | |
| upload-log | prefix | The specified path for uploading logs to the file server. |
| identifier | The log file name. | |
| suffix | The log file format. | |
| set-default | Set the image as the default to be loaded at startup. | |
| reboot-on-success | Automatically reboot the device after the ZTP process is completed successfully. | |
### Configuration Example
Network requirements
A certain company has multiple switches that need to be deployed in bulk, upgraded, and configured. To save on human resources and streamline the process, they plan to use zero-touch provisioning for deployment.
![](/media/archbee/cxCYtny71WRcvqG8mmCoz-20251202-093732.png)
Procedure
1. Configure the DHCP Server and add an option field to configure the FTP server address.
```bash
option bootfile-name ”ftp\://ftpserver\:test@192.168.0.10/ztp.json
  1. Create a ZTP file in the /ftpboot directory of the FTP server, and provide directory information for the required files during the ZTP process.
{
"ztp": {
"configdb-json": {
"dynamic-url": {
"source": {
"prefix": "ftp://ftpserver:test@192.168.0.10/ZTP_CFG/",
"identifier": "serial-number",
"suffix": ".json"
},
"destination":"/etc/sonic/config_db.json"
}
},
"firmware": {
"install": {
"dynamic-url": {
"source": {
"prefix": "ftp://ftpserver:test@192.168.0.10/ZTP_IMAGE/",
"identifier": "product-name",
"suffix": ".bin"
}
},
"set-default": true
}
},
"upload-log": {
"dynamic-upload-url": {
"destination": {
"prefix": "ftp://ftpserver:test@192.168.0.10/ZTP_LOG/",
"identifier": " serial-number",
"suffix": ".LOG"
}
},
"reboot-on-success": true
}
}
}
  1. Upload the required files to the directory specified in the ztp.json file on the FTP server.

Verify configuration

After device reboot, view device version and configuration

sonic# show version
sonic# show running-config