Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Normal rule cause exception #22

Open
soroshsabz opened this issue Aug 10, 2023 · 1 comment
Open

[Bug] Normal rule cause exception #22

soroshsabz opened this issue Aug 10, 2023 · 1 comment

Comments

@soroshsabz
Copy link
Contributor

ITNOA

Hi

I have rule like below

-A INPUT  --protocol tcp --source 2.2.2.2 --destination 1.1.1.1 --source-port 111 --destination-port 222 --jump DROP

I try this rule in iptables command in bash and work correctly, but when I try to create rule for this like below

            IpTablesRule rule = IpTablesRule.Parse($"-A  INPUT  --protocol tcp --source 2.2.2.2 --destination 1.1.1.1 --source-port 111 --destination-port 222 --jump DROP", null, chains);

I got exception

IPTables.Net.Exceptions.IpTablesParserException: Error parsing rule: -A INPUT  --protocol tcp --source 2.2.2.2 --destination 1.1.1.1 --source-port 111 --destination-port 222 --jump DROP
 ---> IPTables.Net.Exceptions.IpTablesNetException: Unknown option: "--source-port"
   at IPTables.Net.Iptables.Modules.CommandParser.FeedToSkip(Int32 position, Boolean not)
   at IPTables.Net.Iptables.IpTablesCommand.Parse(String rule, IpTablesSystem system, IpTablesChainSet chains, CommandParser& parserOut, Int32 version, String defaultTable)
   --- End of inner exception stack trace ---
   at IPTables.Net.Iptables.IpTablesCommand.Parse(String rule, IpTablesSystem system, IpTablesChainSet chains, CommandParser& parserOut, Int32 version, String defaultTable)
   at IPTables.Net.Iptables.IpTablesRule.Parse(String rule, IpTablesSystem system, IpTablesChainSet chains, Int32 version, String defaultTable, ChainCreateMode createChain)
   at BSN.IpTables.Api.Controllers.V1.HomeController.Append(RulesCommandServiceAppendRequest request) in D:\Source\Repos\Resa\IpTables.Api\Source\BSN.IpTables.Api\Controllers\V1\HomeController.cs:line 57
   at lambda_method481(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
@splitice
Copy link
Owner

You need to specify the required module. The implicit -p module loading is not supported (pr welcome).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants