Write just my current IP address to a text file?


Recommended Posts

If there a way in Linux to output my current IP address to a text file?

ifconfig displays the IP address and I could redirect the output to a file but then I'd have to strip the junk. Is there a direct way to only write the current ip address?

Edit:

What I would really ultimately like to write would be:

dnscmd /recorddelete mydomain.ca ns2 a /f
dnscmd /recordadd mydomain.ca ns2 a xxx.xxx.xx.xxx

(where xxx.xxx.xxx.xxx = my current IP address)

  Quote
I'd like to have a text file that contained nothing other than "xxx.xxx.xxx.xxx"

I know there's plenty of guys on here with nothing buy XXX files. Surely you could borrow some?

Other than that, I can't think of a way to really do what you're asking. I'll poke around a bit.

Edited by SFalcon

dnscmd /recordadd mydomain.ca ns2 a `/sbin/ifconfig eth0 | grep addr | awk '{ print $2 }' | sed -e 's/addr://'`

...replacing eth0 with your external interface.

EDIT: This doesn't drop it to a text file, though... do you need that?

  rezza said:
dnscmd /recordadd mydomain.ca ns2 a `/sbin/ifconfig eth0 | grep addr | awk '{ print $2 }' | sed -e 's/addr://'`

...replacing eth0 with your external interface.

EDIT: This doesn't drop it to a text file, though... do you need that?

586169993[/snapback]

That should be:

/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/addr://'

Otherwise, it might pick up your IPv6 line too.

  code_monkey said:
That should be:

/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/addr://'

Otherwise, it might pick up your IPv6 line too.

586170058[/snapback]

True, I forgot about IPv6 because I don't use it... good point ;)

  code_monkey said:
That should be:

/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/addr://'

Otherwise, it might pick up your IPv6 line too.

586170058[/snapback]

You boys are fancy.

It looks like you are taking the verbose output from ifconfig and cleaning it.

Yea, I need to output it to a text file with a .CMD extension.

I want to write it to a SAMBA drive and then execute it as a batch file on a Windows Server box.

Basically I am trying to write my Linux IP address to the DNS service on my Windows box. Unfortunately, I am still much better with Windows.

I've been having a TERRIBLE time getting iptables/ipchains to forward traffic from the Linux box to the Windows box. However, I just found rinetd and I am again re-envigorated in my quest to have them work together properly.

  fred666 said:
You boys are fancy.

It looks like you are taking the verbose output from ifconfig and cleaning it.

Yea, I need to output it to a text file with a .CMD extension.

I want to write it to a SAMBA drive and then execute it as a batch file on a Windows Server box.

Basically I am trying to write my Linux IP address to the DNS service on my Windows box.  Unfortunately, I am still much better with Windows.

I've been having a TERRIBLE time getting iptables/ipchains to forward traffic from the Linux box to the Windows box.  However, I just found rinetd and I am again re-envigorated in my quest to have them work together properly.

586170485[/snapback]

ip=$(/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/addr://')
echo "dnscmd /recorddelete mydomain.ca ns2 a /f" > something.CMD
echo "dnscmd /recordadd mydomain.ca ns2 a $ip" >> something.CMD

  BudMan said:
Um dude - Why not just make it a static entry in your windows dns?? Where is the linux box getting its IP address from? Your dhcp?? Your ISP?

586171034[/snapback]

It's a dynamic IP from a backup internet provider.

I used to have a working solution when I had two Windows boxes.

The remaining Windows box has the static IP.

  rezza said:
ip=$(/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/addr://')
echo "dnscmd /recorddelete mydomain.ca ns2 a /f" > something.CMD
echo "dnscmd /recordadd mydomain.ca ns2 a $ip" >> something.CMD

586171084[/snapback]

Thank you rezza. That looks perfect.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Mistral AI's new 'Magistral' models bring traceable, faster AI reasoning by Paul Hill One of Europe’s leading AI companies, Mistral, has announced the availability of its Magistral reasoning model. It comes in two versions: there is the open-source Magistral Small (24B parameters) and the enterprise-focused Magistral Medium. Magistral has been designed to better handle domain-specific tasks such as law, finance, and engineering. It shows users the model’s thought processes so that it’s more transparent, and it supports multilingual reasoning to perform better when tasked with answering non-English queries. Key features and performance Mistral compared its new models against DeepSeek R1 in various benchmarks. Ones that stood out were its results on AIME2024, which assesses reasoning capabilities. Magistral Medium scored 73.6% (90% with majority voting @64) while Small scored 70.7% (83.3% respectively). If you’ve used DeepSeek R1, you’ll have seen it thinking before answering. Magistral now does this too and can do it across multiple languages, including English, French, Spanish, German, Italian, Arabic, Russian, and Simplified Chinese. Interestingly, there’s also a Flash Answers mode that speeds up the thinking for 10x faster responses compared to competitors. Real-world applications and availability Thanks to the expertise Magistral has been trained on, organizations across multiple fields, including legal research, financial forecasting, and regulated industries, may be able to turn to Magistral for more reliable answers. Its traceable reasoning also makes it ideal in regulated fields for compliance and auditability. Magistral Small, the open-source model, is available under an Apache 2.0 license via Hugging Face. Magistral Medium is accessible through Mistral's Le Chat and via API on La Plateforme. It’ll also be arriving soon on Amazon SageMaker, IBM WatsonX, Azure AI, and Google Cloud Marketplace. The easiest way for readers to try it out is on Mistral's Le Chat platform; just head to chat.mistral.ai to get started. Source: Mistral
    • Didn't know this thanks, useful.
    • I had to check your comment history to see what you were referring to here. One word... Wow! I asked him myself. LOL
    • Why do you care? Is he your uncle or something? LOL Oh no! Someone made a remark about your favorite blogger you read everyday so you are personally offended.
    • I've been on the 16 beta, since beta 1, and just received the QPR beta 2 today. Nova launcher and no issues. I noticed that two about lack of updates.
  • Recent Achievements

    • Week One Done
      elsa777 earned a badge
      Week One Done
    • One Month Later
      elsa777 earned a badge
      One Month Later
    • First Post
      K Dorman earned a badge
      First Post
    • Reacting Well
      rshit earned a badge
      Reacting Well
    • Reacting Well
      Alan- earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      544
    2. 2
      ATLien_0
      273
    3. 3
      +FloatingFatMan
      207
    4. 4
      +Edouard
      201
    5. 5
      snowy owl
      139
  • Tell a friend

    Love Neowin? Tell a friend!