Network configuration files in linux (taking into account all major releases)

Source: Internet
Author: User
For more information about the network configuration files in linux (taking into account the mainstream releases)-Linux Enterprise applications-Linux server applications, see the following. In fact, there is no specific release version. As we all know, there are too many Linux releases and LSB cannot be the same. The network is started through some scripts at system startup, such as the/etc/init. d/network file under redhat/fedora. Read the initialization script of the system as appropriate.
[Lee @ lee init. d] $ cat network
#! /Bin/bash
#
# Network Bring up/down networking
#
# Chkconfig: 2345 10 90
# Description: Activates/Deactivates all network interfaces configured \
# Start at boot time.
#
### BEGIN INIT INFO
# Provides: $ network
### END INIT INFO

# Source function library.
./Etc/init. d/functions

If [! -F/etc/sysconfig/network]; then
Exit 0
Fi

./Etc/sysconfig/network

If [-f/etc/sysconfig/pcmcia]; then
./Etc/sysconfig/pcmcia
Fi


# Check that networking is up.
["$ {NETWORKING}" = "no"] & exit 0

# If the ip configuration utility isn' t around we can't function.
[-X/sbin/ip] | exit 1

# Even if IPX is configured, without the utilities we can't do much
[! -X/sbin/ipx_internal_net-o! -X/sbin/ipx_configure] & IPX =

# Even if VLAN is configured, without the utility we can't do much
[! -X/sbin/vconfig] & VLAN =

CWD = 'pwd'
Cd/etc/sysconfig/network-scripts

. Network-functions // pay attention to this cute script file!

# Find all the interfaces besides loopback.
# Ignore aliases, alternative deployments, and editor backup files
Interfaces = 'ls ifcfg * | \
LANG = C sed-e '/\ (ifcfg-lo \ |: \ | ifcfg-. *-range \)/d '\
-E '/\ (rpmsave \ | rpmorig \ | rpmnew \)/d '\
-E '/\(~ \ | \. Bak \) $/d '\
-E'/ifcfg-[A-Za-z0-9 \. _-] \ + $/{s/^ ifcfg-// g; s/[0-9]/&/} '| \
LANG = C sort-k 1, 1-k 2n | \
LANG = C sed's ///''

# See how we were called.
Case "$1" in
Start)
# IPv6 hook (pre IPv4 start)
If ["$ NETWORKING_IPV6" = "yes"]; then
If [-x/etc/sysconfig/network-scripts/init. ipv6-global]; then
/Etc/sysconfig/network-scripts/init. ipv6-global start pre
Fi
Fi

Sysctl-e-p/etc/sysctl. conf>/dev/null 2> & 1

# Bring up loopback interface
Action $ "Bringing up loopback interface:"./ifup ifcfg-lo

Case "$ IPX" in
Yes | true)
/Sbin/ipx_configure -- auto_primary = $ IPXAUTOPRIMARY \
-- Auto_interface = $ IPXAUTOFRAME
If ["$ IPXINTERNALNETNUM "! = "0"]; then
/Sbin/ipx_internal_net add $ IPXINTERNALNETNUM $ IPXINTERNALNODENUM
Fi
;;
Esac

Case "$ VLAN" in
Yes)
If [-d/proc/net/vlan] | modprobe 8021q>/dev/null 2> & 1; then
Test-z "$ VLAN_NAME_TYPE" & VLAN_NAME_TYPE = DEV_PLUS_VID_NO_PAD
Action $ "Setting 802.1Q VLAN parameters:"/sbin/vconfig set_name_type "$ VLAN_NAME_TYPE"
Else
Echo $ "No 802.1Q VLAN support available in kernel ."
Fi
;;
Esac

Vlaninterfaces = ""
Cipeinterfaces = ""
Xdslinterfaces = ""
Bridgeinterfaces = ""

# Bring up all other interfaces configured to come up at boot time
For I in $ interfaces; do
Eval $ (LANG = C fgrep "DEVICE =" ifcfg-$ I)
Eval $ (LANG = C fgrep "TYPE =" ifcfg-$ I)
Eval $ (LANG = C fgrep "SLAVE =" ifcfg-$ I)
Eval $ (LANG = C fgrep "BRIDGE =" ifcfg-$ I)

If [-z "$ DEVICE"]; then DEVICE = "$ I"; fi

If ["$ {DEVICE # cipcb }"! = "$ DEVICE"]; then
Cipeinterfaces = "$ cipeinterfaces $ I"
Unset DEVICE TYPE SLAVE BRIDGE
Continue
Fi
If ["$ TYPE" = "xDSL"]; then
Xdslinterfaces = "$ xdslinterfaces $ I"
Unset DEVICE TYPE SLAVE BRIDGE
Continue
Fi

If [-n "$ BRIDGE"]; then
Is_available $ I
Bridgeinterfaces = "$ bridgeinterfaces $ I"
Unset DEVICE TYPE SLAVE BRIDGE
Continue
Fi

