summaryrefslogtreecommitdiff
path: root/src/settings/plugins/ifnet/tests/net
blob: a5ac9ca2381bb5179a3a49b1e32877e62d4009e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).

modules="!wpa_supplicant"

config_eth0=(
"202.117.16.121    netmask    255.255.255.0 brd 202.117.16.255"
"192.168.4.121/24"
"dhcp6"
)
routes_eth0=( "default via     202.117.16.1" 
		"192.168.4.0/24 via 192.168.4.1")
dns_servers_eth0="202.117.0.20    202.117.0.21"
dns_search_eth0="p12.edu.cn p13.edu.cn"

config_eth1=(
	"dhcp"
)
enable_ipv6_eth1="true"
routes_eth1=( "default via 202.117.16.1" )
dns_servers_eth1="202.117.0.20 202.117.0.21"
config_eth2=(
"202.117.16.1211    netmask    255.255.255.0 brd 202.117.16.255"
"192.168.4.121/24"
"4321:0:1:2:3:4:567:89ab/64"
)
routes_eth2=("default via  4321:0:1:2:3:4:567:89ab")
enable_ipv6_eth2="true"
config_eth3=("nufjlsjlll")
managed_eth4="false"
routes_eth4=("default via 4321:0:1:2:3:4:567:89ab")
config_eth5=("dhcp")

config_eth7=( "dhcp" )
auto_eth7="true"

# missing config_eth8
auto_eth8="true"

#new openrc style
config_eth9="202.117.16.10/24 202.117.17.10/24"
routes_eth9="default via 202.117.16.1
10.0.0.0/8 via 192.168.0.1
"
config_eth10="202.117.16.2 netmask 255.255.255.0"
routes_eth10="10.0.0.0/8 via 192.168.0.1"

config_myxjtu2=("202.117.16.121/24 brd 202.117.16.255")
routes_myxjtu2=("default via 202.117.16.1")
dns_servers_myxjtu2="202.117.0.20 202.117.0.21"
#key_myxjtu2="[1] s:xjtud key [1] enc restricted"
#key_eth6="[1] aaaa-4444-3d [2] s:xjtudlc key [1] enc open"


username_ppp0='user'
password_ppp0='password'

config_qiaomuf=("dhcp")

config_1xtest=("dhcp")

config_0xab3ace=("dhcp")

modules=( "iproute2" )
	config_kvm0=( "null" )
	config_kvm1=( "null" )

	tuntap_kvm0="tap"
	tuntap_kvm1="tap"
	tunctl_kvm0="-u user"
	tunctl_kvm1="-u user"

bridge_br0="eth0 kvm0 kvm1"
config_br0=( "192.168.1.10/24" )
	brctl_br0=( "setfd 0")
	dhcp_eth1="nosendhost nontp -I"

predown() {
	# The default in the script is to test for NFS root and disallow
	# downing interfaces in that case.  Note that if you specify a
	# predown() function you will override that logic.  Here it is, in
	# case you still want it...
	if is_net_fs /; then
		eerror "root filesystem is network mounted -- can't stop ${IFACE}"
		return 1
	fi

	# Remember to return 0 on success
	return 0
}

postup() {
	# This function could be used, for example, to register with a
	# dynamic DNS service.  Another possibility would be to
	# send/receive mail once the interface is brought up.

	# Here is an example that allows the use of iproute rules
	# which have been configured using the rules_eth0 variable.
	#rules_eth0=" \
	#	'from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100' \
	#	'from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100' \
	#"
	eval set -- \$rules_${IFVAR}
	if [ $# != 0 ]; then
		einfo "Adding IP policy routing rules"
		eindent
		# Ensure that the kernel supports policy routing
		if ! ip rule list | grep -q "^"; then
			eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
			eerror "in your kernel to use ip rules"
		else
			for x; do
				ebegin "${x}"
				ip rule add ${x}
				eend $?
			done
		fi
		eoutdent
		# Flush the cache
		ip route flush cache dev "${IFACE}"
	fi

}

postdown() {
	# Enable Wake-On-LAN for every interface except for lo
	# Probably a good idea to set ifdown="no" in /etc/conf.d/net
	# as well ;)
	[ "${IFACE}" != "lo" ] && ethtool -s "${IFACE}" wol g

	Automatically erase any ip rules created in the example postup above
	if interface_exists "${IFACE}"; then
		# Remove any rules for this interface
		local rule
		ip rule list | grep " iif ${IFACE}[ ]*" | {
			while read rule; do
				rule="${rule#*:}"	
				ip rule del ${rule}
			done
		}
		# Flush the route cache
		ip route flush cache dev "${IFACE}"
	fi

	# Return 0 always
	return 0
}

failup() {
       # This function is mostly here for completeness... I haven't
       # thought of anything nifty to do with it yet ;-)
}

faildown() 
{}