Skip to content

Commit

Permalink
Added new dhcp server version, added asciinema
Browse files Browse the repository at this point in the history
  • Loading branch information
wizche committed Nov 26, 2019
1 parent 3546811 commit 24f37ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@ static void Request(DHCPRequest dhcpRequest, IPAddress targetIp)
var replyOptions = new DHCPReplyOptions();
replyOptions.SubnetMask = IPAddress.Parse("255.255.255.0");

if (type == DHCPMsgType.DHCPDISCOVER)
if (type == DHCPMsgType.DHCPDISCOVER){
Console.WriteLine($"Received discovery, sending offer!");
dhcpRequest.SendDHCPReply(DHCPMsgType.DHCPOFFER, targetIp, replyOptions);
if (type == DHCPMsgType.DHCPREQUEST)
}else if (type == DHCPMsgType.DHCPREQUEST){
Console.WriteLine($"Received request, sending ack!");
dhcpRequest.SendDHCPReply(DHCPMsgType.DHCPACK, targetIp, replyOptions);
} else {
Console.WriteLine($"Received unknown DHCP type {type}");
}
}
catch (Exception ex)
{
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# dhcpshot

[![asciicast](https://asciinema.org/a/OyMydvQOw3imDCD9OLiyiPlUB.svg)](https://asciinema.org/a/OyMydvQOw3imDCD9OLiyiPlUB)

Use [DotNetProjects.DhcpServer](https://www.nuget.org/packages/DotNetProjects.DhcpServer/) library to quickly create a predefined DHCP Server answering with a fixed IP to request coming from the interface specified by the user. E.g.: you connect your RPI in DHCP mode directly to your laptop's ethernet interface.

## Publish
Expand Down
2 changes: 1 addition & 1 deletion dhcpshot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetProjects.DhcpServer" Version="1.0.15" />
<PackageReference Include="DotNetProjects.DhcpServer" Version="2.0.19" />
<PackageReference Include="System.CommandLine.Experimental" Version="0.3.0-alpha.19573.2" />
</ItemGroup>

Expand Down

0 comments on commit 24f37ce

Please sign in to comment.