If ["$ {DEVICE % .*}"! = "$ DEVICE"]; then
Vlaninterfaces = "$ vlaninterfaces $ I"
Unset DEVICE TYPE SLAVE BRIDGE
Continue
Fi

If ["$ SLAVE" = "yes"]; then
Unset DEVICE TYPE SLAVE BRIDGE
Continue
Fi
Unset DEVICE TYPE SLAVE BRIDGE

If LANG = C egrep-L "^ ONBOOT = ['\"]? [Nn] [Oo] ['\ "]? "Ifcfg-$ I>/dev/null; then
# This loads the module, to preserve ordering
Is_available $ I
Continue
Fi
# If we're in confirmation mode, get user confirmation.
If [-f/var/run/confirm]; then
Confirm $ I
Test $? = 1 & continue
Fi
Action $ "Bringing up interface $ I:"./ifup $ I boot
Done

# Bring up xDSL and CIPE interfaces
For I in $ vlaninterfaces $ bridgeinterfaces $ xdslinterfaces $ cipeinterfaces; do
If! LANG = C egrep-L "^ ONBOOT = ['\"]? [Nn] [Oo] ['\ "]? "Ifcfg-$ I>/dev/null 2> & 1; then
# If we're in confirmation mode, get user confirmation.
If [-f/var/run/confirm]; then
Confirm $ I
Test $? = 1 & continue
Fi
Action $ "Bringing up interface $ I:"./ifup $ I boot
Fi
Done

# Add non interface-specific static-routes.
If [-f/etc/sysconfig/static-routes]; then
Grep "^ any"/etc/sysconfig/static-routes | while read ignore args; do
/Sbin/route add-$ args
Done
Fi

# IPv6 hook (post IPv4 start)
If ["$ NETWORKING_IPV6" = "yes"]; then
If [-x/etc/sysconfig/network-scripts/init. ipv6-global]; then
/Etc/sysconfig/network-scripts/init. ipv6-global start post
Fi
Fi
# Run this again to catch any interface-specific actions
Sysctl-e-p/etc/sysctl. conf>/dev/null 2> & 1

Touch/var/lock/subsys/network
;;
Stop)
# If this is a final shutdown/halt, check for network FS,
# And unmount them even if the user didn't turn on netfs

If ["$ RUNLEVEL" = "6"-o "$ RUNLEVEL" = "0"-o "$ RUNLEVEL" = "1"]; then
NFSMTAB = 'lc _ ALL = C awk '$3 ~ /^ Nfs/{print $2} '/proc/mounts'
SMBMTAB = 'lc _ ALL = C awk' $3 = "smbfs" {print $2} '/proc/mounts'
NCPMTAB = 'lc _ ALL = C awk '$3 = "ncpfs" {print $2}'/proc/mounts'
If [-n "$ NFSMTAB"-o-n "$ SMBMTAB"-o-n "$ NCPMTAB"]; then
/Etc/init. d/netfs stop
Fi
Fi

# IPv6 hook (pre IPv4 stop)
If ["$ NETWORKING_IPV6" = "yes"]; then
If [-x/etc/sysconfig/network-scripts/init. ipv6-global]; then
/Etc/sysconfig/network-scripts/init. ipv6-global stop pre
Fi
Fi

Vlaninterfaces = ""
Cipeinterfaces = ""
Xdslinterfaces = ""
Bridgeinterfaces = ""
Remaining = ""

# Get list of bonding, cipe, and xdsl interfaces
For I in $ interfaces; do
Eval $ (LANG = C fgrep "DEVICE =" ifcfg-$ I)
Eval $ (LANG = C fgrep "TYPE =" ifcfg-$ I)
Eval $ (LANG = C fgrep "BRIDGE =" ifcfg-$ I)

If [-z "$ DEVICE"]; then DEVICE = "$ I"; fi

If ["$ {DEVICE # cipcb }"! = "$ DEVICE"]; then
Cipeinterfaces = "$ cipeinterfaces $ I"
Unset DEVICE TYPE BRIDGE
Continue
Fi
If [-n "$ BRIDGE"]; then
Bridgeinterfaces = "$ bridgeinterfaces $ I"
Unset DEVICE TYPE BRIDGE
Continue
Fi
If ["$ TYPE" = "xDSL"]; then
Xdslinterfaces = "$ xdslinterfaces $ I"
Unset DEVICE TYPE BRIDGE
Continue
Fi

If ["$ {DEVICE % .*}"! = "$ DEVICE"]; then
Vlaninterfaces = "$ vlaninterfaces $ I"
Unset DEVICE TYPE SLAVE BRIDGE
Continue
Fi
Remaining = "$ remaining $ I"
Unset DEVICE TYPE BRIDGE
Done

For I in $ cipeinterfaces $ xdslinterfaces $ bridgeinterfaces $ vlaninterfaces; do
Eval $ (fgrep "DEVICE =" ifcfg-$ I)
If [-z "$ DEVICE"]; then DEVICE = "$ I"; fi

