aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/error.rs2
-rw-r--r--src/main.rs12
2 files changed, 12 insertions, 2 deletions
diff --git a/src/error.rs b/src/error.rs
index b525e47..3431850 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -4,6 +4,8 @@ use thiserror::Error;
pub enum Error {
#[error("parse ip address: {0}")]
AddrParse(#[from] std::net::AddrParseError),
+ #[error("ipnetwork: {0}")]
+ IpNetwork(#[from] ipnetwork::IpNetworkError),
#[error("rustables builder: {0}")]
RustablesBuilder(#[from] rustables::error::BuilderError),
#[error("rustables query: {0}")]
diff --git a/src/main.rs b/src/main.rs
index 4d604af..1d91419 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,8 +1,10 @@
use rsdsl_netfilterd::error::Result;
+use std::net::Ipv4Addr;
use std::thread;
use std::time::Duration;
+use ipnetwork::Ipv4Network;
use rustables::{
Batch, Chain, ChainPolicy, ChainType, Hook, HookClass, MsgType, Protocol, ProtocolFamily, Rule,
Table,
@@ -26,8 +28,14 @@ fn nat() -> Result<()> {
batch.add(&postrouting, MsgType::Add);
- let rule = Rule::new(&postrouting)?.oface("ppp0")?.masquerade();
- batch.add(&rule, MsgType::Add);
+ let masq_outbound_modem = Rule::new(&postrouting)?
+ .oface("eth1")?
+ .dnetwork(Ipv4Network::new(Ipv4Addr::new(192, 168, 1, 0), 24)?.into())?
+ .masquerade();
+ batch.add(&masq_outbound_modem, MsgType::Add);
+
+ let masq_outbound_wan = Rule::new(&postrouting)?.oface("ppp0")?.masquerade();
+ batch.add(&masq_outbound_wan, MsgType::Add);
// +------------------+
// | PREROUTING chain |