Linux and etc and network and interfaces Configuration Interface Method
- 2021-07-22 12:20:30
- OfStack
The/etc/network/interfaces file under Linux is used to configure the network interface.
Initialize the network port Ethernet Interface
Most network interface configurations can be addressed in/etc/network/interfaces. For example, configure static IP (dhcp) for network card, set routing information, configure IP mask, set default route, etc.
PS: If you want to start the network port automatically when the system starts up, you need to add an auto1 line, as shown in the following example.
1. Use dynamic IP addresses
auto eth0
iface eth0 inet dhcp
2. Use static IP addresses
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
# network 192.168.1.0
# broadcast 192.168.1.255
network and broadcast1 just use the default values.
3. View the routing table
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
route-n does not resolve names.
The above is this site this site for you to sort out the relevant content, thank you for your study and support.