dhcpv6
This commit is contained in:
parent
90e1aaa20d
commit
00a630fd34
32
src/main.cr
32
src/main.cr
@ -183,6 +183,13 @@ class NetworkCommands
|
|||||||
raise "(udhcpc) dhcp failed on #{ifname}"
|
raise "(udhcpc) dhcp failed on #{ifname}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.dhcp6(ifname : String)
|
||||||
|
# we suppose udhcpc6 installed along with udhcpc
|
||||||
|
unless Do.run("udhcpc6", [ ifname ]).success?
|
||||||
|
raise "(udhcpc6) dhcp failed on #{ifname}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class DHClientCommand
|
class DHClientCommand
|
||||||
@ -191,6 +198,12 @@ class NetworkCommands
|
|||||||
raise "(dhclient) dhcp failed on #{ifname}"
|
raise "(dhclient) dhcp failed on #{ifname}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.dhcp6(ifname : String)
|
||||||
|
unless Do.run("dhclient", [ "-6", ifname ]).success?
|
||||||
|
raise "(dhclient) dhcp6 failed on #{ifname}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class IfconfigCommand
|
class IfconfigCommand
|
||||||
@ -367,6 +380,13 @@ class NetworkCommands
|
|||||||
|
|
||||||
def self.autoconfiguration(ifname : String)
|
def self.autoconfiguration(ifname : String)
|
||||||
puts "TODO: IPv6 autoconfiguration setup"
|
puts "TODO: IPv6 autoconfiguration setup"
|
||||||
|
puts "sysctl -w net.ipv6.conf.#{ifname}.autoconf=1"
|
||||||
|
puts "sysctl -w net.ipv6.conf.#{ifname}.accept_ra=1"
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.dhcp6(ifname : String)
|
||||||
|
puts "TODO: dhcpv6"
|
||||||
|
@@cmd_dhcp_client.dhcp6 ifname
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.wireless_connect_wpa_psk(ifname : String, ssid : String, passwd : String)
|
def self.wireless_connect_wpa_psk(ifname : String, ssid : String, passwd : String)
|
||||||
@ -613,20 +633,15 @@ class InterfaceConfiguration
|
|||||||
|
|
||||||
# ipv6 configuration
|
# ipv6 configuration
|
||||||
main_ip_v6.tap do |ip|
|
main_ip_v6.tap do |ip|
|
||||||
puts "CONFIGURATION IPV6"
|
|
||||||
|
|
||||||
case ip
|
case ip
|
||||||
when IPAddress
|
when IPAddress
|
||||||
NetworkCommands.set_ip name, ip
|
NetworkCommands.set_ip name, ip
|
||||||
# TODO
|
|
||||||
when Autoconfiguration
|
when Autoconfiguration
|
||||||
puts "CONFIGURATION IPV6 : autoconfiguration !!!"
|
|
||||||
NetworkCommands.autoconfiguration name
|
NetworkCommands.autoconfiguration name
|
||||||
#when DHCP
|
when DHCP
|
||||||
# NetworkCommands.dhcp6 name
|
NetworkCommands.dhcp6 name
|
||||||
when NotSetup
|
when NotSetup
|
||||||
# do nothing
|
# do nothing
|
||||||
puts "CONFIGURATION IPV6 : not setup !!!"
|
|
||||||
else
|
else
|
||||||
raise "ipv6 configuration: neither static nor dynamic"
|
raise "ipv6 configuration: neither static nor dynamic"
|
||||||
end
|
end
|
||||||
@ -780,10 +795,7 @@ class NetworkConfigurationParser
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO
|
|
||||||
ipaddr = IPAddress.parse ipstr
|
ipaddr = IPAddress.parse ipstr
|
||||||
|
|
||||||
# TODO
|
|
||||||
access_point = wireless_networks[ssid].not_nil!
|
access_point = wireless_networks[ssid].not_nil!
|
||||||
|
|
||||||
if ipaddr.ipv4?
|
if ipaddr.ipv4?
|
||||||
|
Loading…
Reference in New Issue
Block a user