- Linux Administration Cookbook
- Adam K. Dean
- 119字
- 2021-07-02 14:24:30
Configuring a new interface
Start by creating a configuration file for eth2:
$ sudo touch /etc/sysconfig/network-scripts/ifcfg-eth2
Next, populate it using the following:
$ sudo tee /etc/sysconfig/network-scripts/ifcfg-eth2 << HERE
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.44.10
NETMASK=255.255.255.0
DEVICE=eth2
PEERDNS=no
HERE
The tee command is used here. It enables reading from standard input and outputting to a destination of our choosing, in this case, a file.
Now, restart your interface as an individual:
$ sudo ifdown eth2
$ sudo ifup eth2
Alternatively, restart networking in general:
$ sudo systemctl restart network
It's generally a good rule of thumb to be the least disruptive when working with components that make up a greater whole. Even in a dev environment, it's a good habit to get into.