aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-03-21 14:49:49 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-03-21 14:49:49 +0100
commitc5ebda8f56439b23fc9c3309d671382de02ad7b2 (patch)
tree8adeb66779db3435e15f5ab750a9b31dafb093ff /src
parent016ca36fe064f1cd95821f337366b65d74d05609 (diff)
configure lan interface with a static ipv4 address
Diffstat (limited to 'src')
-rw-r--r--src/error.rs3
-rw-r--r--src/main.rs15
2 files changed, 18 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index 2440169..78bd0ba 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,4 +1,5 @@
use std::io;
+use std::net;
use thiserror::Error;
@@ -8,6 +9,8 @@ pub enum Error {
LinkNotFound(String),
#[error("io: {0}")]
Io(#[from] io::Error),
+ #[error("net: parse ip address: {0}")]
+ NetAddrParseError(#[from] net::AddrParseError),
#[error("notify: {0}")]
Notify(#[from] notify::Error),
#[error("rtnetlink: {0}")]
diff --git a/src/main.rs b/src/main.rs
index a857344..c7663fa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,6 +17,14 @@ fn main() -> Result<()> {
link::up("eth0".into())?;
link::up("eth1".into())?;
+ match configure_eth0() {
+ Ok(_) => println!("[netlinkd] configure eth0 statically (10.128.0.254/24)"),
+ Err(e) => {
+ println!("[netlinkd] can't configure eth0: {:?}", e);
+ return Err(e);
+ }
+ }
+
let ip_config = Path::new("/data/pppoe.ip_config");
while !ip_config.exists() {
println!("[netlinkd] waiting for PPPoE connection");
@@ -45,6 +53,13 @@ fn main() -> Result<()> {
}
}
+fn configure_eth0() -> Result<()> {
+ addr::flush("eth0".into())?;
+ addr::add("eth0".into(), "10.128.0.254".parse()?, 24)?;
+
+ Ok(())
+}
+
fn configure_wan() {
match configure_rsppp0() {
Ok(_) => println!("[netlinkd] configure rsppp0 with PPPoE data"),