If! Check_device_down $ DEVICE; then
Action $ "Shutting down interface $ I:"./ifdown $ I boot
Fi
Done

# Shut down all interfaces (other than loopback)
For I in $ remaining; do
Eval $ (fgrep "DEVICE =" ifcfg-$ I)
If [-z "$ DEVICE"]; then DEVICE = "$ I"; fi

If! Check_device_down $ DEVICE; then
Action $ "Shutting down interface $ I:"./ifdown $ I boot
Fi
Done
Case "$ IPX" in
Yes | true)
If ["$ IPXINTERNALNETNUM "! = "0"]; then
/Sbin/ipx_internal_net del
Fi
;;
Esac

Action $ "Shutting down loopback interface:"./ifdown ifcfg-lo

If [-d/proc/sys/net/ipv4]; then
# Ip advanced options
If [-f/proc/sys/net/ipv4/ip_forward]; then
If ['cat/proc/sys/net/ipv4/ip_forward '! = 0]; then
Action $ "Disabling IPv4 packet forwarding:" sysctl-w net. ipv4.ip _ forward = 0
Fi
Fi
If [-f/proc/sys/net/ipv4/ip_always_defrag]; then
If ['cat/proc/sys/net/ipv4/ip_always_defrag '! = 0]; then
Action $ "Disabling IPv4 automatic defragmentation:" sysctl-w net. ipv4.ip _ always_defrag = 0
Fi
Fi
Fi

# IPv6 hook (post IPv4 stop)
If ["$ NETWORKING_IPV6" = "yes"]; then
If [-x/etc/sysconfig/network-scripts/init. ipv6-global]; then
/Etc/sysconfig/network-scripts/init. ipv6-global stop post
Fi
Fi

Rm-f/var/lock/subsys/network
;;
Status)
Echo $ "Configured devices :"
Echo lo $ interfaces

Echo $ "Currently active devices :"
Echo '/sbin/ip-o link show | awk-F ":"'/UP>/{print $2 }''
;;
Restart | reload)
Cd "$ CWD"
$0 stop
$0 start
;;
*)
Echo $ "Usage: $0 {start | stop | restart | reload | status }"
Exit 1
Esac

Exit 0

This is the script, full of sed, grep, egrep, awk regular expressions, what a magical world!
Let's see where they are !!! Not changed at all!

Red hat
/Etc/sysconfig/network
/Etc/sysconfig/networking
/Etc/sysconfig/network-scripts/ifcfg-ifname
The following are my operations on the PC. Check the files carefully. All the files except the three files above should contain detailed network settings as much as possible:
[Lee @ lee sysconfig] $ ls
Amd bluetooth dund i18n kudzu network prelink squid xgl
Apmd cbq firstboot init lm_sensors networking rhn syslog xinetd
Apm-scripts clock grub iptables-config modules network-scripts samba system-config-securitylevel
Arpwatch console hidd irda named ntpd saslauthd system-config-users
Auditd crond hsqldb irqbalance netdump pand selinux tux
Authconfig desktop httpd kernel netdump_id_dsa pgsql sendmail vncservers
Autofs diskdump hwconf keyboard netdump_id_dsa.pub pm spamassassin wpa_supplicant
[Lee @ lee sysconfig] $ cat network
NETWORKING = yes
HOSTNAME = lee. study. home
[Lee @ lee sysconfig] $ cd networking
[Lee @ lee networking] $ ls
Devices profiles
[Lee @ lee networking] $ cd devices
[Lee @ lee devices] $ ls
Ifcfg-eth0 ifcfg-eth1
[Lee @ lee devices] $ cat ifcfg-eth0
# Realtek semiconduco., Ltd. RTL-8139/8139C/8139C +
DEVICE = eth0
BOOTPROTO = none
BROADCAST = 192.168.0.255
HWADDR = 00: E0: 4D: 90: 4B: 54
IPADDR = 192.168.0.128
NETMASK = 255.255.255.0
NETWORK = 192.168.0.0
ONBOOT = yes
USERCTL = yes
IPV6INIT = no
PEERDNS = yes
GATEWAY = 192.168.0.1
TYPE = Ethernet
[Lee @ lee devices] $ cd ..
[Lee @ lee networking] $ cd profiles
[Lee @ lee profiles] $ ls
Default defacopycopy0
[Lee @ lee profiles] $ cd default
[Lee @ lee default] $ ls
Hosts ifcfg-eth0 ifcfg-eth1 network resolv. conf
[Lee @ lee default] $ cat resolv. conf
# Generated by NetworkManager, do not edit!

Search study. home




Nameserver 202.102.224.68
Nameserver 202.102.247.250
[Lee @ lee default] $ cat hosts
# Do not remove the following line, or various programs
# That require network functionality will fail.
127.0.0.1 lee. study. home lee localhost. localdomain localhost


Suse
/Etc/rc. config
/Etc/route. conf

Debian)
/Etc/hostname
/Etc/network/interfaces

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.