Interfaces
Interface configuration commands in SONiC enable you to configure and manage interface parameters, including the ability to
- assign an IP address for an interface
- remove an IP address from an interface, and
- display configured IP addresses on a system.
Interface configuration commands
Assign IP to an interface using the config interface ip add
command:
admin@sonic:~$ sudo config interface ip add -h
Usage: config interface ip add [OPTIONS] <interface_name> <ip_addr> <default
gateway IP address>
Add an IP address towards the interface
Options:
-h, -?, --help Show this message and exit.
For example:
sudo config interface ip add Ethernet0 192.1.1.2/30
Remove IP from an interface using the config interface ip remove
command:
admin@sonic:~$ sudo config interface ip remove -h
Usage: config interface ip remove [OPTIONS] <interface_name> <ip_addr>
Remove an IP address from the interface
Options:
-h, -?, --help Show this message and exit.
For example:
sudo config interface ip remove Ethernet0 192.1.1.2/30
Save changed configurations using the config save
command:
config save -y
Verification commands
View all interfaces with IP addresses configured using the show ip interfaces
command:
root@sonic:/home/admin# show ip interfaces
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- ------------ -------------- -------------
Ethernet0 192.1.1.2/30 up/down N/A N/A
docker0 240.127.1.1/24 up/down N/A N/A
eth0 192.168.1.2/16 up/up N/A N/A
lo 127.0.0.1/16 up/up N/A N/A
root@sonic:/home/admin#
Configure interface MTU
Change interface MTU using the config interface mtu
command:
admin@sonic:~$ sudo config interface mtu -h
Usage: config interface mtu [OPTIONS] <interface_name> <interface_mtu>
Set interface mtu
Options:
-v, --verbose Enable verbose output
-?, -h, --help Show this message and exit.
For example:
root@R1:/home/cisco# sudo config interface mtu Ethernet0 9214
Let's verify our changes:
root@R1:/home/cisco# show interfaces status
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
----------- --------------------------------------- ------- ----- ----- ------- ------ ------ ------- ------ ----------
Ethernet0 2304,2305,2306,2307,2308,2309,2310,2311 400G 9214 N/A etp0 routed down up N/A N/A
Ethernet8 2320,2321,2322,2323,2324,2325,2326,2327 400G 9100 N/A etp1 routed down up N/A N/A
To save our changes to /etc/sonic/config_db.json
:
config save -y